I have a PHP project that connects to a SQL database. The problem is that I cannot access the value of the text in the following code:
$sher = $db->query("SELECT * FROM sher1 ORDER BY RAND() LIMIT 1"); $matn = $sher[0][text];
What went wrong? How can I fix it?
Access table values in array
P粉5761849332023-09-17 10:23:59
Suppose there is a result (result greater than 0) and there is a "text" column. You are missing double quotes because "text" without double quotes will be recognized as a constant. Here’s how to fix it
$sher = $db->query("SELECT * FROM sher1 ORDER BY RAND() LIMIT 1"); $matn = $sher[0]["text"];