philip315 Posted April 21, 2011 Share Posted April 21, 2011 I finished making an entire php and it will not go to my SQL document. The problem is on line 1. Line 1 would be <?php . Anyway I will include the php here. Do you know what the problem is? <?php //This gets all the other information from the form $Fname=$_POST['Fname']; $Lname=$_POST['Lname']; $Compname=$_POST['Compname']; $emailad=$_POST['emailad']; $urlname=$_POST['urlname']; $address=$_POST['address']; $address2=$_POST['address2']; $address3=$_POST['address3']; $phone=$_POST['phone']; $phone2=$_POST['phone2']; $phonename=$_POST['phonename']; $listingtype=$_POST['listingtype']; $formcheck1=$_POST['formcheck']['name']; $formcheck2=$_POST['formcheck']['name']; $formcheck3=$_POST['formcheck']['name']; $pic=($_FILES['photo']['name']); $pic2=($_FILES['photo']['name']); $pic3=($_FILES['photo']['name']); $pic4=($_FILES['photo']['name']); $description=$_POST['atDescription']; // Connects to your Database mysql_connect ("", "", "") or die(mysql_error()) ; mysql_select_db("") or die(mysql_error()) ; //Writes the photos to the server and store the names in $picname[] foreach ($_FILES["photo"]["error"] as $key => $error) { if ($error == UPLOAD_ERR_OK) { $tmp_name = $_FILES["photo"]["tmp_name"][$key]; $name = $_FILES["photo"]["name"][$key]; move_uploaded_file($tmp_name, "upload/$name"); $picname[] = $name; } else { //Gives and error if its not echo "bldf"; } } // setup empty names so that the variable will exist $pic = ""; $pic2 = ""; $pic3 = ""; $pic3 = ""; // overwrite the empty pic names if they exist if (count($picname) > 0) { //at least 1 pic $pic = $picname[0]; } if (count($picname) > 1) { //at least 2 pics $pic2 = $picname[1]; } if (count($picname) > 2) { //at least 3 pics $pic3 = $picname[2]; } if (count($picname) > 3) { //at least 4 pics $pic4 = $picname[3]; } // don't care if there's more than 4 //Writes the information to the database $sql = ("INSERT INTO bestform (Fname,Lname,Compname,emailad,urlname,address,address2,address3,phone,phone2,phonename,listingtype,formcheck_1,formcheck_2,formcheck_3,photo_1,photo_2,photo_3,photo_4,atDescription,) VALUES ('$Fname', '$Lname', '$Compname', '$emailad', '$urlname', '$address', '$address2', '$address3', '$phone', '$phone2', '$phonename', '$listingtype', '$formcheck1', '$formcheck2', '$formcheck3', '$pic', '$pic2', '$pic3', '$pic4', '$description')") ; //Writes the information to the database mysql_query($sql) or die(mysql_error()); // and catch any error echo date("m/d/y : H:i:s", time()) ?> Link to comment https://forums.phpfreaks.com/topic/234309-bad-syntax-on-line-1-please-sos-need-assist/ Share on other sites More sharing options...
dan_t Posted April 21, 2011 Share Posted April 21, 2011 atDescription,) Try removing the comma at the end of "atDescription" It might help. Not sure though. Link to comment https://forums.phpfreaks.com/topic/234309-bad-syntax-on-line-1-please-sos-need-assist/#findComment-1204320 Share on other sites More sharing options...
Pikachu2000 Posted April 21, 2011 Share Posted April 21, 2011 If it's a MySQL error, line 1 would be line 1 of the query string, not line 1 of the script. Link to comment https://forums.phpfreaks.com/topic/234309-bad-syntax-on-line-1-please-sos-need-assist/#findComment-1204324 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.