franknu Posted January 16, 2007 Share Posted January 16, 2007 i have this code to upload multiple files the error that i am getting is [code=php:0]Parse error: syntax error, unexpected '=' in /home/townsfin/public_html/html_forms/insert_data.php on line 105[/code]probably i have other errors but i need to go through this one first [code=php:0]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head> <title>Hello!</title></head><body><?$host = "localhost";$username = "townsfin_localho";$password = "abc123";$database = "townsfin_contacts";$db = mysql_connect($host, $username, $password);mysql_select_db($database); // Business Owner $First_Name = addslashes($_POST['First_Name']); $Last_Name= addslashes($_POST['Last_Name']); $Owner_Address = addslashes($_POST['Owner_Address']); $State= addslashes($_POST['State']); $City= addslashes($_POST['City']); $Zip= addslashes($_POST['Zip']); $Tel= addslashes($_POST['Tel']); $Email= addslashes($_POST['Email']); $Position=addslashes($_POST['Position']); $Comments=addslashes($_POST['Comments']);// Business Info $BusinessName = addslashes ($_POST['BusinessName']); $Slogan = addslashes($_POST['Slogan']); $Business_Address = addslashes($_POST['Business_Address']); $Tel = addslashes($_POST['Tel']); $Website = addslashes($_POST['Website']); $Email = addslashes($_POST['Email']); $Member_Status = addslashes($_POST['Member_Status']); $Fax =addslashes($_POST['Fax']); $type = addslashes($_POST['type']); $make = addslashes($_POST['make']);// webpage info $Categories = addslashes($_POST['Categories']); $Keyword = addslashes ($_POST['Keyword']); $Picture1 = addslashes (isset ($_POST['Picture1'])); $Headline = addslashes ($_POST['Headline']); $Slogan2 = addslashes ($_POST['Slogan2']); $Description1 = addslashes ($_POST['Description1']); $Description2 = addslashes ($_POST['Description2']); $Description3= addslashes ($_POST['Description3']); $Contact2 = addslashes ($_POST['Contact2']); $Picture2 = addslashes (isset($_POST['Picture2'])); $Picture3 = addslashes (isset($_POST['Picture3'])); $User_Name = addslashes ($_POST['User_Name']); $Password = addslashes ($_POST['Password']);if(!$db){echo " Error: could not connect to database.";exit; } //business owner$sql="INSERT INTO `business_owner`(`First_Name`,`Last_Name`,`Owner_Address`,`State`,`City`, `Zip`,`Tel`, `Email`,`Comments`,`Position`)VALUES ('".$First_Name."','".$Last_Name."','".$Owner_Address."','".$State."','".$City."','".$Zip."','".$Tel."','".$Email."','".$Comments."','".$Position."')";$result = mysql_query($sql);echo mysql_error();if($result) {echo mysql_affected_rows()." .Business Owner information Inserted. <br>"; } //Business Info$uploaddir = '/home/townsfin/public_html/business_images/';$uploadfile1 = $_FILES['Picture1']['name'];if(isset ($_FILES['picture1'])){ If(is_uploaded_file($_FILES['Picture1']['tmp_name'])&& is_uploaded_file($_FILES['Picture2']['tmp_name'])); $fullpath = $uploaddir . $uploadfile1; filename1=$_POST['name']. "1"; 103 $result= move_uploaded_file($_FILES['picture1']['tmp_name'], $fullpath."/". "$filename1"); 104 105. if($result==1) 106 $sql="INSERT INTO `business_info`(`BusinessName`,`Slogan`,`Business_Address`,`Tel`,`Website`,`Email`, `Fax`,`type`,`make`,`Categories`,`Keyword`,`Picture1`,`Headline`,`Slogan2`,`Description1`,`Description2`,`Description3`, `Picture2`,`Picture3`,`User_Name`,`Password`)Values('$BusinessName','$Slogan','$Business_Address','$Tel','$Website','$Email','$Fax','$type','$make','$Categories','$Keyword','$fullpath','$Headline','$Slogan2','$Description1','$Description2','$Description3','$fullpath','$fullpath','$User_Name','$Password')";$result = mysql_query($sql);echo "file uploaded";$uploadfile2= $_FILES['Picture2']['name'];$fullpath2=$uploaddir . $uploadfile2 filename2= $_POST['name']. "2"; $result = move_uploaded_file($_FILES['picture2]['tmp_name'], $fullpath. "/" "$filename2"); if ($result==1) $sql="INSERT INTO `business_info`(`BusinessName`,`Slogan`,`Business_Address`,`Tel`,`Website`,`Email`, `Fax`,`type`,`make`,`Categories`,`Keyword`,`Picture1`,`Headline`,`Slogan2`,`Description1`,`Description2`,`Description3`, `Picture2`,`Picture3`,`User_Name`,`Password`)Values('$BusinessName','$Slogan','$Business_Address','$Tel','$Website','$Email','$Fax','$type','$make','$Categories','$Keyword','$fullpath1','$Headline','$Slogan2','$Description1','$Description2','$Description3','$fullpath2','$fullpath1','$User_Name','$Password')";$result = mysql_query($sql); } }}?></body></html>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/34431-uploading-multiple-files-in-the-database/ Share on other sites More sharing options...
franknu Posted January 16, 2007 Author Share Posted January 16, 2007 this is what i have on line 105 103. $result= move_uploaded_file($_FILES['picture1']['tmp_name'], $fullpath."/". "$filename1"); 104. 105. if($result==1) 106. Quote Link to comment https://forums.phpfreaks.com/topic/34431-uploading-multiple-files-in-the-database/#findComment-162097 Share on other sites More sharing options...
HuggieBear Posted January 16, 2007 Share Posted January 16, 2007 It's the line above that...Try changing this:[code]filename1=$_POST['name']. "1";[/code]To this:[code]$filename1=$_POST['name']. "1";[/code]Also further down you're missing a semi-colon on the end of this line:[code]$fullpath2=$uploaddir . $uploadfile2[/code]and a $ sign at the beginning of this line:[code]filename2= $_POST['name']. "2";[/code]RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/34431-uploading-multiple-files-in-the-database/#findComment-162100 Share on other sites More sharing options...
franknu Posted January 16, 2007 Author Share Posted January 16, 2007 this is the error that i am getting now, and i am gettin it on the next lineParse error: syntax error, unexpected T_STRING, expecting ']' in /home/townsfin/public_html/html_forms/insert_data.php on line 126[code=php:0]$uploaddir = '/home/townsfin/public_html/business_images/';$uploadfile1 = $_FILES['Picture1']['name'];if(isset ($_FILES['Picture1'])){ If(is_uploaded_file($_FILES['Picture1']['tmp_name'])&& is_uploaded_file($_FILES['Picture2']['tmp_name'])); $fullpath = $uploaddir . $uploadfile1; $filename1=$_POST['name']. "1"; $result= move_uploaded_file($_FILES['picture1']['tmp_name'], $fullpath."/". "$filename1"); if($result==1) $sql="INSERT INTO `business_info`(`BusinessName`,`Slogan`,`Business_Address`,`Tel`,`Website`,`Email`, `Fax`,`type`,`make`,`Categories`,`Keyword`,`Picture1`,`Headline`,`Slogan2`,`Description1`,`Description2`,`Description3`, `Picture2`,`Picture3`,`User_Name`,`Password`)Values('$BusinessName','$Slogan','$Business_Address','$Tel','$Website','$Email','$Fax','$type','$make','$Categories','$Keyword','$fullpath','$Headline','$Slogan2','$Description1','$Description2','$Description3','$fullpath','$fullpath','$User_Name','$Password')";$result = mysql_query($sql);echo "file uploaded";$uploadfile2= $_FILES['Picture2']['name'];$fullpath2=$uploaddir . $uploadfile2; $filename2= $_POST['name']. "2"; $result = move_uploaded_file($_FILES['picture2]['tmp_name'], $fullpath. "/" "$filename2"); if ($result==1) $sql="INSERT INTO `business_info`(`BusinessName`,`Slogan`,`Business_Address`,`Tel`,`Website`,`Email`, `Fax`,`type`,`make`,`Categories`,`Keyword`,`Picture1`,`Headline`,`Slogan2`,`Description1`,`Description2`,`Description3`, `Picture2`,`Picture3`,`User_Name`,`Password`)Values('$BusinessName','$Slogan','$Business_Address','$Tel','$Website','$Email','$Fax','$type','$make','$Categories','$Keyword','$fullpath1','$Headline','$Slogan2','$Description1','$Description2','$Description3','$fullpath2','$fullpath1','$User_Name','$Password')";$result = mysql_query($sql); } }}[/code] Quote Link to comment https://forums.phpfreaks.com/topic/34431-uploading-multiple-files-in-the-database/#findComment-162139 Share on other sites More sharing options...
paul2463 Posted January 16, 2007 Share Posted January 16, 2007 how about an opening curly brace after the IF statement????this would prevent the origonal error because it would think that the $sql="BLAH" would be on the same line as the IF statement therefore unexpected = on line 105or am i barking up the wrong tree? Quote Link to comment https://forums.phpfreaks.com/topic/34431-uploading-multiple-files-in-the-database/#findComment-162151 Share on other sites More sharing options...
franknu Posted January 16, 2007 Author Share Posted January 16, 2007 ok i made more changesthe problem now is that it says that it has upload the files but when i look into the database there is nothing therehere is my code[code=php:0]$uploaddir = '/home/townsfin/public_html/business_images/';$uploadfile1 = $_FILES['Picture1']['name'];if(isset ($_FILES['Picture1'])){ If (is_uploaded_file($_FILES['Picture1']['tmp_name'])&& is_uploaded_file($_FILES['Picture2']['tmp_name'])); $fullpath = $uploaddir . $uploadfile1; $filename1=$_POST['name']. "1"; $result= move_uploaded_file($_FILES['picture1']['tmp_name'], $fullpath."/". "$filename1"); if($result==1) $sql="INSERT INTO `business_info`(`BusinessName`,`Slogan`,`Business_Address`,`Tel`,`Website`,`Email`, `Fax`,`type`,`make`,`Categories`,`Keyword`,`Picture1`,`Headline`,`Slogan2`,`Description1`,`Description2`,`Description3`, `Picture2`,`Picture3`,`User_Name`,`Password`)Values('$BusinessName','$Slogan','$Business_Address','$Tel','$Website','$Email','$Fax','$type','$make','$Categories','$Keyword','$fullpath','$Headline','$Slogan2','$Description1','$Description2','$Description3','$fullpath','$fullpath','$User_Name','$Password')";$result = mysql_query($sql);echo "picture1 front of business uploaded";$uploadfile2= $_FILES['Picture2']['name'];$fullpath2=$uploaddir . $uploadfile2; $filename2= $_POST['name']. "2"; $result = move_uploaded_file($_FILES['picture2']['tmp_name'], $fullpath. "$filename2"); if ($result==1) $sql="INSERT INTO `business_info`(`BusinessName`,`Slogan`,`Business_Address`,`Tel`,`Website`,`Email`, `Fax`,`type`,`make`,`Categories`,`Keyword`,`Picture1`,`Headline`,`Slogan2`,`Description1`,`Description2`,`Description3`, `Picture2`,`Picture3`,`User_Name`,`Password`)Values('$BusinessName','$Slogan','$Business_Address','$Tel','$Website','$Email','$Fax','$type','$make','$Categories','$Keyword','$fullpath1','$Headline','$Slogan2','$Description1','$Description2','$Description3','$fullpath2','$fullpath1','$User_Name','$Password')";$result = mysql_query($sql);echo " <br> Picture2 uploaded"; }?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/34431-uploading-multiple-files-in-the-database/#findComment-162172 Share on other sites More sharing options...
franknu Posted January 16, 2007 Author Share Posted January 16, 2007 [code=php:0]$uploaddir = '/home/townsfin/public_html/business_images/';$uploadfile1 = $_FILES['Picture1']['name'];if(isset ($_FILES['Picture1'])){ If (is_uploaded_file($_FILES['Picture1']['tmp_name'])&& is_uploaded_file($_FILES['Picture2']['tmp_name'])); $fullpath = $uploaddir . $uploadfile1; $filename1=$_POST['name']. "1"; $result= move_uploaded_file($_FILES['picture1']['tmp_name'], $fullpath."/". "$filename1"); if($result==1){ $sql="INSERT INTO `business_info`(`BusinessName`,`Slogan`,`Business_Address`,`Tel`,`Website`,`Email`, `Fax`,`type`,`make`,`Categories`,`Keyword`,`Picture1`,`Headline`,`Slogan2`,`Description1`,`Description2`,`Description3`, `Picture2`,`Picture3`,`User_Name`,`Password`)Values('$BusinessName','$Slogan','$Business_Address','$Tel','$Website','$Email','$Fax','$type','$make','$Categories','$Keyword','$fullpath','$Headline','$Slogan2','$Description1','$Description2','$Description3','$fullpath','$fullpath','$User_Name','$Password')";$result = mysql_query($sql) or die("SQL Error: $sql<br>" . mysql_error()); echo "picture1 front of business uploaded";}$uploadfile2= $_FILES['Picture2']['name'];$fullpath2=$uploaddir . $uploadfile2; $filename2= $_POST['name']. "2"; $result = move_uploaded_file($_FILES['picture2']['tmp_name'], $fullpath. "$filename2"); if ($result==1) { $sql="INSERT INTO `business_info`(`BusinessName`,`Slogan`,`Business_Address`,`Tel`,`Website`,`Email`, `Fax`,`type`,`make`,`Categories`,`Keyword`,`Picture1`,`Headline`,`Slogan2`,`Description1`,`Description2`,`Description3`, `Picture2`,`Picture3`,`User_Name`,`Password`)Values('$BusinessName','$Slogan','$Business_Address','$Tel','$Website','$Email','$Fax','$type','$make','$Categories','$Keyword','$fullpath1','$Headline','$Slogan2','$Description1','$Description2','$Description3','$fullpath2','$fullpath1','$User_Name','$Password')";$result = mysql_query($sql) or die("SQL Error: $sql<br>" . mysql_error()); echo " <br> Picture2 uploaded";} }?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/34431-uploading-multiple-files-in-the-database/#findComment-162205 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.