PHP MYsql Trouble - Pls Help
OK well iv been playing around witht this php site iv made for a long time now… well not really, but bits of the code are from some much earlier sites of mine. Anyway, i made a page system, where i have an iframe in the middle, and a database that has a table with name and url fields, so if something in the $_GET variable page corrosponds to the 'name', it will make the iframe link to the url from the database.
This works fine, but i have an error about the mysql_fetch_array();
markupWarning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in c:\program files\easyphp1-8\www\ethical\indexxxx - edit.php on line 19
The relevent code looks like this:
if($page == NULL){
$page = 'home';
};
require("stats/db.php");
$rPage = mysql_query("SELECT * FROM pages WHERE name = '$page'");
$row = mysql_fetch_array($rPage))
$rPage = $row['url'];
if($rPage == NULL){
$rPage = 'html/error.html';
};
...
<iframe name="Content" allowtransparency="True" height="640" width="447" src="<? echo $rPage; ?>" frameborder="0"></iframe>
Any ideas?
I'm not exactly sure why that didn't work, but it looks like parts of the code are missing, so could you post the rest.
But this is what I use and it works.
$query = "SELECT * FROM shout ORDER BY -shoutid LIMIT 10";
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($result)){
$id = $row['shoutid'];
}
Edit: You have
$rPage = mysql_query("SELECT * FROM pages WHERE name = '$page'");
$row = mysql_fetch_array($rPage))
$rPage = $row['url'];
Should be
$rPage = "SELECT * FROM pages WHERE name = '$page'";
$result = mysql_query($rPage) or die(mysql_error());
$row = mysql_fetch_array($result);
$rPage = $row['url'];
Get rid of the mysql_query() and add a $result = mysql_query($rPage)