Jump to content


Tutorial CSM Help needed.


3 replies to this topic

#1 DanWilliamson

    P2L Jedi

  • Members
  • PipPipPip
  • 650 posts

Posted 28 January 2006 - 10:41 AM

Hey guys,

I need some help and I don't really know whats happening so it'd be great if one of you masters could help me.

I've created a CMS for my tutorials and eerythings working except tutorials.php so I don't want no answers like check your dbconnect data.

And yes i've followed a tutorial to do it but I will be highly editing it.and adding a whole admin section just want to get it all up and running.

Heres the code:

<?php

include ("dbconnect.php");

if (isset($ID))
{
$tuts="SELECT * from yourtable where ID='$ID'";
$tuts2=mysql_query($tuts);
while ($tuts3=mysql_fetch_array($tuts2))

{

echo "

<table width=100% border=0 cellspacing=3 cellpadding=0>
<tr>
<td>
<font color=#82A1FF size=1 face=Verdana, Arial, Helvetica, sans-serif><b>$tuts3[title]</b><br>
<font color=#000000>By <b>$tuts3[user]</b><br>
<i>$tuts3[description]</i><br>
<br>
$tuts3[message]<br>
<br>
</td>
</tr>
</table>

"; }
}


else if(!isset($id))
{
$tut="SELECT * from yourtable";
$tut2=mysql_query($tut);
while($tut3=mysql_fetch_array($tut2))

{

echo "

<font color=#000000 size=1 face=Verdana, Arial, Helvetica, sans-serif>
<table width=250 border=0 cellspacing=3 cellpadding=0>
<tr>
<td width=42 height=42>
<div align=center><a href='tutorials.php?ID=$tut3[ID]'><img src='$tut3[avatar]' border='0' alt='$tut3[title]' target='main'></a></div></td>
<td width=208><font color=#82A1FF size=1 face=Verdana, Arial, Helvetica, sans-serif><strong>$tut3[title]</strong><br>
<font color=#000000><em>$tut3[date]</em><br>
By <strong>$tut3[user]</strong></font><br></font></td>
</tr></table>

"; }
}


?>

The error I get is:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/daniel/public_html/tutorials.php on line 36


- Dan

Edited by DanWilliamson, 28 January 2006 - 10:42 AM.


#2 meadow

    Young Padawan

  • Members
  • Pip
  • 224 posts
  • Location:Devon, England
  • Interests:Php, Hockey, mysql, web design.

Posted 28 January 2006 - 12:04 PM

Try changing
$tut="SELECT * from yourtable";
$tut2=mysql_query($tut);
while($tut3=mysql_fetch_array($tut2))

To

$result = mysql_query("SELECT * FROM yourtable");
	 while($tut3=mysql_fetch_array($result)){

Edited by meadow, 28 January 2006 - 12:04 PM.


#3 Stu

    Retired P2L Staff

  • Publishing Betazoids
  • PipPipPipPip
  • 1,761 posts
  • Gender:Male

Posted 28 January 2006 - 12:18 PM

that pretty much means that something is wrong with your query i think. like meadow said instead of just using $tuts and $tuts2 etc give it some structure and meaning which will help you troubleshoot in the future..

search the forums, theres actually three or four recent-ish threads with the same problem...

#4 rc69

    PHP Master PD

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

Posted 28 January 2006 - 01:18 PM

This question has been asked before.
http://www.pixel2lif...showtopic=17252

Please do a forum search next time.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users