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);");
Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
MylesMor
  • 35
  • 5
  • 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? – chris85 Mar 23 '18 at 00:46
  • From your reply, I may not entirely sure how query works, is it designed to be executed multiple times? – MylesMor Mar 23 '18 at 00:48
  • You are using `mysqli`? http://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 – chris85 Mar 23 '18 at 00:49
  • Thank you Chris, multi_query is what I needed, really appreciate the help. – MylesMor Mar 23 '18 at 00:53

0 Answers0