Jump to content


say whaaa? Php issue.


14 replies to this topic

#1 influct

    Young Padawan

  • Members
  • Pip
  • 63 posts

Posted 27 September 2006 - 02:52 PM

I've tried everything, I consider myself a.ok at php but this has me stumped:S
http://www.sfegaming...arcade/beta.php
Notice the whole "Resource id #13"
Anyone got any clues?
I have never come accross anything like this before.
Please help:)
Thanks.
Henry.

#2 Mr. Matt

    Moderator

  • P2L Staff
  • PipPipPipPip
  • 1,945 posts
  • Gender:Not Telling

Posted 27 September 2006 - 02:56 PM

post the code, how do you expect us to help without seeing the code...

Matt

#3 Davey

    P2L Jedi

  • Members
  • PipPipPip
  • 620 posts
  • Location:Perth, Scotland
  • Interests:Creativity, Adrenaline, Etc

Posted 27 September 2006 - 03:05 PM

surely if u're ok at php u'll realise the code is executed on the file being accessed on the server? lol

#4 cheerio

    Young Padawan

  • Members
  • Pip
  • 246 posts
  • Gender:Male

Posted 27 September 2006 - 03:08 PM

that happens when you try to echo a class variable like so:
class bleh{ }
$myClass = new bleh;
echo $myClass;


#5 influct

    Young Padawan

  • Members
  • Pip
  • 63 posts

Posted 27 September 2006 - 03:10 PM

I was kinda hoping it was one of those problems that people can just look at and go.
Oh. well you've done xyz.
Lets go get our code:D

<?php
include_once "conn.php";					  
$last = $totalrows - 10;	 
$last5 = $totalrows - $last;
$quer  = "SELECT * FROM games WHERE (sender is NULL OR sender = '') ORDER BY score DESC LIMIT $last5";
$result = mysql_query($quer,$db) or die("Error: " . mysql_error());

$datas = mysql_fetch_array($result);	
$quer  = "SELECT SUM(rate) as total_rate, gName,catid FROM komento WHERE sender <> 'video' GROUP BY gName,catid ORDER BY total_rate DESC LIMIT $last5";
$result = mysql_query($quer,$db) or die("Error: " . mysql_error());

$datas = mysql_fetch_array($result);	
echo "<table width=100%>";
   do	{
   $fname = str_replace(" ","-",$datas[gName]);

echo "<tr style='font-size:8pt'><td><a href = '$siteurl/game/$datas[catid]/$fname.html'>".substr($datas[gName], 0, 20)."</a> </td><td align=right>  $datas[total_rate]/10</td></tr>";
	   }	


while ($datas = mysql_fetch_array($result));
echo "</table>";

?>

Thats the page the codes on, I use some includes on the index page to grab that and other things.

Thanks again:)

#6 Lang

    Young Padawan

  • Members
  • Pip
  • 198 posts
  • Gender:Male
  • Location:Ontario, Canada

Posted 27 September 2006 - 03:12 PM

I think you're trying to echo a variable with mysql_query();

Example:
$sql = "SELECT * FROM table";
$sql = mysql_query($sql);

echo $sql;

Try this:

$sql = "SELECT * FROM table";
$sql = mysql_query($sql):

While ($row = MySQL_fetch_array($sql)){
   echo $row['field_name'];
}

Edited by Lang, 27 September 2006 - 03:12 PM.


#7 cheerio

    Young Padawan

  • Members
  • Pip
  • 246 posts
  • Gender:Male

Posted 27 September 2006 - 03:31 PM

In my example I said "class." Well I meant Object, and a class is an object, and so is a mysql_query(), so don't try echoing those and you'll be fine, unless you use 2 variables or put the echo $sql before mysql_query();

#8 influct

    Young Padawan

  • Members
  • Pip
  • 63 posts

Posted 27 September 2006 - 03:43 PM

thanks you guys, gonna try it now:)

#9 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 27 September 2006 - 03:49 PM

View PostDavey, on Sep 27 2006, 02:05 PM, said:

surely if u're ok at php u'll realise the code is executed on the file being accessed on the server? lol
Umm, no.

View Postcheerio, on Sep 27 2006, 02:08 PM, said:

that happens when you try to echo a class variable like so:
class bleh{ }
$myClass = new bleh;
echo $myClass;
Umm...
$obj = new class;
echo $obj; /* == Object; !is_resource($obj); */

View Postinfluct, on Sep 27 2006, 02:10 PM, said:

I was kinda hoping it was one of those problems that people can just look at and go.
Oh. well you've done xyz.
Well, in this case it sort of was, but the code would help us to know where exactly the problem is happening.

View PostLang, on Sep 27 2006, 02:12 PM, said:

I think you're trying to echo a variable with mysql_query();
And we have a winner...

<?php
include_once "conn.php";
echo 'Resource error is in the config if above this line...'; /* Just an error check... */					 
$last = $totalrows - 10;	 
$last5 = $totalrows - $last;

$result = mysql_query("SELECT SUM(rate) as total_rate, gName,catid FROM komento WHERE sender <> 'video' GROUP BY gName,catid ORDER BY total_rate DESC LIMIT $last5", $db) or die("Error: ".mysql_error());
  
echo "<table width=100%>";
while ($datas = mysql_fetch_array($result)){
   $fname = str_replace(" ","-",$datas['gName']);

echo "<tr style='font-size:8pt'><td><a href = '$siteurl/game/{$datas['catid'}]/$fname.html'>".substr($datas['gName'], 0, 20)."</a> </td><td align=right>  {$datas['total_rate']}/10</td></tr>";
}	

echo "</table>";
?>
That shouldn't fix the problem, but it removed a lot of junk.

Edited by rc69, 27 September 2006 - 03:50 PM.


#10 influct

    Young Padawan

  • Members
  • Pip
  • 63 posts

Posted 27 September 2006 - 04:03 PM

thanks:)
That cleared lots of the junk that was affecting things:S
Sadly I'm getting more errors:S
This is madness, I'm going to recode this from scratch...
(wanders of mumbling bitchy comments about the folks that scripted this in the first place)

#11 Matthew.

    Official Spammer .Matt

  • Members
  • PipPipPipPip
  • 2,749 posts
  • Gender:Male
  • Location:England

Posted 27 September 2006 - 04:08 PM

If you were to post the errors you are now getting for us to look at you may not have to recode it :) I remember when i used to battle with Resource #n errors....mine always used to be resource 14 :( :lol:

Matt.

Edited by Matthew., 27 September 2006 - 04:09 PM.


#12 influct

    Young Padawan

  • Members
  • Pip
  • 63 posts

Posted 27 September 2006 - 04:19 PM

Did it:D

Thanks guys, you'll notice I borrowed your code:)
Big thanks to rc69 for helping me by cleaning the code:)

<?php
include_once "conn.php";				 
$last = $totalrows - 10;	
$last5 = $totalrows - $last;
$sql = mysql_query("SELECT SUM(rate) as total_rate, gName,catid FROM komento WHERE sender <> 'video' GROUP BY gName,catid ORDER BY total_rate DESC LIMIT $last5");
$sql2 = mysql_query($sql);
While ($row = MySQL_fetch_array($sql)){
   echo
$row['gName']
;
}
?>

He, my finished product;)

#13 cheerio

    Young Padawan

  • Members
  • Pip
  • 246 posts
  • Gender:Male

Posted 27 September 2006 - 04:42 PM

thanks rc69, that was my mistake :(

#14 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 28 September 2006 - 06:10 PM

Does that actually work influct? It should throw an error from mysql_query() (the second one...). But i'm gonna pull a matt on you really quickly and say, add error reproting. It will help you out in the long run.
<?php
include_once "conn.php";				 
$last = $totalrows - 10;	
$last5 = $totalrows - $last;
$sql = mysql_query("SELECT SUM(rate) as total_rate, gName,catid FROM komento WHERE sender <> 'video' GROUP BY gName,catid ORDER BY total_rate DESC LIMIT $last5") or die(mysql_error());

while($row = mysql_fetch_array($sql)){
   echo $row['gName'];
}
?>


#15 influct

    Young Padawan

  • Members
  • Pip
  • 63 posts

Posted 30 September 2006 - 08:43 AM

seems to be working fine:)
Thanks for the error reporting idea:)





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users