CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: DBI:
MySQL Query Execution Problem

 



chromox
New User

Apr 14, 2008, 1:33 PM

Post #1 of 2 (5233 views)
MySQL Query Execution Problem Can't Post

This is my query...

Code
$sql = "INSERT INTO `abliss`.`songs` (`id`,`artist`,`album`,`name`,`track`,`year`,`length`,`plays`,`filename`) VALUES (NULL,'\'$main::artist\'','\'$main::album\'','\'$main::title\'','\'$main::track\'','$main::year','0','0','$File::Find::name');";

This is the error:

Code
DBD::mysql::st execute failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'U2'',''How to Dismantle an Atomic Bomb'',''Sometimes You Can't Make It on Your O' at line 1 at ./mp3scan.pl line 32.


Basically I am trying to make it insert the data that I have for each song, and it just doesn't like me I have no idea why the query is not working. Does anyone see something wrong?


winfinit
User

May 9, 2008, 11:25 PM

Post #2 of 2 (5028 views)
Re: [chromox] MySQL Query Execution Problem [In reply to] Can't Post

sorry for super late response :) but anyhow, that is improper usage of DBI, you dont want to insert data inside you query, especially if it contains special characters, you always want to setup your query and replace data with ? (question marks) and then when you do $data->execute();
you place your data into ();

example:
$mark = $dbh->prepare("update movies set status=? where uniqueid=?");
$mark->execute('D', $id);

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives