0
$query = "INSERT INTO abc VALUES ('1', '2', '3')";
$send_to_mysql = mysqli_query($connection, $query);

OK.

$query = "CREATE TABLE abc (a varchar(255), b varchar(255), c varchar(255))";
$send_to_mysql = mysqli_query($connection, $query);

OK.

$query = "CREATE TABLE abc (a varchar(255), b varchar(255), c varchar(255))";
$query .= "INSERT INTO abc VALUES ('1', '2', '3')";
$send_to_mysql = mysqli_multi_query($connection, $query);

nop. Where's the problem?

2
  • 2
    A missing semicolon separator ? Commented Apr 1, 2014 at 11:56
  • Haha. Can't belive. Thanks! Commented Apr 1, 2014 at 11:58

2 Answers 2

2

Put a semicolon between your two queries. As you are putting your two queries into one single string, you need to separate them in order for MySQL to understand that you do have two queries :

$query = "CREATE TABLE abc (a varchar(255), b varchar(255), c varchar(255));";
$query .= "INSERT INTO abc VALUES ('1', '2', '3')";
Sign up to request clarification or add additional context in comments.

Comments

0

Put semicolon as separator between two queries like

$query = "CREATE TABLE abc (a varchar(255), b varchar(255), c varchar(255));";
mysqli_multi_query($connection, $query);
$query = "INSERT INTO abc VALUES ('1', '2', '3')";
$send_to_mysql = mysqli_multi_query($connection, $query);

Comments

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.