Предупреждение: mysqli_query() ожидает параметр 1, чтобы быть mysqli, то в этом случае мы дали предупреждение: mysqli_fetch_assoc() ожидает параметр 1, чтобы быть mysqli_result, нуль дается в
After submitting something through my form I get the welcome part and then the mysql connection error because mysql is off, it goes away when I turn it on and then the boolean error. "Warning: mysqli_query() expects parameter 1 to be mysqli, boolean given in /storage/ssd3/691/11050691/public_html/signin.php on line 255 Warning: mysqli_query() expects parameter 1 to be mysqli, boolean given in /storage/ssd3/691/11050691/public_html/signin.php on line 255 Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, null given in /storage/ssd3/691/11050691/public_html/signin.php on line 256 I have code in php and mysql,it work on localhost but it didn't work in the web ,always the computer show me the warning of mysqli and it seems that the program can't connect to the database and this the code: the connection code: <?php $db=mysqli_connect("localhost","id11050691_kimo","025586381") or die ("Couldn't connect to Mysql"); $db=mysqli_select_db($db,"id11050691_daowat_db") or die ("Couldn't select database"); //time formate function formatDate($date){ return date('F j, Y, g:i a', strtotime($date)); } ?> the code wich I have problem with : //getting daowat post photo $getposts = mysqli_query($db,"SELECT * FROM daowat WHERE photos != '' ORDER BY RAND()"); $row = mysqli_fetch_assoc($getposts); $photos_db = $row['photos']; $photosrow = "./userdata/daowat_pics/".$photos_db;
Что я уже пробовал:
I don't understand why the $db work like booleen,and I don't know what should I do for the $db comes work like a paramter and for the program be mysqli. I don't know if the problem is in the database or the the program, and I didn't find solution for it,so please where the problem and how can I solve it?
F-ES Sitecore
$db-это логическое значение, так как вы присваиваете ему логические значения (как connect, так и select_db возвращают bool). Посмотрите в документах примеры того, как делать запросы
https://www.w3schools.com/php/func_mysqli_query.asp