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
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
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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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