Jump to content

Can Some One Spot The Error ?


hopbop

Recommended Posts

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);
?>

Link to comment
https://forums.phpfreaks.com/topic/269043-can-some-one-spot-the-error/
Share on other sites

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?

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 ......

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

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.