There is a server. It has support for .php and access to the mysql database.

I connect to the database like this:

$SQLhost='sub.domain.net'; $SQLuser='user'; $SQLpass='password'; $SQLdbase='DBase'; $mysqli = new mysqli($SQLhost, $SQLuser, $SQLpass, $SQLdbase); if ($mysqli->connect_errno) { echo 'Unable to connect to MySQL: ('.$mysqli->connect_errno.')'.$mysqli->connect_error; } $query='SELECT * FROM WORDS'; // <<<<<<<<<<<<< WORDS - a sheet of DBase $res = $mysqli->query($query); if($res!=FALSE) { $res->data_seek(0); while ($row = $res->fetch_assoc()) { echo 'id='.$row['id'].'<br>'; } } else printf('Error: %s\n', $mysqli->error); 

Connects to the database without errors. When outputting the entire database, everything is normally executed and output, but when I try to complicate the query, $res returns FALSE . A complicated query looks like this:

  $ query = 'SELECT * FROM WORDS WHERE FIELD ("12/31/2018", `AddDate`,` 1`)'; 

1 and AddDate are the WORDS table columns in which this date is. Checked directly on the site through the built-in interface - any request works, but does not want to programmatically from my page .. Writes an error:

Error: Unknown column 'AddDate' in 'where clause' \ n

Which is very surprising, because this column exists.

  • If he returned false, then the error was all the same and it would be worth printing it from php.net/manual/ru/mysqli.error.php to understand what is happening - Mike
  • usually write FIELD IN (VALUE1, VALUE2) - sterx
  • 2
    Your query contains both an apostrophe, and double quotes, and single quotes. Do you make a salad or SQL query? For the first time I see such constructions in PHP. - Rootware

0