I have slightly ammended a insert script to upload some form data according to a specific email address in the database.
// Get values from form
$name=$_POST['name'];
$lastname=$_POST['lastname'];
$email=$_POST['email'];
// Insert data into mysql
$sql="INSERT INTO $tbl_name(Username, Password)VALUES('$lastname', '$email') where Email='$name'";
$result=mysql_query($sql);
When where Email=‘$name’ is not there the script works, but when I put that back it doesnt.
As you can see, its saying to put a username and password into the database where the email address in the database matches the email address selected by the user ($name’).
Should I be using a select script to to firstly select the email address from (Email) field.
Are you positive you should not be doing the above?
With all things PHP/Mysql it is a case of divide and conquer.
Temp add this line to find out what sql is being assembled by PHP
echo $sql;
Copy the output of that to your database and make sure it is a LEGAL statement, and that you have MATCHING DATA in your database.
If you don’t then deal with those problems first.
Make sure you have a working example of a positive SQL statement, then recreate that in PHP
$sql=“INSERT INTO MyTable (Username, Password) VALUES (‘testname’, ‘testpassword’) where Email=‘test@email.com’”;
Alter MyTable to the ACTUAL TABLE NAME you are using.
Enter the test records into your database.
Paste the query into your database - do they get the result?
Paste the query into PHP, and start to carefully ONE BY ONE replace the actual values with PHP ones - keep testing with the test values you have set in your database.
mysql error : UPDATE command denied to user ‘tourcheck’@‘172.31.16.12’ for table ‘Register’ in query: UPDATE Register SET Username=‘6’, Password=‘7’ WHERE Email=‘jmberrio@checksafetyfirst.com’