padiwak Posted December 30, 2009 Share Posted December 30, 2009 I am trying to create a directory of Sellers on My Site and have created the MYSql DB and table which are working fine Using this script <? $username="........_admin"; $password=".........."; $database=".........._sellers"; $first=$_POST['first']; $last=$_POST['last']; $business=$_POST['business']; $address=$_POST['address']; $county=$_POST['county]; $telephone=$_POST['telephone']; $mobile=$_POST['mobile']; $email=$_POST['email']; $web=$_POST['web']; $about=$POST['about']; $image1=$POST[image1']; mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query = "INSERT INTO sellers VALUES ('','$first','$last','$business','$address','$county','$telephone','$mobile','$email','$web')"; mysql_query($query); mysql_close(); Have for on this page http://www.irishhorsemarkets.com/addseller.php and script on this page http://www.irishhorsemarkets.com/addbusiness.php and getting this error code Parse error: syntax error, unexpected T_STRING, expecting ']' in /home/ucuyyijx/public_html/irishhorsemarkets.com/addbusiness.php on line 11 Help Appreciated Quote Link to comment https://forums.phpfreaks.com/topic/186675-new-to-this-and-already-in-trouble/ Share on other sites More sharing options...
rajivgonsalves Posted December 30, 2009 Share Posted December 30, 2009 you missed out a quote, this $county=$_POST['county]; should be $county=$_POST['county']; Quote Link to comment https://forums.phpfreaks.com/topic/186675-new-to-this-and-already-in-trouble/#findComment-985865 Share on other sites More sharing options...
padiwak Posted December 30, 2009 Author Share Posted December 30, 2009 Thank you. Changed that and now have new error as follows Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ']' in /home/ucuyyijx/public_html/irishhorsemarkets.com/addbusiness.php on line 21 Quote Link to comment https://forums.phpfreaks.com/topic/186675-new-to-this-and-already-in-trouble/#findComment-985875 Share on other sites More sharing options...
sasa Posted December 30, 2009 Share Posted December 30, 2009 error is in line $image1=$POST[image1']; Quote Link to comment https://forums.phpfreaks.com/topic/186675-new-to-this-and-already-in-trouble/#findComment-985879 Share on other sites More sharing options...
padiwak Posted December 30, 2009 Author Share Posted December 30, 2009 Thank you. I have ammended the script as follows $first=$_POST['first']; $last=$_POST['last']; $business=$_POST['business']; $address=$_POST['address']; $county=$_POST['county']; $telephone=$_POST['telephone']; $mobile=$_POST['mobile']; $email=$_POST['email']; $web=$_POST['web']; $about=$POST['about']; $image1=$POST['image1']; mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query = "INSERT INTO sellers VALUES ('','$first','$last','$business','$address','$county','$telephone','$mobile','$email','$web')"; mysql_query($query); mysql_close(); So have corrected the errors but now have error Parse error: syntax error, unexpected '<' in /home/ucuyyijx/public_html/irishhorsemarkets.com/addbusiness.php on line 26 Quote Link to comment https://forums.phpfreaks.com/topic/186675-new-to-this-and-already-in-trouble/#findComment-985882 Share on other sites More sharing options...
Adam Posted December 30, 2009 Share Posted December 30, 2009 What's line 26 in addbusiness.php? Quote Link to comment https://forums.phpfreaks.com/topic/186675-new-to-this-and-already-in-trouble/#findComment-985884 Share on other sites More sharing options...
padiwak Posted December 30, 2009 Author Share Posted December 30, 2009 That was a daft post sorry. I did'nt close the PHP with ?> which I have now done. The form, when filled in is now navigating to the page which has the script however the form data is not writing to the MYSql database. Should this script work assuming I have named the DB table correctly? Quote Link to comment https://forums.phpfreaks.com/topic/186675-new-to-this-and-already-in-trouble/#findComment-985887 Share on other sites More sharing options...
Adam Posted December 30, 2009 Share Posted December 30, 2009 Try replacing the query with this and see if there's an error reported: $query = "INSERT INTO sellers VALUES ('','$first','$last','$business','$address','$county','$telephone','$mobile','$email','$web')"; mysql_query($query) or trigger_error('MySQL error: '.mysql_error(), E_USER_ERROR); Quote Link to comment https://forums.phpfreaks.com/topic/186675-new-to-this-and-already-in-trouble/#findComment-985889 Share on other sites More sharing options...
padiwak Posted December 30, 2009 Author Share Posted December 30, 2009 Yes got this error Fatal error: MySQL error: Column count doesn't match value count at row 1 in /home/ucuyyijx/public_html/irishhorsemarkets.com/addbusiness.php on line 21 Quote Link to comment https://forums.phpfreaks.com/topic/186675-new-to-this-and-already-in-trouble/#findComment-985891 Share on other sites More sharing options...
padiwak Posted December 30, 2009 Author Share Posted December 30, 2009 OK so I added the fields on the form into the query and now I am getting some of the data writing to MySQL, However the Info from fields First, Last & About are not been written to database? Why would this be.. Quote Link to comment https://forums.phpfreaks.com/topic/186675-new-to-this-and-already-in-trouble/#findComment-985895 Share on other sites More sharing options...
Adam Posted December 30, 2009 Share Posted December 30, 2009 Yes got this error Fatal error: MySQL error: Column count doesn't match value count at row 1 in /home/ucuyyijx/public_html/irishhorsemarkets.com/addbusiness.php on line 21 Means you're trying to insert more field (column) values than there actually are. OK so I added the fields on the form into the query and now I am getting some of the data writing to MySQL, However the Info from fields First, Last & About are not been written to database? Why would this be.. Probably related to the first part. Quote Link to comment https://forums.phpfreaks.com/topic/186675-new-to-this-and-already-in-trouble/#findComment-985896 Share on other sites More sharing options...
padiwak Posted December 30, 2009 Author Share Posted December 30, 2009 When I added the additional fields $about & $Image1 the error dissapeared but the detail for $first, $last, $business, and $about are not writing to the database. The query now looks like this $query = "INSERT INTO addsellers VALUES ('','$first','$last','$business','$address','$county','$telephone','$mobile','$email','$web','$about','image1')";mysql_query($query) or trigger_error('MySQL error: '.mysql_error(), E_USER_ERROR); Where have I gone wrong, any help appreciated Quote Link to comment https://forums.phpfreaks.com/topic/186675-new-to-this-and-already-in-trouble/#findComment-985898 Share on other sites More sharing options...
Adam Posted December 30, 2009 Share Posted December 30, 2009 Can you post the structure of your table? mysql> describe addsellers My guess is you're trying to enter one or more fields in the wrong order. Carefully check each input, make sure it's a valid value (i.e. var_dump it before the query), and also trying printing out the SQL string rather than executing it once, to make sure it looks correct. Generally by debugging a query like that the problem will become clear. Quote Link to comment https://forums.phpfreaks.com/topic/186675-new-to-this-and-already-in-trouble/#findComment-985902 Share on other sites More sharing options...
sasa Posted December 30, 2009 Share Posted December 30, 2009 change to $query = "INSERT INTO addsellers VALUES ('','$first','$last','$business','$address','$county','$telephone','$mobile','$email','$web','$about','image1')";mysql_query($query) or trigger_error('Error in: '.$query. ' - '.mysql_error(), E_USER_ERROR); and see query Quote Link to comment https://forums.phpfreaks.com/topic/186675-new-to-this-and-already-in-trouble/#findComment-985904 Share on other sites More sharing options...
padiwak Posted December 30, 2009 Author Share Posted December 30, 2009 Thank you all for your help. Have made major progress. No more errors. However the about data from form is still not coming to Mysql Script now lokks like this $name=$_POST['name']; $address=$_POST['address']; $county=$_POST['county']; $telephone=$_POST['telephone']; $mobile=$_POST['mobile']; $email=$_POST['email']; $web=$_POST['web']; $about=$_POST['about']; $image1=$_POST['image1']; mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query = "INSERT INTO addsellers VALUES ('','$name','$address','$county','$telephone','$mobile','$email','$web','$about','$image1')";mysql_query($query) or trigger_error('MySQL error: '.mysql_error(), E_USER_ERROR); mysql_close(); ?> The About data is input in a Text Box Field in the form and I have set it up as Varchar in the database Quote Link to comment https://forums.phpfreaks.com/topic/186675-new-to-this-and-already-in-trouble/#findComment-985911 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.