Jump to content

[SOLVED] Something wrong with query??


glenelkins

Recommended Posts

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

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 ) . "'
								);" );

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()

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.