0

I've been trying for an hour to get this to work and am at a loss at this point. This statement here is the issue. If I remove the INSERT INTO statement this works and the table is created, however when I add it back nothing happens. I've checked this is a valid SQL statement by performing directly on the DB and it works fine. Thanks for your help.

$conn->query("CREATE TABLE stock (Title varchar(255), Stock int(11)); INSERT 
INTO stock VALUES('Chair', 45);");
4
  • 2
    I think query can only execute 1 query (CREATE TABLE is 1 query, INSERT INTO is a second query). Also why create the table multiple times? Commented Mar 23, 2018 at 0:46
  • From your reply, I may not entirely sure how query works, is it designed to be executed multiple times? Commented Mar 23, 2018 at 0:48
  • You are using mysqli? php.net/manual/en/mysqli.multi-query.php I'd also recommend using error reporting and see what happens when you actually execute this. Errors will help you debug Commented Mar 23, 2018 at 0:49
  • Thank you Chris, multi_query is what I needed, really appreciate the help. Commented Mar 23, 2018 at 0:53

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.