Jump to content

[SOLVED] Can't get this to work! Agh.


adamjones

Recommended Posts

Ok.

So I'm making some really basic forums. I'm trying to echo data from a table, depending on the forum name, and ID of the post;

 

<?php
....DB Connection....

$forum=$_GET['forum']; 
$id=$_GET['id'];

$sql="SELECT * FROM $tbl_name WHERE forum='$forum' AND id='$id'";
$result=mysql_query($sql);

$rows=mysql_fetch_array($result);
?>

 

And then I will echo the rows, eg;

<? echo $rows['topic']; ?>

 

But I keep getting this error;

 

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/domainey/public_html/habhub/topic.php on line 69

 

Any ideas?

Cheers.

Link to comment
https://forums.phpfreaks.com/topic/153928-solved-cant-get-this-to-work-agh/
Share on other sites

Change this:

$result=mysql_query($sql);

 

to this:

echo $sql;

$result=mysql_query($sql) or die(mysql_error());

 

And post what you see.

 

 

SELECT * FROM general_forum_question WHERE forum='general' AND id='1'Unknown column 'forum' in 'where clause'

 

ooops.

silly me. forgot to add that colum!!

 

thanks

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.