Jump to content

my sql syntax error for values()


bryanptcs

Recommended Posts

I am using php to store client info as well as files uploaded by the client.  When running the php I get the following mysql error:

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(null,'image/pjpeg','ÿØÿà\0JFIF\0\0È\0È\0\0ÿá!HExif\0\0MM\0*\0\0\0\0' at line 1

here is my code
[code]

<?php

$host = "";
$user = "";
$pass = "";
$db = "";

$cn = mysql_connect($host, $user, $pass) OR die ("Could not connect to the server.");
mysql_select_db($db) OR die("Could not connect to the database.");

$pureFile = addslashes(fread(fopen($file,"r"), filesize($file)));
$business = stripslashes($_POST['business']);
$address = stripslashes($_POST['address']);
$city = stripslashes($_POST['city']);
$contact = stripslashes($_POST['contact']);
$email = stripslashes($_POST['email']);
$salesrep = stripslashes($_POST['salesrep']);
$phone = stripslashes($_POST['phone']);

$sql  = "insert into upload SET id='$id' , values(null,'$file_type','$pureFile'),  business='$business', address='$address', city='$city', contact='$contact', salesrep='$salesrep', phone='$phone', email='$email'";
$rc = mysql_query($sql,$cn)or die(mysql_error());

$sql = "select * from upload";
$rc = mysql_query($sql,$cn);


$rw = mysql_fetch_object($rc);

header("Content-type: $rw->type");
print($rw->filename);




?>

[/code]
Link to comment
Share on other sites

I'm no expert but your sql looks like it could be wrong.

$sql  = "insert into upload SET id='$id' , values(null,'$file_type','$pureFile'),  business='$business', address='$address', city='$city', contact='$contact', salesrep='$salesrep', phone='$phone', email='$email'";

I would suspect it should look like this...

sql = "INSERT INTO upload (id, business, address, city, contact, salesrep, phone, email) VALUES ('$id', '$business', $address', '$city', '$contact', '$salesrep', '$phone', '$email)";

Your SQL looks more like an UPDATE SQL Modified......

-John
Link to comment
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.