Lamez Posted December 16, 2008 Share Posted December 16, 2008 The script below is suppose to find the user's pick, as in a football team, then take that info and pull the who the team is playing. so like, say the user chose, Texas Tech, then it finds who they are playing, so it would be Ole Miss. Well, it is not finding who the other team is. It does find who the user picked. Here is the script: <?php ob_start(); $path = "../../"; $title = "Choose your Teams!"; $rank = "yes"; $u_login = "yes"; $ban = "yes"; include ($path."main/include/cons/head.php"); if(siteStat() !== "Football"){ header ("Location: ../index.php"); } $ck = mysql_query("SELECT `user` FROM `foot_picks` WHERE `user` = '".$user_."' LIMIT 1"); $ck = mysql_num_rows($ck); if($ck == 0){ header("Location: ../index.php"); } $v = mysql_query("SELECT * FROM `foot_picks` WHERE `user` = '".$user_."'")or die(mysql_error()); while($n = mysql_fetch_array($v)){ $nt = $n['team']; $a = mysql_query("SELECT * FROM `foot_bowls` WHERE `team_a` OR `team_b` = '".$nt."'")or die(mysql_error()); $b = mysql_fetch_array($a); $team_a = $b['team_a']; $team_b = $b['team_b']; echo $team_a." VS ".$team_b."<br>"; } include ($path."main/include/cons/foot.php"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/137149-solved-mysql-not-pulling-data/ Share on other sites More sharing options...
darkfreaks Posted December 16, 2008 Share Posted December 16, 2008 have you tried changing the singles to backticks ??? Quote Link to comment https://forums.phpfreaks.com/topic/137149-solved-mysql-not-pulling-data/#findComment-716450 Share on other sites More sharing options...
genericnumber1 Posted December 16, 2008 Share Posted December 16, 2008 Just a quick run over of your code: SELECT * FROM `foot_bowls` WHERE `team_a` OR `team_b` = '".$nt."' should be SELECT * FROM `foot_bowls` WHERE `team_a` = '".$nt".' OR `team_b` = '".$nt."' <?php if($ck == 0){ header("Location: ../index.php"); } ?> should be <?php if($ck == 0){ header("Location: ../index.php"); die(); } ?> and add "or die(mysql_error());" to the first query as you did in your other queries for debugging purposes. Quote Link to comment https://forums.phpfreaks.com/topic/137149-solved-mysql-not-pulling-data/#findComment-716518 Share on other sites More sharing options...
trq Posted December 16, 2008 Share Posted December 16, 2008 And why are you running this query.... $a = mysql_query("SELECT * FROM `foot_bowls` WHERE `team_a` OR `team_b` = '".$nt."'")or die(mysql_error()); within a loop? Use mysql to get all the records in one go. Quote Link to comment https://forums.phpfreaks.com/topic/137149-solved-mysql-not-pulling-data/#findComment-716522 Share on other sites More sharing options...
waynew Posted December 16, 2008 Share Posted December 16, 2008 Just a quick run over of your code: SELECT * FROM `foot_bowls` WHERE `team_a` OR `team_b` = '".$nt."' should be SELECT * FROM `foot_bowls` WHERE `team_a` = '".$nt".' OR `team_b` = '".$nt."' <?php if($ck == 0){ header("Location: ../index.php"); } ?> should be <?php if($ck == 0){ header("Location: ../index.php"); die(); } ?> and add "or die(mysql_error());" to the first query as you did in your other queries for debugging purposes. It's bad practise to place die() and kill execution. Use "or trigger_error(mysql_error())" Lamez: In my opinion: $ck = mysql_query("SELECT `user` FROM `foot_picks` WHERE `user` = '".$user_."' LIMIT 1"); $ck = mysql_num_rows($ck); if($ck == 0){ header("Location: ../index.php"); } Should be $ck = mysql_query("SELECT COUNT(*) FROM foot_picks WHERE user = '".$user_."'") or trigger_error(mysql_error()); $row = mysql_fetch_row($ck); if($row[0] == 0){ //redirect } Quote Link to comment https://forums.phpfreaks.com/topic/137149-solved-mysql-not-pulling-data/#findComment-716523 Share on other sites More sharing options...
genericnumber1 Posted December 16, 2008 Share Posted December 16, 2008 wayne: as I said, the die() is for debugging purposes, I didn't mean he should let it go live like that Quote Link to comment https://forums.phpfreaks.com/topic/137149-solved-mysql-not-pulling-data/#findComment-716528 Share on other sites More sharing options...
Lamez Posted December 16, 2008 Author Share Posted December 16, 2008 wow, that fixed it Quote Link to comment https://forums.phpfreaks.com/topic/137149-solved-mysql-not-pulling-data/#findComment-716778 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.