bryanptcs Posted December 13, 2006 Share Posted December 13, 2006 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 1here 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 https://forums.phpfreaks.com/topic/30563-my-sql-syntax-error-for-values/ Share on other sites More sharing options...
jsladek Posted December 14, 2006 Share Posted December 14, 2006 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 https://forums.phpfreaks.com/topic/30563-my-sql-syntax-error-for-values/#findComment-140758 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.