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

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

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


New User

Apr 14, 2008, 1:33 PM

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

This is my query...

$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:

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 ./ 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?


May 9, 2008, 11:25 PM

Post #2 of 2 (7609 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 ();

$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