guymclaren Posted September 17, 2008 Share Posted September 17, 2008 variable = queryresult('column') $aff1 = $affdetails('ref2'); What am I doing wrong here, sorry to ask such a basic question. I can find lots of info about variables but nothing that actually tells me how to do this. Link to comment https://forums.phpfreaks.com/topic/124689-solved-variables-from-database/ Share on other sites More sharing options...
kenrbnsn Posted September 17, 2008 Share Posted September 17, 2008 Please post all of the script, so we can see the context of your question. Ken Link to comment https://forums.phpfreaks.com/topic/124689-solved-variables-from-database/#findComment-644028 Share on other sites More sharing options...
F1Fan Posted September 17, 2008 Share Posted September 17, 2008 You are using parenthesis rather than brackets. Try this: $aff1 = $affdetails['ref2']; Link to comment https://forums.phpfreaks.com/topic/124689-solved-variables-from-database/#findComment-644031 Share on other sites More sharing options...
guymclaren Posted September 17, 2008 Author Share Posted September 17, 2008 $affdetails =" SELECT id, ref2, ref3, ref4 FROM affiliates WHERE aff_id = '$aff'"; mysql_query($affdetails) or die(mysql_error()); $aff1 = $affdetails['ref2']; echo $aff1; OK so what is wrong? Link to comment https://forums.phpfreaks.com/topic/124689-solved-variables-from-database/#findComment-644037 Share on other sites More sharing options...
F1Fan Posted September 17, 2008 Share Posted September 17, 2008 You're missing the fetch function: $affdetails =" SELECT id, ref2, ref3, ref4 FROM affiliates WHERE aff_id = '$aff'"; mysql_query($affdetails) or die(mysql_error()); $result = mysql_fetch_assoc($affdetails); $aff1 = $result['ref2']; echo $aff1; Link to comment https://forums.phpfreaks.com/topic/124689-solved-variables-from-database/#findComment-644040 Share on other sites More sharing options...
guymclaren Posted September 17, 2008 Author Share Posted September 17, 2008 Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /var/www/vhosts/webtech.co.za/httpdocs/order.php on line 42 Link to comment https://forums.phpfreaks.com/topic/124689-solved-variables-from-database/#findComment-644048 Share on other sites More sharing options...
F1Fan Posted September 17, 2008 Share Posted September 17, 2008 Arg, my bad. <?php $affdetails =" SELECT id, ref2, ref3, ref4 FROM affiliates WHERE aff_id = '$aff'"; $result = mysql_query($affdetails) or die(mysql_error()); $row = mysql_fetch_assoc($result); $aff1 = $row['ref2']; echo $aff1; ?> Link to comment https://forums.phpfreaks.com/topic/124689-solved-variables-from-database/#findComment-644052 Share on other sites More sharing options...
guymclaren Posted September 17, 2008 Author Share Posted September 17, 2008 Thank you sir, you are a scholar and a gentleman Link to comment https://forums.phpfreaks.com/topic/124689-solved-variables-from-database/#findComment-644074 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.