1

This is my SQL statement:

UPDATE approved_student SET barcode='11',phone='11',table_name='2',remark='' WHERE
studentid='5230010'; UPDATE approved_student SET 
barcode='22',phone='22',table_name='2',remark='' WHERE studentid='5230009';  

Executing the SQL using PHP is not resulting in the desired outcome.

PHP source:

mysql_connect("localhost","root","1234"); //connect database
mysql_select_db("lasto");//select name of the database

if($sql=mysql_query($data1)){
    echo 1;
}else{
    echo $data1;
}

mysql_close();

I sent the SQL using POST, but it does not work.

2

1 Answer 1

6

You can only execute one commands at the time with mysql_query(), you should look at using mysqli or PDO instead.

mysql_query("UPDATE approved_student SET barcode='11',phone='11',table_name='2',remark='' WHERE
studentid='5230010'"); 

...

mysql_query("UPDATE approved_student SET 
barcode='22',phone='22',table_name='2',remark='' WHERE studentid='5230009'");  
Sign up to request clarification or add additional context in comments.

2 Comments

you mean that mysqli or PDO can execute at the same time right ?
@JongzPuangput Yeah that shouldn't be a problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.