Jump to content

Recommended Posts

can anyone see a error with this code ?

 

$query = mysql_query("SELECT * FROM project WHERE Module_Code ='$schemelevel' AND Available ='Yes'");

$result = mysql_query($query);

 

while ($myrow = mysql_fetch_row($result)) {

 

seems to be a issue using fetch_row ($result) telling me theres a issue with the resource

 

Link to comment
https://forums.phpfreaks.com/topic/259742-help/
Share on other sites

mysql_query expects it's first argument to be a string containing valid SQL, which is what you have contained in $query.

With $result, you are attempting to query a query resource, which is invalid, the code should read:

 

$query = "SELECT * FROM project WHERE Module_Code = '$schemelevel' AND Available = 'Yes'";
$result = mysql_query($query);
while ($myrow = mysql_fetch_row($result))
{
//code
}

Link to comment
https://forums.phpfreaks.com/topic/259742-help/#findComment-1331217
Share on other sites

Is there any other code in the page?

Try this debugging code and post the results:

 

$sql = "SELECT * FROM project WHERE Module_Code = '$schemelevel' AND Available = 'Yes'";
$result = mysql_query($sql) or die($sql .'<br />'. mysql_error());
if(mysql_num_rows($result) == 0)
{
    echo "no results";
    exit;
}
while ($myrow = mysql_fetch_row($result))
{
//code
}

Link to comment
https://forums.phpfreaks.com/topic/259742-help/#findComment-1331221
Share on other sites

alright, then try this:

 

$sql = "SELECT * FROM project WHERE Module_Code = '$schemelevel' AND Available = 'Yes'";
$result = mysql_query($sql) or die($sql .'<br />'. mysql_error());
if(mysql_num_rows($result) == 0)
{
    echo "no results <br/ >";
    echo $sql;
    exit;
}
while ($myrow = mysql_fetch_row($result))
{
//code
}

Link to comment
https://forums.phpfreaks.com/topic/259742-help/#findComment-1331225
Share on other sites

<?php
$db = mysql_connect("", "","");
mysql_select_db("");

$schemelevel = $_POST['schemelevel'];

$sql = "SELECT * FROM project WHERE Module_Code = '$schemelevel' AND Available = '1'";
$result = mysql_query($sql) or die($sql .'<br />'. mysql_error());
if(mysql_num_rows($result) == 0)
{
    echo "no results <br/ >";
    echo $sql;
    exit;
}
while ($myrow = mysql_fetch_row($result))
{
echo "<table border=1>\n";
echo "<tr><td>Module Code</td><td>Title</td><td>First_Supervisor</td><td>Level</td><td>Description</td></tr>\n";




echo "<tr><td><A HREF='http://students.comp.glam.ac.uk/08030472/project/displayproject.php?T1=$myrow[0]'>$myrow[0]</A></td><td>$myrow[1]</td><td>$myrow[2]</td><td>$myrow[3]</td><td>$myrow[4]</td></tr>\n";
	//printf("<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>\n",
	//echo"<A HREF='http://students.comp.glam.ac.uk/08030472/project/displayproject.php?T1=$myrow[0]'>$myrow[0]</A>"$myrow[0],$myrow[1],$myrow[2],$myrow[3],$myrow[4]);
}
echo "</table>\n";
?>
</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/259742-help/#findComment-1331255
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.