Hartley Posted July 11, 2007 Share Posted July 11, 2007 This is a segment of a larger script (the actual query involves a total of 43 columns, but I didn't post the whole thing for the sake of space. There is no error in the query, it just doesn't seem to pull. <?php $dbhosta = 'xxx'; $dbusera = 'xxx'; $dbpassa = 'xxx'; $dbnamea = 'xxx'; $conna = mysql_connect($dbhosta, $dbusera, $dbpassa) or die ('Error connecting to mysql'); mysql_select_db($dbnamea); $attune = "SELECT cot_intro, arc_key_quest FROM attunement WHERE userid = " .$_COOKIE['bbuserid']; $attquery = mysql_query($attune); while($att = mysql_fetch_assoc($attquery)) { $cot_intro = $att['cot_intro']; $arc_key_quest = $att['arc_key_quest']; } if ($cot_intro == "1") { $cot_intro_1 = "on"; $cot_intro_2 = "off"; } else { $cot_intro_1 = "off"; $cot_intro_2 = "on"; } if ($arc_key_quest == "1") { $arc_key_quest_1 = "on"; $arc_key_quest_2 = "off"; } else { $arc_key_quest_1 = "off"; $arc_key_quest_2 = "on"; } ?> It's not a cookie problem, because even when I give a specific row to pull, it doesn't work. Thanks in advance. Link to comment https://forums.phpfreaks.com/topic/59362-solved-query-problem/ Share on other sites More sharing options...
teng84 Posted July 11, 2007 Share Posted July 11, 2007 print_r(mysql_fetch_assoc($attquery)); try that first and see if theres a result Link to comment https://forums.phpfreaks.com/topic/59362-solved-query-problem/#findComment-294876 Share on other sites More sharing options...
Hartley Posted July 11, 2007 Author Share Posted July 11, 2007 Didn't bring anything up. Link to comment https://forums.phpfreaks.com/topic/59362-solved-query-problem/#findComment-294882 Share on other sites More sharing options...
Hartley Posted July 11, 2007 Author Share Posted July 11, 2007 Worth mentioning as well: this table had a similar problem with nothing working on it in a setup problem I've had. Is there any sort of glitch that may occur from the name? The table attunement seems to not work at all, and the syntax looked fine. Link to comment https://forums.phpfreaks.com/topic/59362-solved-query-problem/#findComment-294887 Share on other sites More sharing options...
teng84 Posted July 11, 2007 Share Posted July 11, 2007 try doing this "SELECT cot_intro, arc_key_quest FROM attunement WHERE userid = " .$_COOKIE['bbuserid']."" if print r still dont have value then chek your query maybe the _COOKIE['bbuserid'] is empty Link to comment https://forums.phpfreaks.com/topic/59362-solved-query-problem/#findComment-294889 Share on other sites More sharing options...
AndyB Posted July 11, 2007 Share Posted July 11, 2007 After defining the query string, echo it before executing the query. Then you'll know for sure just what's in it. Link to comment https://forums.phpfreaks.com/topic/59362-solved-query-problem/#findComment-294893 Share on other sites More sharing options...
Hartley Posted July 11, 2007 Author Share Posted July 11, 2007 I forgot to include the mysql_error()! When I did it, I got more details: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ssl, cot_mh FROM attunement WHERE userid = 1' at line 1 It was a part I cut out of the code snippet I posted. When I took out the ssl and cot_mh, it worked! However, I can't figure out why it did. Link to comment https://forums.phpfreaks.com/topic/59362-solved-query-problem/#findComment-294900 Share on other sites More sharing options...
AndyB Posted July 11, 2007 Share Posted July 11, 2007 Because ssl is a reserved word in MySQL - http://dev.mysql.com/doc/refman/4.1/en/reserved-words.html Link to comment https://forums.phpfreaks.com/topic/59362-solved-query-problem/#findComment-294931 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.