Thomisback Posted January 5, 2008 Share Posted January 5, 2008 Hi, I'm new here, and beginner at PHP. I'm trying to return/echo (What's the difference between return and echo?) a specific field from my mysql database and then spit it out using a variable. I have coded: <?php $row = "therow"; echo $row['FIELD'] = $FIELD; echo "&FIELD=$FIELD"; ?> I have coded something wrong and I can't find the error, could anyone help me? Thanks you for your help! Quote Link to comment https://forums.phpfreaks.com/topic/84619-simple-php-echoreturn-question/ Share on other sites More sharing options...
gerkintrigg Posted January 5, 2008 Share Posted January 5, 2008 you kinda have a few things wrong here. First, you're defining the $row variable as "therow", then you're re-defining it in an echo statement to equal whatever the $FIELD variable contains (which appears to be nothing), then you're trying to echo some text with the field variable in it. You probably need to do something like <?php echo 'Hello World!'; ?> then work up: <?php $field='Hello World!'; echo $field; ?> then perhaps take the array from your database and then do something like: <?php $field=$r['field'];// you need to get the array to put a value in here, though... $output_variable='&field='.$field; // by the way, you can use the dot (.) to add variables and text stuff together echo $output_variable; ?> Hope this helps. Quote Link to comment https://forums.phpfreaks.com/topic/84619-simple-php-echoreturn-question/#findComment-431175 Share on other sites More sharing options...
Thomisback Posted January 5, 2008 Author Share Posted January 5, 2008 Hi, Thanks for your reply! I'm starting to learn about arrays now http://uk3.php.net/array Thank you very much! Quote Link to comment https://forums.phpfreaks.com/topic/84619-simple-php-echoreturn-question/#findComment-431191 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.