hopbop Posted October 3, 2012 Share Posted October 3, 2012 (edited) ok so simpole loop i know the connetion works in the config file because it's in other files working and the mysql_select_db is working and corect but for the life of me can not get this thing to display the information! help this is driving me up the wall <?php $date1=$_GET['date1']; $date2=$_GET['date2']; $ecs=$_GET['ecs']; include '../config.php'; mysql_select_db("_learn_sym"); $result = mysql_query("SELECT * FROM clients WHERE date <= '$date1' and date >= '$date2' and ecs= '$ecs'") or die(mysql_error()); while ($row = mysql_fetch_array($result, MYSQL_NUM)) { printf("ID: %s Name: %s", $row[0], $row[1]); } mysql_free_result($result); ?> Edited October 3, 2012 by hopbop Quote Link to comment https://forums.phpfreaks.com/topic/269043-can-some-one-spot-the-error/ Share on other sites More sharing options...
Pikachu2000 Posted October 3, 2012 Share Posted October 3, 2012 How do you even know the query is returning any results? You aren't checking for an empty results set, you're just displaying it regardless of whether there's anything there or not. Have you echoed the query to make sure it contains the values you'd expect it to contain, then tried executing it in phpMyAdmin to see what happens? Quote Link to comment https://forums.phpfreaks.com/topic/269043-can-some-one-spot-the-error/#findComment-1382510 Share on other sites More sharing options...
hopbop Posted October 3, 2012 Author Share Posted October 3, 2012 How do you even know the query is returning any results? You aren't checking for an empty results set, you're just displaying it regardless of whether there's anything there or not. Have you echoed the query to make sure it contains the values you'd expect it to contain, then tried executing it in phpMyAdmin to see what happens? yes i have done that and it is returing results ...... Quote Link to comment https://forums.phpfreaks.com/topic/269043-can-some-one-spot-the-error/#findComment-1382511 Share on other sites More sharing options...
Pikachu2000 Posted October 3, 2012 Share Posted October 3, 2012 Post the code you used when you echoed the actual query string, along with the output it generated. Quote Link to comment https://forums.phpfreaks.com/topic/269043-can-some-one-spot-the-error/#findComment-1382513 Share on other sites More sharing options...
hopbop Posted October 3, 2012 Author Share Posted October 3, 2012 (edited) Post the code you used when you echoed the actual query string, along with the output it generated. <?php $date1=$_GET['date1']; $date2=$_GET['date2']; $ecs=$_GET['ecs']; include '../config.php'; mysql_select_db("_learn_sym"); $result = mysql_query("SELECT id FROM clients WHERE ecs= '$ecs'") or die(mysql_error()); $row = mysql_fetch_array($result); echo $row['id']; ?> output : 05634 Edited October 3, 2012 by hopbop Quote Link to comment https://forums.phpfreaks.com/topic/269043-can-some-one-spot-the-error/#findComment-1382515 Share on other sites More sharing options...
Pikachu2000 Posted October 3, 2012 Share Posted October 3, 2012 That doesn't echo the query string. Remove the query string from the query execution and store it in a variable. Then you can use the variable both to execute the query and to echo the query string. Quote Link to comment https://forums.phpfreaks.com/topic/269043-can-some-one-spot-the-error/#findComment-1382516 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.