Alright, I've tried to fix this bug for the last hour, and I'm definately stuck. I'm relatively new to php AND mySQL, so I'm sure this is just a stupid syntax mistake.
So here's my problem:
I call this script from a link on the main articles page.
(ex. url "http://bubinski.frih.net/articles/article.php?id=3")
article.php is a template, and I have this little script that looks through my articles table and pulls up the proper article that matches the id in the url. The entire system works when I manually substitute the $id for a number, like 3, but when I leave it as a varaiable, I get this error:
Which makes me assume the proper row isn't being returned at all.
and now here's the code:
Note this is just the code in the header section, which retrieves the row, splits the row up into an array of values, and then assigns those values to the proper variables. Later on in my script they are echo'd into the html document.
here's the script in action (unfinished)
http://bubinski.frih.net/articles/
thanks in advance.
So here's my problem:
I call this script from a link on the main articles page.
(ex. url "http://bubinski.frih.net/articles/article.php?id=3")
article.php is a template, and I have this little script that looks through my articles table and pulls up the proper article that matches the id in the url. The entire system works when I manually substitute the $id for a number, like 3, but when I leave it as a varaiable, I get this error:
| Quote: |
| Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/hobbkins/domains/bubinski.frih.net/public_html/articles/article.php on line 11 |
Which makes me assume the proper row isn't being returned at all.
and now here's the code:
Note this is just the code in the header section, which retrieves the row, splits the row up into an array of values, and then assigns those values to the proper variables. Later on in my script they are echo'd into the html document.
here's the script in action (unfinished)
http://bubinski.frih.net/articles/
| Code: |
| <?php
$pageType="articles"; require_once($_SERVER['DOCUMENT_ROOT']."/include/config.php"); $db = mysql_connect($dbhost,$dbuser,$dbpass); mysql_select_db($dbname) or die(mysql_error()); //problem area, I believe $result = mysql_query("SELECT * FROM articles WHERE id=$id"); //note, id is a field in the articles table that is unique and incremented by one each time an article is added to my site while($r = mysql_fetch_array($result)) { $title = $r['title']; $date = $r['date']; $author = $r['author']; $entry = $r['entry']; $thisPage = $title; } ?> |
thanks in advance.
