HuggieBear Posted September 7, 2006 Share Posted September 7, 2006 Remove the curley braces { } from around $page in your SQL statement.Rich Quote Link to comment Share on other sites More sharing options...
roopurt18 Posted September 7, 2006 Share Posted September 7, 2006 By placing:$page = isset($_GET['page']) ? $_GET['page'] : '1';at the top of the page you garauntee that $page is set, so you can remove the opening if statement. I.E., [b]if($page)[/b] is not necessary [b]unless[/b] you specifically want nothing to be shown when the url contains [b]page=0[/b]. Quote Link to comment Share on other sites More sharing options...
HuggieBear Posted September 7, 2006 Share Posted September 7, 2006 I was going to say that, but wanted to go one step at a time ;DCheersRoopert Quote Link to comment Share on other sites More sharing options...
Mutley Posted September 7, 2006 Author Share Posted September 7, 2006 So I've done this:[code]if($page) {$sql = "SELECT * FROM pages WHERE page_id=$page LIMIT 1";$q = mysql_query($sql);if(mysql_num_rows($q) == 1){ while($row = mysql_fetch_array($result)){ $content = $row['content']; }}else{ $content = "You're trying to find random pages in my website!";}echo $content;}[/code]Which still doesn't work but I havn't removed the IF statement, what would it look like as I would need to remove curley brackets to? Could you do a mock up for me please? Quote Link to comment Share on other sites More sharing options...
HuggieBear Posted September 7, 2006 Share Posted September 7, 2006 I'm determined to get this sorted for you...Forget all the previous stuff, lets go from scratch as it's all very confusing.[code]<?php // Get the parameters from the URL $id = $_GET['id'] $page = isset($_GET['page']) ? $_GET['page'] : '1'; // if '&page=n' (n is a number) is in the url use it, if not, default to page=1 // The following assumes that you have a user_id column in your pages table, and the columns are called 'content', 'page_id' and 'user_id' $sql = "SELECT content FROM pages WHERE page_id = '$page' AND user_id = '$id'"; $result = mysql_query($sql); // We should only have one row returned, so mysql_fetch_row should be fine here $content = mysql_fetch_row($result); // Check we found a page with the page_id that was given to us and output accordingly if ($content){ echo $content[0]; else { echo "No record was found for Page ID $page"; }?>[/code]Now this is assuming quite a lot, but this simple bit of code should work fine and you should be able to build whatever you need around it.RegardsRich Quote Link to comment Share on other sites More sharing options...
Mutley Posted September 7, 2006 Author Share Posted September 7, 2006 Hurah! Finally, I've tested it and it works. Brilliant.I would really like to thank everyone that has got me through this problem. Thanks Rich. :) Quote Link to comment Share on other sites More sharing options...
HuggieBear Posted September 7, 2006 Share Posted September 7, 2006 No problem my friend, no problem at all.Rich Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.