Undefined constant 'text' in /home/jokebo/public_html/index.php:23
P粉422227023
P粉422227023 2023-09-16 16:33:51
0
1
715

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粉422227023
P粉422227023

reply all(1)
P粉576184933

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"];
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template