Jump to content

echo no results..


techker

Recommended Posts

hey guys i keep on getting this error when i have no results..i need a full no results..

 

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/techker/public_html/Site/New/Main/Rapport.php on line 46

No results found. Please check often to see if we have more data..

 

$Etudiant=$_GET['E_ID'];

$query = "SELECT * FROM `Etudiant` WHERE `Code_P` ='$Etudiant'"; 
$numresults=mysql_query($query);
$row10 = mysql_fetch_assoc($numresults);

if ($row10 == 0)
  {
  echo "<h4>Results</h4>";
  echo "<p>Sorry, your search: returned zero results</p>";

  }

$Nom = $row10["Nom"];
$Prenom = $row10["Prenom"];

$fileSQL="SELECT `N_Etudiant`
FROM  `Expulsion` 
WHERE  `Nom` LIKE  '$Nom'
AND  `Prenom` LIKE  '$Prenom'
LIMIT 0 , 30";
$fileLIST=mysql_query($fileSQL);

if(mysql_num_rows($fileLIST) > 0){

while ($row = mysql_fetch_array($fileLIST))
{

 

 

Link to comment
https://forums.phpfreaks.com/topic/252535-echo-no-results/
Share on other sites

Your code does not check to see if the queries are valid, it simply assumes that they are.  Clearly in certain cases the queries are not valid, and you have errors.  There is a link in my signature that describes how to approach this properly.

Link to comment
https://forums.phpfreaks.com/topic/252535-echo-no-results/#findComment-1294742
Share on other sites

well what mess is me up is that i have 1 query that depends on the other..

 

the first


$Etudiant=$_GET['E_ID'];

$query = "SELECT * FROM `Etudiant` WHERE `Code_P` ='$Etudiant'"; 
$numresults=mysql_query($query);
$row10 = mysql_fetch_assoc($numresults);

get the id

 

and the second gets the search results in another table

$Nom = $row10["Nom"];
$Prenom = $row10["Prenom"];

$fileSQL="SELECT `N_Etudiant`
FROM  `Expulsion` 
WHERE  `Nom` LIKE  '$Nom'
AND  `Prenom` LIKE  '$Prenom'
LIMIT 0 , 30";
$fileLIST=mysql_query($fileSQL);

 

Link to comment
https://forums.phpfreaks.com/topic/252535-echo-no-results/#findComment-1294743
Share on other sites

ya i seen your page..

 

but the thing is is that the first query is for the second to work..

 

inless i can do an inner join ?

 

cause i can't put the second query but on the first i can't..

 

 

if (!$result) {
    echo "Could not successfully run query ($sql) from DB: " . mysql_error();
    exit;
}
while ($row = mysql_fetch_array()) {
.... 
}

Link to comment
https://forums.phpfreaks.com/topic/252535-echo-no-results/#findComment-1294857
Share on other sites

techker:  the point is that if the first query fails OR it does not return a row, there is no reason to do the 2nd query because it will also fail.  This is why you need to check the result of the query, and only do that if you have a result AND you were able to get a row to drive the 2nd query. 

 

This is simple IF THEN ELSE logic.  I could write the code for you, but the purpose of this forum is to help people do for themselves.  If you have new code that shows your progress but still doesn't work, we will help out, but so far I've not seen any new code from you that reflects you understand the advice I provided.

Link to comment
https://forums.phpfreaks.com/topic/252535-echo-no-results/#findComment-1295416
Share on other sites

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.