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
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);

Link to comment
Share on other sites

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) ){

Link to comment
Share on other sites

<?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.

Link to comment
Share on other sites

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") {

Link to comment
Share on other sites

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 ()

 

 

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.