leighhobson89 Posted March 16, 2007 Share Posted March 16, 2007 Hi all, I have this bit of code here. It is supposed to call someones name out of the database when the variable is echo'd at the bottom, but instead, the variable $username2 is echoing out the whole SQL statement. Does anyone know what i'm doing wrong. I want the value of 'custFirstname' to be the word that echoes out. It is being used for a login screen/shopping cart. Here's the code... $username2 = "SELECT custFirstname from lptCustomerrecord WHERE userName = ".$_SESSION['username']; if(!$resultusername = mysql_query($username2,$connection)) echo "ERROR. SQL is '".$username2."'\n"; else { $Row6 = mysql_fetch_array($resultusername); } echo "<p>Welcome ".$Row6['custFirstname'].", you just chose the following product. To add it to your cart, click the Add to Cart button below, otherwise click No Thanks, to return to the shopping screen without adding the item to your cart.</p>"; I hope someone can help! Link to comment https://forums.phpfreaks.com/topic/43010-login-for-shopping-cart/ Share on other sites More sharing options...
flappy_warbucks Posted March 16, 2007 Share Posted March 16, 2007 You have a error in your statement! $username2 = "SELECT custFirstname from lptCustomerrecord WHERE userName = ".$_SESSION['username']; should be: $username2 = "SELECT custFirstname from lptCustomerrecord WHERE userName = \"". $_SESSION['username']. "\""; Link to comment https://forums.phpfreaks.com/topic/43010-login-for-shopping-cart/#findComment-208911 Share on other sites More sharing options...
leighhobson89 Posted March 16, 2007 Author Share Posted March 16, 2007 would you be able to give me the correct line of code? Im a complete php noob! cheers Link to comment https://forums.phpfreaks.com/topic/43010-login-for-shopping-cart/#findComment-208914 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.