Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/186675-new-to-this-and-already-in-trouble/
Share on other sites

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

 

 

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

 

 

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?

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);

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.

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

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.

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

 

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

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.