Jump to content

[SOLVED] PHP error, variables


Foser

Recommended Posts

<?php 
$list_query = mysql_query("SELECT * FROM item_info");

echo "<table width=\"200\" border=\"1\"><tr><th scope=\"col\">ID</th><th scope=\"col\">Name</th> <th scope=\"col\">Author</th><th scope=\"col\">Manage</th>";   
while ($item_list = mysql_fetch_assoc($list_query)){
echo '<tr><th scope=\"col\">$item_list[item_id]</th> <th scope=\"col\">$item_list[item_name]</th><th scope=\"col\">$item_list[item_author]</th><th scope=\"col\"><a href=\"manage_item.php?item=$item_list[item_id]\">Manage</a></th>';
}?>

 

When it outputs i all i see is the $item_list[item_id] and not the actual id...

 

I also tried with {$variable}... but still didnt work

Link to comment
https://forums.phpfreaks.com/topic/63710-solved-php-error-variables/
Share on other sites

Use double quotes and put curly brackets around the variables. That is needed when you are using arrays.

 

Variables will only be parsed when enclosed in double quotes.

 

Edit: You should also use single or double quotes around the array keys. Else you are using constants which is not what you intended.

 

Edit 2: Without curly brackets is called simple syntax and with is called complex syntax (see http://php.net/string)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.