Jump to content

Recommended Posts

This is a two part question: 

First, what is the best method to sort data using php.  When info is uploaded a sort field is given where the user enters 0 or 1 or so on...

 

I created a new field using tinyint.  Now I am getting this error

Error, query 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 ') 
VALUES ('NEWDAYsmall.jpg', '22667', 'image/pjpeg', 'upload/NEWDAYsmall.jpg', '' at line 1

 

This is the PHP to upload file and data

$filePath = $uploadDir . $fileName;

$result = move_uploaded_file($tmpName, $filePath);
chmod($filePath, 0755);
if (!$result) {
echo "Error uploading file";
exit;
}


if(!get_magic_quotes_gpc())
{
$fileName = addslashes($fileName);
$filePath = addslashes($filePath);
} 
mysql_connect($db_host, $db_user, $db_pwd);
mysql_select_db($db_name);

$query = "INSERT INTO upload2 (name, size, type, path, title, description, buy,) ".
"VALUES ('$fileName', '$fileSize', '$fileType', '$filePath', '$_POST[title]', '$_POST[description]', '$_POST[buy]')";

mysql_query($query) or die('Error, query failed : ' . mysql_error()); 

 

I removed the sort field but I am still getting the same error.  I did play around with the primary a little bit which is currently id

Link to comment
https://forums.phpfreaks.com/topic/75829-solved-mysql-error/
Share on other sites

INSERT INTO `upload2` (`name`,`size`,`type`,`path`,`title,`description`,`buy`)
VALUES ('$fileName','$fileSize','$fileType','$filePath','{$_POST['title']}','{$_POST['description']}','{$_POST['buy']}');

 

Thanks, unfortunately its not the problem.  This form worked fine until a few minutes ago.  I think the error is somewhere in the database, but I don't know.

Link to comment
https://forums.phpfreaks.com/topic/75829-solved-mysql-error/#findComment-383798
Share on other sites

my database was out of wack, so I simply created a new one with the same info and it is working fine...still don't know why I got the error.

 

As far as ordering information, pretty simple:

 

SELECT * FROM upload2 ORDER BY `sort`") or die(mysql_error())

 

 

Link to comment
https://forums.phpfreaks.com/topic/75829-solved-mysql-error/#findComment-383847
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.