Jump to content


Photo

Mysql_fretch_array


  • Please log in to reply
21 replies to this topic

#1 chriscloyd

chriscloyd
  • Members
  • PipPipPip
  • Advanced Member
  • 489 posts
  • LocationArizona

Posted 15 August 2006 - 07:57 AM

i get this error

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/.giro/thegtz/aspire-hosting.net/includes/latestthreads.php on line 5

and my code is

<?php
include("threaddb.php");
$latest = mysql_query("SELECT * FROM 'thread' ORDER BY date DESC 'threadid' LIMIT '7'");
echo '<table width="193" border="0" bordercolor="#000000" bgcolor="#FFFFFF">';
while ($row = mysql_fetch_array ($latest)){
echo '<tr>
    <td width="105"><div align="left">'.$row['title'].'</div></td>
    <td width="78"><div align="center"><a href="forums/showthread.php?t'.$row['threadid'].'">View</a></div></td>
  </tr>';
}
echo '</table>';
?>

can someone help me fast please

44 bugs in my java code
44 bugs in my java code
Fix 1 bug, and complie again
122 bugs in my java code

#2 hostfreak

hostfreak
  • Members
  • PipPipPip
  • Advanced Member
  • 581 posts

Posted 15 August 2006 - 08:09 AM

Try:

<?php
include("threaddb.php");
$latest = mysql_query("SELECT * FROM 'thread' ORDER BY date DESC 'threadid' LIMIT '7'");
while ($row = mysql_fetch_array ($latest)){
$title = $row['title'];
$threadid = $row['threadid'];
?>
<table width="193" border="0" bordercolor="#000000" bgcolor="#FFFFFF">';
	<tr>
		<td width="105"><div align="left"><?php echo $title; ?></div></td>
		<td width="78"><div align="center"><a href="forums/showthread.php?t=<?php echo $threadid; ?>'">View</a></div></td>
	</tr>
<?php
}
echo '</table>';
?>


#3 chriscloyd

chriscloyd
  • Members
  • PipPipPip
  • Advanced Member
  • 489 posts
  • LocationArizona

Posted 15 August 2006 - 08:13 AM

Nope same error
44 bugs in my java code
44 bugs in my java code
Fix 1 bug, and complie again
122 bugs in my java code

#4 hostfreak

hostfreak
  • Members
  • PipPipPip
  • Advanced Member
  • 581 posts

Posted 15 August 2006 - 08:15 AM

Not sure if it matters, but try:

<?php
include("threaddb.php");
$latest = mysql_query("SELECT * FROM 'thread' ORDER BY date DESC 'threadid' LIMIT '7'");
while ($row = mysql_fetch_array($latest)){ //took out the space
$title = $row['title'];
$threadid = $row['threadid'];
?>
<table width="193" border="0" bordercolor="#000000" bgcolor="#FFFFFF">';
	<tr>
		<td width="105"><div align="left"><?php echo $title; ?></div></td>
		<td width="78"><div align="center"><a href="forums/showthread.php?t=<?php echo $threadid; ?>'">View</a></div></td>
	</tr>
<?php
}
echo '</table>';
?>


#5 chriscloyd

chriscloyd
  • Members
  • PipPipPip
  • Advanced Member
  • 489 posts
  • LocationArizona

Posted 15 August 2006 - 08:17 AM

thats what i did
44 bugs in my java code
44 bugs in my java code
Fix 1 bug, and complie again
122 bugs in my java code

#6 hostfreak

hostfreak
  • Members
  • PipPipPip
  • Advanced Member
  • 581 posts

Posted 15 August 2006 - 08:19 AM

It's different than the first one I posted, I commented on the slight difference. I said I wasn't sure if it mattered, but the first one was:

while ($row = mysql_fetch_array ($latest)){

The second one was:

while ($row = mysql_fetch_array($latest)){ //took out the space


#7 chriscloyd

chriscloyd
  • Members
  • PipPipPip
  • Advanced Member
  • 489 posts
  • LocationArizona

Posted 15 August 2006 - 08:22 AM

ya i did and it still doesnt lol
any other way of doing what im trying to do im trying to get the 7 newest rows by id from threads
44 bugs in my java code
44 bugs in my java code
Fix 1 bug, and complie again
122 bugs in my java code

#8 hostfreak

hostfreak
  • Members
  • PipPipPip
  • Advanced Member
  • 581 posts

Posted 15 August 2006 - 08:25 AM

Are you sure "thread" is a table in the database? And that date, threadid, and title are all fields in the table "thread" ?

#9 chriscloyd

chriscloyd
  • Members
  • PipPipPip
  • Advanced Member
  • 489 posts
  • LocationArizona

Posted 15 August 2006 - 08:26 AM

ya the error im getting now is

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 'threadid LIMIT 7' at line 1

and my mysql_query is

mysql_query("SELECT * FROM thread ORDER BY threadid DESC threadid LIMIT 7") or die(mysql_error());
44 bugs in my java code
44 bugs in my java code
Fix 1 bug, and complie again
122 bugs in my java code

#10 hostfreak

hostfreak
  • Members
  • PipPipPip
  • Advanced Member
  • 581 posts

Posted 15 August 2006 - 08:28 AM

I think the problem might be:

$latest = mysql_query("SELECT * FROM 'thread' ORDER BY date DESC 'threadid' LIMIT '7'");

Try changing that to:

$latest = mysql_query("SELECT * FROM 'thread' ORDER BY date, threadid DESC LIMIT 0, 7");


#11 chriscloyd

chriscloyd
  • Members
  • PipPipPip
  • Advanced Member
  • 489 posts
  • LocationArizona

Posted 15 August 2006 - 08:29 AM

i fixed it i took out threadid after desc but now it messes up my whole page :(

44 bugs in my java code
44 bugs in my java code
Fix 1 bug, and complie again
122 bugs in my java code

#12 hostfreak

hostfreak
  • Members
  • PipPipPip
  • Advanced Member
  • 581 posts

Posted 15 August 2006 - 08:30 AM

Why was the threadid in there anyways? Were you trying to order the page by the threadid as well?

#13 chriscloyd

chriscloyd
  • Members
  • PipPipPip
  • Advanced Member
  • 489 posts
  • LocationArizona

Posted 15 August 2006 - 08:31 AM

ya but i already had it b4 desc thats why.  but now its messing up my whole page www.aspire-hosting.net
44 bugs in my java code
44 bugs in my java code
Fix 1 bug, and complie again
122 bugs in my java code

#14 hostfreak

hostfreak
  • Members
  • PipPipPip
  • Advanced Member
  • 581 posts

Posted 15 August 2006 - 08:34 AM

Yeah, the page really is messed up. Can you maybe post your whole code?

#15 chriscloyd

chriscloyd
  • Members
  • PipPipPip
  • Advanced Member
  • 489 posts
  • LocationArizona

Posted 15 August 2006 - 08:35 AM

i fixed it but now its only showing a one!
44 bugs in my java code
44 bugs in my java code
Fix 1 bug, and complie again
122 bugs in my java code

#16 hostfreak

hostfreak
  • Members
  • PipPipPip
  • Advanced Member
  • 581 posts

Posted 15 August 2006 - 08:36 AM

Most likely you moved the "}" to where after the rows were selected? It won't work then because it cannot loop through all the results.

#17 chriscloyd

chriscloyd
  • Members
  • PipPipPip
  • Advanced Member
  • 489 posts
  • LocationArizona

Posted 15 August 2006 - 08:43 AM

now its not showing anything
44 bugs in my java code
44 bugs in my java code
Fix 1 bug, and complie again
122 bugs in my java code

#18 hostfreak

hostfreak
  • Members
  • PipPipPip
  • Advanced Member
  • 581 posts

Posted 15 August 2006 - 08:44 AM

Can you post the code your using that's not showing anything?

#19 chriscloyd

chriscloyd
  • Members
  • PipPipPip
  • Advanced Member
  • 489 posts
  • LocationArizona

Posted 15 August 2006 - 08:47 AM

<?php
include("threaddb.php");
$latest = mysql_query("SELECT * FROM thread ORDER BY threadid DESC LIMIT 7") or die(mysql_error());
echo '<table width="193" border="0" bordercolor="#000000" bgcolor="#FFFFFF">';
while ($row = mysql_fetch_array($latest)){

$title = $row['title'];
$threadid = $row['threadid'];
echo '<tr>
		<td width="105"><div align="left">'.$title.'</div></td>
		<td width="78"><div align="center"><a href="forums/showthread.php?t'.$threadid.'">View</a></div></td>
	</tr>';
}
echo '</table>';
?>

44 bugs in my java code
44 bugs in my java code
Fix 1 bug, and complie again
122 bugs in my java code

#20 chriscloyd

chriscloyd
  • Members
  • PipPipPip
  • Advanced Member
  • 489 posts
  • LocationArizona

Posted 15 August 2006 - 08:53 AM

look on the normal page

http://www.aspire-ho...testthreads.php
it shows it but when u go to
http://www.aspire-hosting.net
it wont
44 bugs in my java code
44 bugs in my java code
Fix 1 bug, and complie again
122 bugs in my java code




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users