Jump to content

[SOLVED] Insert PHP Variables Inside Echo "*"


egturnkey

Recommended Posts

Hello Friends,

 

How can i do the following if i have

 

$productrow['name'][code]

how to add it to

[code]echo "$productrow['name']";[code]
it will give indeed error
syntax error, unexpected T_VARIABLE

cause echo accept only $productrow

so is there any way i do so that it working


Database connection is 
[code]
// the following display the selected product details
$productSQL = "SELECT * FROM product WHERE catID='".$_GET['catID']."' AND productID=".$_GET['productID'];
$productresult = mysql_query($productSQL);
$productrow = mysql_fetch_array($productresult);

Link to comment
https://forums.phpfreaks.com/topic/172688-solved-insert-php-variables-inside-echo/
Share on other sites

You need to put braces {} around array variables when they are inside of strings to help the php parser figure out where the variable starts and stops and to allow you to use the exact same syntax for an array variable inside of a string that you would use outside of a 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.