Jump to content

[SOLVED] Need Another Code Checking


djfox

Recommended Posts

<?
if ($_GET['alert'] == "noechos") {
echo "<script language=\"javascript\" type=\"text/javascript\">
alert(\"You don't have enough echos for this!\");
</script>";
}

  if(!$offset) $offset=0;
  $recent = 0;
  $res = mysql_query("Select id,seller,item,sellprice,price,sellerid FROM coll_sell ORDER BY id DESC")or die( mysql_error() );
echo "";
  while( $row = mysql_fetch_row($res) ){
if( $recent >= $offset && $recent < ($offset + 25 )){
    
    if( $recent%1 == 0 ){
echo "<tr><td bgcolor='312D37'><td bgcolor='312D37'><td bgcolor='312D37'><td bgcolor='312D37'><tr>";
    }
?>
<?
$res = mysql_query("SELECT id, name, description, url, price, preview FROM collection WHERE id='$row[2]'");
$item = mysql_fetch_row($res);
mysql_free_result($res);
?>
<td><img src="stamps/<? echo "$item[6]" ?>"> <? echo "$item[1]" ?>
<td><a href="trancer.php?g=<? echo"$row[5]" ?>"><? echo "$row[1]" ?></a>
<td><? echo "$row[3]" ?> Echos
<td><a href="sellbuy.php?id=<? echo "$row[0]" ?>&p=<? echo "$row[3]" ?>&pr=<? echo "$row[4]" ?>">Buy</a>
<?
  }
$recent = $recent + 1;
}
  echo "";
?>

 

All the information is properly displaying. However, after all the displayed information, I get this error message:

Warning: mysql_fetch_row(): 22 is not a valid MySQL result resource in /home/secrett1/public_html/testing/vendor_grovepark.php on line 109

 

And, it only lists one item. It will not list the other items in the coll_sell table.

 

Line 109 is this line:

  while( $row = mysql_fetch_row($res) ){

 

Why is this error coming up? What can I do to fix it?

Link to comment
https://forums.phpfreaks.com/topic/60310-solved-need-another-code-checking/
Share on other sites

That means you have a problem with your query:

$res = mysql_query("Select id,seller,item,sellprice,price,sellerid FROM coll_sell ORDER BY id DESC")
or die( mysql_error() );

 

Are you sure it isn't give you an error message?

 

Try putting this at the top of your script:

error_reporting(E_ALL);

These pop up:

 

Notice: Undefined index: alert in /home/secrett1/public_html/testing/vendor_grovepark.php on line 101

 

Notice: Undefined variable: offset in /home/secrett1/public_html/testing/vendor_grovepark.php on line 107

 

Warning: mysql_fetch_row(): 22 is not a valid MySQL result resource in /home/secrett1/public_html/testing/vendor_grovepark.php on line 111

 

Line 101

if ($_GET['alert'] == "noechos") {

 

Line 107

if(!$offset) $offset=0;

 

Line 111

while( $row = mysql_fetch_row($res) ){

<?php
if (isset($_GET['alert'] && $_GET['alert'] == "noechos") {
echo "<script language=\"javascript\" type=\"text/javascript\">
alert(\"You don't have enough echos for this!\");
</script>";
}
  // should it be $_GET['offset'] ??
  if(isset($offest) && !$offset) $offset=0;
  $recent = 0;
  $res = mysql_query("Select id,seller,item,sellprice,price,sellerid FROM coll_sell ORDER BY id DESC")or die( mysql_error() );

  while( $row = mysql_fetch_row($res) ){
if( $recent >= $offset && $recent < ($offset + 25 )){
	if( $recent%1 == 0 ){
		echo "<tr><td bgcolor='312D37'><td bgcolor='312D37'><td bgcolor='312D37'><td bgcolor='312D37'><tr>";
	}
// needs to be named different than what we are looping on.
$res2 = mysql_query("SELECT id, name, description, url, price, preview FROM collection WHERE id='$row[2]'");
$item = mysql_fetch_row($res2);
mysql_free_result($res2);
?>
<td><img src="stamps/<? echo "$item[6]" ?>"> <? echo "$item[1]" ?>
<td><a href="trancer.php?g=<? echo"$row[5]" ?>"><? echo "$row[1]" ?></a>
<td><? echo "$row[3]" ?> Echos
<td><a href="sellbuy.php?id=<? echo "$row[0]" ?>&p=<? echo "$row[3]" ?>&pr=<? echo "$row[4]" ?>">Buy</a>
<?php
  }
$recent = $recent + 1;
}
?>

 

First off use <?php as <? has been depreciated. Check that offset is not being passed GET or POST, you always check a variable for being isset to avoid the notice error.

 

For the query error you are using $res inside the while, which is what screwed it up, change that to a different name

 

Edits made above.

frost110

 

Putting in your code, the page is blank with just this message:

Parse error: syntax error, unexpected T_BOOLEAN_AND, expecting ',' or ')' in /home/secrett1/public_html/testing/vendor_grovepark.php on line 99

 

Line 99 is:

if (isset($_GET['alert'] && $_GET['alert'] == "noechos") {

here is your code

if (isset($_GET['alert'] && $_GET['alert'] == "noechos") {

heres what i posed

if (isset($_GET['alert']) && $_GET['alert'] == "noechos") {

 

 

isset($_GET['alert'])

you have to place the ) after $_GET['alert'] isset is a predefine function so it need a complete ()

 

 

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.