Saturday 9 June 2018

php - multiple commands on mysqli query doesn't work?

if I write a query like this :



$conn = new mysqli($db_host, $db_username, $db_password, $db_database);
$conn -> query ("
DROP TABLE IF EXISTS for_search;
CREATE TABLE IF NOT EXISTS for_search
(
id INT,
for_search TEXT
);

");
$conn -> close();


it doesn't work but if i rewrite that like this:



$conn = new mysqli($db_host, $db_username, $db_password, $db_database);
$conn -> query ("
DROP TABLE IF EXISTS for_search;
");

$conn -> query ("
CREATE TABLE IF NOT EXISTS for_search
(
id INT,
for_search TEXT
);
");
$conn -> close();



it will work!
i want to know why i can't write multiple line queries in mysqli?

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...