glenelkins Posted February 24, 2009 Share Posted February 24, 2009 Hi Any ideas whats up with this query: INSERT INTO `images` VALUES ( '', 'Test', 'uploads/images/53a07136a64005ab666135e13ffad263' ); The database table has id (auto increment int), image_id(varchar), and image_file(mediumtext) I get this error, its confusing as the query looks fine to me: 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 'Resource id #49' at line 1 Link to comment https://forums.phpfreaks.com/topic/146670-solved-something-wrong-with-query/ Share on other sites More sharing options...
JonnoTheDev Posted February 24, 2009 Share Posted February 24, 2009 Since your error reads 'Resource id #49' It seems that you maybe passing an object into the query rather than the SQL. There is nothing wrong with the SQL syntax. Check your code. Link to comment https://forums.phpfreaks.com/topic/146670-solved-something-wrong-with-query/#findComment-770009 Share on other sites More sharing options...
glenelkins Posted February 24, 2009 Author Share Posted February 24, 2009 There is no object being sent to the query. Here is the php $upload_folder = $this->kernel->get_config ( 'uploads_folder' ) . 'images/'; $image_id = eregi_replace ( ' ', '_', $post_array['image_id'] ); $file_tmp_name = $files_array['image_file']['tmp_name']; $file_name = $files_array['image_file']['tmp_name']; // Convert file name to hash code with // random string $salt1 = rand ( 1, 500 ); $salt2 = rand ( 1, 500 ); $file_name = md5 ( $salt1 . $file_name . $salt2 ); move_uploaded_file ( $file_tmp_name, $upload_folder . $file_name ); $this->kernel->query ( "INSERT INTO `{$this->kernel->get_config ( 'images_table' )}` VALUES ( '', '$image_id', '" . addslashes ( $upload_folder . $file_name ) . "' );" ); Link to comment https://forums.phpfreaks.com/topic/146670-solved-something-wrong-with-query/#findComment-770013 Share on other sites More sharing options...
JonnoTheDev Posted February 24, 2009 Share Posted February 24, 2009 Must be. Use the following: $this->kernel->query("INSERT INTO ".$this->kernel->get_config('images_table')." VALUES('','".$image_id."','".addslashes($upload_folder.$file_name)."');"); Link to comment https://forums.phpfreaks.com/topic/146670-solved-something-wrong-with-query/#findComment-770019 Share on other sites More sharing options...
PFMaBiSmAd Posted February 24, 2009 Share Posted February 24, 2009 Then that is not the query that is producing that error. Also, addslashes() does not escape all the special characters that can break a query. Assuming you are using mysql, you should be using mysql_real_escape_string() Link to comment https://forums.phpfreaks.com/topic/146670-solved-something-wrong-with-query/#findComment-770021 Share on other sites More sharing options...
glenelkins Posted February 24, 2009 Author Share Posted February 24, 2009 So then what is producing the error? Its bloody strange Link to comment https://forums.phpfreaks.com/topic/146670-solved-something-wrong-with-query/#findComment-770024 Share on other sites More sharing options...
glenelkins Posted February 24, 2009 Author Share Posted February 24, 2009 hmm its not even that function at all causing the issue here. though it was working fine until i edited that function...agghghgh now i gotta hunt it down ffs Link to comment https://forums.phpfreaks.com/topic/146670-solved-something-wrong-with-query/#findComment-770025 Share on other sites More sharing options...
PFMaBiSmAd Posted February 24, 2009 Share Posted February 24, 2009 Since we don't have access to all your code unless you post it, you would need to answer that question or post all the relevant code if you want someone else to help with the problem. Link to comment https://forums.phpfreaks.com/topic/146670-solved-something-wrong-with-query/#findComment-770026 Share on other sites More sharing options...
JonnoTheDev Posted February 24, 2009 Share Posted February 24, 2009 Its gotta be this within your query. Check my post above `{$this->kernel->get_config ( 'images_table' )}` Link to comment https://forums.phpfreaks.com/topic/146670-solved-something-wrong-with-query/#findComment-770027 Share on other sites More sharing options...
glenelkins Posted February 24, 2009 Author Share Posted February 24, 2009 I found the issue. Its in a completely different class one called "template" where the system replaces html tags from a database. For some reason it was getting stuck on one of the objects created in the loop Link to comment https://forums.phpfreaks.com/topic/146670-solved-something-wrong-with-query/#findComment-770040 Share on other sites More sharing options...
glenelkins Posted February 24, 2009 Author Share Posted February 24, 2009 lol in fact it was my stupid error in a function using a query function rather than a fetch array function ...dumb ass! Link to comment https://forums.phpfreaks.com/topic/146670-solved-something-wrong-with-query/#findComment-770042 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.