Unstoppable Domains โ€” Get your daily AI drops report

Mysql errors, PLEASE HELP

SpaceshipSpaceship
Watch
Impact
38
www.dailydrinker.com

Click one of the categories on the left or recipes in the center and you get many mysql errors. Whats going on>???
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
Unstoppable Domains โ€” AI StorefrontUnstoppable Domains โ€” AI Storefront
Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in /home/dailydri/public_html/category.php on line 25

Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home/dailydri/public_html/category.php on line 49

Care to post the code for category.php?
 
0
•••
<?php include("rheader.php"); ?>

<?php

$letter = $_REQUEST['letter'];
$numeric = $_REQUEST['numeric'];

if ($letter) {

$sql = "select drinkid, title, date, rating from drinks where title like '$letter%' and status = 'L'";

} else {

$sql = "select drinkid, title, date, rating from drinks where categoryid = $catid and status = 'L'";

}

if ($numeric == "all") {
$sql = "select drinkid, title, date, rating from drinks where title REGEXP '^[1234567890]' and status = 'L'";
}



$result = mysql_query($sql ,$db);
$numrows = mysql_numrows($result);

$lastpage = false;

if ($pagenum == 0) {
$startrow = 0;
} else {
$startrow = 25 * $pagenum;
}

if ($numrows < $startrow + 25) {
$endrow = $numrows;
$lastpage = true;
}

if ($letter) {

$sql = "select drinkid, title, date, rating from drinks where title like '$letter%' and status = 'L' order by title limit $startrow,25";
$pagetitle = "Drinks starting in the letter '$letter'";

} else {

$sql = "select * from categories where categoryid = $catid";
$result = mysql_query($sql ,$db);
$row = mysql_fetch_row($result);
$pagetitle = $row[1];

$sql = "select drinkid, title, date, rating from drinks where categoryid = $catid and status = 'L' order by title limit $startrow,25";

}

if ($numeric == "all") {
$sql = "select drinkid, title, date, rating from drinks where title REGEXP '^[1234567890]' and status = 'L' order by title limit $startrow,25";
$pagetitle = "Drinks starting in numbers";
}


?>


<TD VALIGN=top width="60%" BGCOLOR="FFFFFF">

<TABLE BORDER=0 WIDTH=99% ALIGN=CENTER>
<TR>

<TD VALIGN=top>

<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100% BGCOLOR=000000>
<TR><TD align=center><FONT SIZE=2 FACE="Verdana,arial,helvetica" color=white><B><?php printf($pagetitle); ?></B></FONT></TD></tR>
</TABLE>

<FONT SIZE=2>

<center>
<br>

<table cellspacing=0 cellpadding=2 border=0>
<tr>
<th width=300 bgcolor=#CCCCCC align=center><FONT face=arial size=2>Drink</font></th>
<th width=85 bgcolor=#CCCCCC align=center><FONT face=arial size=2>Date Added</font></th>
<th width=75 bgcolor=#CCCCCC align=center><FONT face=arial size=2>Rating</font></th>
</tr>

<?php

$rowcolor = 1;

$result = mysql_query($sql ,$db);

if ($myrow = mysql_fetch_array($result)) {

do {

if ($rowcolor == 1) {
$rowcolorhex = "#ffffff";
$rowcolor = 0;
} else {
$rowcolorhex = "#EDEAB9";
$rowcolor = 1;
}


printf("<tr>");
printf("<td width=300 bgcolor=%s align=center><FONT face=arial size=2><a href=drink.php?drinkid=%s>%s</a></font></td>", $rowcolorhex, $myrow["drinkid"], $myrow["title"]);
printf("<td width=80 bgcolor=%s align=center><FONT face=arial size=2>%s</font></td>", $rowcolorhex, $myrow["date"]);
printf("<td width=75 bgcolor=%s><table bgcolor=%s border=0 cellspacing=0 cellpadding=0><tr>", $rowcolorhex, $rowcolorhex);

$onstars = round($myrow["rating"]);
$offstars = 5 - $onstars;

for ($i = 1; $i <= $onstars; $i++) {
printf("<td width=15 bgcolor=%s align=center valign=center><FONT face=arial size=2><img src=images/staron2.gif></font></td>", $rowcolorhex);
}

for ($f = 1; $f <= $offstars; $f++) {
printf("<td width=15 bgcolor=%s align=center valign=center><FONT face=arial size=2><img src=images/staroff2.gif></font></td>", $rowcolorhex);
}

printf("</tr></table></td>");
printf("</tr>");
} while ($myrow = mysql_fetch_array($result));

}

printf("<tr>");
if ($startrow > 0) {
printf("<td align=left><FONT face=arial size=2><a href=category.php?pagenum=%s&searchingred=%s&catid=%s&letter=%s>Previous Page</a></font></td>", $pagenum-1, $searchingred, $catid, $letter);
} else {
printf("<td>ย </td>");
}
printf("<td>ย </td>");
if ($lastpage == false) {
printf("<td align=left><FONT face=arial size=2><a href=category.php?pagenum=%s&searchingred=%s&catid=%s&letter=%s>Next Page</a></font></td>", $pagenum+1, $searchingred, $catid, $letter);
} else {
printf("<td>ย </td>");
}
printf("</tr>");

?>
</table>
</center>

</FONT>

</TD></TR></TABLE>

</TD>

<?php include("rfooter.php"); ?>
 
0
•••
Your SQL queries have a problem somewhere.

Change both instances of
$result = mysql_query($sql ,$db);
to
$result = mysql_query($sql ,$db) or die(mysql_error());

This will show you the error messages being returned from MySQL which will help troubleshoot.
 
0
•••
Post your SQL structure?
 
0
•••
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'and status = 'L'' at line 1

is the new error. Does this mean the server does not support it???
 
0
•••
Try:

<?php include("rheader.php"); ?>

<?php

$letter = $_REQUEST['letter'];
$numeric = $_REQUEST['numeric'];

if ($letter) {

$sql = "select drinkid, title, date, rating from drinks where title like '".$letter."%' and status = 'L'";

} else {

$sql = "select drinkid, title, date, rating from drinks where categoryid = '".$catid."' and status = 'L'";

}

if ($numeric == "all") {
$sql = "select drinkid, title, date, rating from drinks where title REGEXP '^[1234567890]' and status = 'L'";
}



$result = mysql_query($sql ,$db);
$numrows = mysql_numrows($result);

$lastpage = false;

if ($pagenum == 0) {
$startrow = 0;
} else {
$startrow = 25 * $pagenum;
}

if ($numrows < $startrow + 25) {
$endrow = $numrows;
$lastpage = true;
}

if ($letter) {

$sql = "select drinkid, title, date, rating from drinks where title like '$letter%' and status = 'L' order by title limit $startrow,25";
$pagetitle = "Drinks starting in the letter '$letter'";

} else {

$sql = "select * from categories where categoryid = $catid";
$result = mysql_query($sql ,$db);
$row = mysql_fetch_row($result);
$pagetitle = $row[1];

$sql = "select drinkid, title, date, rating from drinks where categoryid = $catid and status = 'L' order by title limit $startrow,25";

}

if ($numeric == "all") {
$sql = "select drinkid, title, date, rating from drinks where title REGEXP '^[1234567890]' and status = 'L' order by title limit $startrow,25";
$pagetitle = "Drinks starting in numbers";
}


?>


<TD VALIGN=top width="60%" BGCOLOR="FFFFFF">

<TABLE BORDER=0 WIDTH=99% ALIGN=CENTER>
<TR>

<TD VALIGN=top>

<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100% BGCOLOR=000000>
<TR><TD align=center><FONT SIZE=2 FACE="Verdana,arial,helvetica" color=white><B><?php printf($pagetitle); ?></B></FONT></TD></tR>
</TABLE>

<FONT SIZE=2>

<center>
<br>

<table cellspacing=0 cellpadding=2 border=0>
<tr>
<th width=300 bgcolor=#CCCCCC align=center><FONT face=arial size=2>Drink</font></th>
<th width=85 bgcolor=#CCCCCC align=center><FONT face=arial size=2>Date Added</font></th>
<th width=75 bgcolor=#CCCCCC align=center><FONT face=arial size=2>Rating</font></th>
</tr>

<?php

$rowcolor = 1;

$result = mysql_query($sql ,$db);

if ($myrow = mysql_fetch_array($result)) {

do {

if ($rowcolor == 1) {
$rowcolorhex = "#ffffff";
$rowcolor = 0;
} else {
$rowcolorhex = "#EDEAB9";
$rowcolor = 1;
}


printf("<tr>");
printf("<td width=300 bgcolor=%s align=center><FONT face=arial size=2><a href=drink.php?drinkid=%s>%s</a></font></td>", $rowcolorhex, $myrow["drinkid"], $myrow["title"]);
printf("<td width=80 bgcolor=%s align=center><FONT face=arial size=2>%s</font></td>", $rowcolorhex, $myrow["date"]);
printf("<td width=75 bgcolor=%s><table bgcolor=%s border=0 cellspacing=0 cellpadding=0><tr>", $rowcolorhex, $rowcolorhex);

$onstars = round($myrow["rating"]);
$offstars = 5 - $onstars;

for ($i = 1; $i <= $onstars; $i++) {
printf("<td width=15 bgcolor=%s align=center valign=center><FONT face=arial size=2><img src=images/staron2.gif></font></td>", $rowcolorhex);
}

for ($f = 1; $f <= $offstars; $f++) {
printf("<td width=15 bgcolor=%s align=center valign=center><FONT face=arial size=2><img src=images/staroff2.gif></font></td>", $rowcolorhex);
}

printf("</tr></table></td>");
printf("</tr>");
} while ($myrow = mysql_fetch_array($result));

}

printf("<tr>");
if ($startrow > 0) {
printf("<td align=left><FONT face=arial size=2><a href=category.php?pagenum=%s&searchingred=%s&catid=%s&letter=%s>Previous Page</a></font></td>", $pagenum-1, $searchingred, $catid, $letter);
} else {
printf("<td>ย </td>");
}
printf("<td>ย </td>");
if ($lastpage == false) {
printf("<td align=left><FONT face=arial size=2><a href=category.php?pagenum=%s&searchingred=%s&catid=%s&letter=%s>Next Page</a></font></td>", $pagenum+1, $searchingred, $catid, $letter);
} else {
printf("<td>ย </td>");
}
printf("</tr>");

?>
</table>
</center>

</FONT>

</TD></TR></TABLE>

</TD>

<?php include("rfooter.php"); ?>
 
0
•••
Silly question, maybe, but are you sure that $db is initialised correctly?
 
0
•••
JRBHosting said:
Try:

<?php include("rheader.php"); ?>

<?php

$letter = $_REQUEST['letter'];
$numeric = $_REQUEST['numeric'];

if ($letter) {

$sql = "select drinkid, title, date, rating from drinks where title like '".$letter."%' and status = 'L'";

} else {

$sql = "select drinkid, title, date, rating from drinks where categoryid = '".$catid."' and status = 'L'";

}

if ($numeric == "all") {
$sql = "select drinkid, title, date, rating from drinks where title REGEXP '^[1234567890]' and status = 'L'";
}



$result = mysql_query($sql ,$db);
$numrows = mysql_numrows($result);

$lastpage = false;

if ($pagenum == 0) {
$startrow = 0;
} else {
$startrow = 25 * $pagenum;
}

if ($numrows < $startrow + 25) {
$endrow = $numrows;
$lastpage = true;
}

if ($letter) {

$sql = "select drinkid, title, date, rating from drinks where title like '$letter%' and status = 'L' order by title limit $startrow,25";
$pagetitle = "Drinks starting in the letter '$letter'";

} else {

$sql = "select * from categories where categoryid = $catid";
$result = mysql_query($sql ,$db);
$row = mysql_fetch_row($result);
$pagetitle = $row[1];

$sql = "select drinkid, title, date, rating from drinks where categoryid = $catid and status = 'L' order by title limit $startrow,25";

}

if ($numeric == "all") {
$sql = "select drinkid, title, date, rating from drinks where title REGEXP '^[1234567890]' and status = 'L' order by title limit $startrow,25";
$pagetitle = "Drinks starting in numbers";
}


?>


<TD VALIGN=top width="60%" BGCOLOR="FFFFFF">

<TABLE BORDER=0 WIDTH=99% ALIGN=CENTER>
<TR>

<TD VALIGN=top>

<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100% BGCOLOR=000000>
<TR><TD align=center><FONT SIZE=2 FACE="Verdana,arial,helvetica" color=white><B><?php printf($pagetitle); ?></B></FONT></TD></tR>
</TABLE>

<FONT SIZE=2>

<center>
<br>

<table cellspacing=0 cellpadding=2 border=0>
<tr>
<th width=300 bgcolor=#CCCCCC align=center><FONT face=arial size=2>Drink</font></th>
<th width=85 bgcolor=#CCCCCC align=center><FONT face=arial size=2>Date Added</font></th>
<th width=75 bgcolor=#CCCCCC align=center><FONT face=arial size=2>Rating</font></th>
</tr>

<?php

$rowcolor = 1;

$result = mysql_query($sql ,$db);

if ($myrow = mysql_fetch_array($result)) {

do {

if ($rowcolor == 1) {
$rowcolorhex = "#ffffff";
$rowcolor = 0;
} else {
$rowcolorhex = "#EDEAB9";
$rowcolor = 1;
}


printf("<tr>");
printf("<td width=300 bgcolor=%s align=center><FONT face=arial size=2><a href=drink.php?drinkid=%s>%s</a></font></td>", $rowcolorhex, $myrow["drinkid"], $myrow["title"]);
printf("<td width=80 bgcolor=%s align=center><FONT face=arial size=2>%s</font></td>", $rowcolorhex, $myrow["date"]);
printf("<td width=75 bgcolor=%s><table bgcolor=%s border=0 cellspacing=0 cellpadding=0><tr>", $rowcolorhex, $rowcolorhex);

$onstars = round($myrow["rating"]);
$offstars = 5 - $onstars;

for ($i = 1; $i <= $onstars; $i++) {
printf("<td width=15 bgcolor=%s align=center valign=center><FONT face=arial size=2><img src=images/staron2.gif></font></td>", $rowcolorhex);
}

for ($f = 1; $f <= $offstars; $f++) {
printf("<td width=15 bgcolor=%s align=center valign=center><FONT face=arial size=2><img src=images/staroff2.gif></font></td>", $rowcolorhex);
}

printf("</tr></table></td>");
printf("</tr>");
} while ($myrow = mysql_fetch_array($result));

}

printf("<tr>");
if ($startrow > 0) {
printf("<td align=left><FONT face=arial size=2><a href=category.php?pagenum=%s&searchingred=%s&catid=%s&letter=%s>Previous Page</a></font></td>", $pagenum-1, $searchingred, $catid, $letter);
} else {
printf("<td>ย </td>");
}
printf("<td>ย </td>");
if ($lastpage == false) {
printf("<td align=left><FONT face=arial size=2><a href=category.php?pagenum=%s&searchingred=%s&catid=%s&letter=%s>Next Page</a></font></td>", $pagenum+1, $searchingred, $catid, $letter);
} else {
printf("<td>ย </td>");
}
printf("</tr>");

?>
</table>
</center>

</FONT>

</TD></TR></TABLE>

</TD>

<?php include("rfooter.php"); ?>


Still receiving errors.....
 
0
•••
What error(s)?
 
0
•••
$db doesn't seem to be a valid resource in your query make sure its set correctly. Heres the current errors:

Code:
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home/dailydri/public_html/category.php on line 49

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/dailydri/public_html/category.php on line 94
 
0
•••
Post the code for rheader.php please
 
0
•••
baxter said:
$db doesn't seem to be a valid resource in your query make sure its set correctly. Heres the current errors:

Code:
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home/dailydri/public_html/category.php on line 49

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/dailydri/public_html/category.php on line 94

how do i set it correctly?
 
0
•••
Is this path ok? : /home/dailydri/public_html/category.php ???
 
0
•••
nomis135 said:
Is this path ok? : /home/dailydri/public_html/category.php ???

Well heres the thing. In my smart FTP, it says

DailyDrinker.com

Then it lists everything.

So I think thats right....
 
0
•••
It's mysql_num_rows, not mysql_numrows.

That could be your problem? :red: :)

Find:
PHP:
$numrows = mysql_numrows($result);
Replace with:
PHP:
$numrows = mysql_num_rows($result);

Tell us how it goes. See if it works. :)
 
0
•••
Change
$result = mysql_query($sql ,$db);
To
$result = mysql_query($sql);

Any other instances where it has a mysql_query and a ,$db, do the same thing.
 
0
•••
I am helping him via PM, sorry guys ;)
 
0
•••
CatchedCatched
Escrow.com
Spaceship
Rexus Domain
CryptoExchange.com
Domain Recover
CatchDoms
DomDB
NameFit
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back