ID:181137
 
if($_GET["blog"]) {
if(mysql_query("SELECT * FROM blog_post WHERE author = '".$_GET["blog"]."'")) { presentblog($_GET["postid"]);}
else { return;}
}


Keeps entirely crashing the page if the mysql_query() does not go through. It won't simply return in any other case. Ideas?

presentblog() function has no errors and works fine, so I know for a fact that isn't the error.
Is that part of a function, or an entire script?
In response to Murrawhip
This is just a stand-alone portion of the code. Everything prior and after works perfect. Basically, what happens is this:

If I use http://website.com/index.php?blog=cauti0n, then it would work because my blog is on there already. I already have a post set up. However, if I go http://website.com/index.php?blog=unknownuser, then it will not work, because unknownuser either does not exist, or has never made a blog post yet. When it does not work, instead of just returning nothing (as it should), it completely shuts down the page and this appears:

ERROR

The requested URL could not be retrieved

While trying to process the request:

GET /MyLoginSystem/index.php?blog=unknownuser HTTP/1.1
Host: johnnytest.host22.com
Proxy-Connection: keep-alive
User-Agent: Mozilla/5.0 (Windows NT 5.1) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.112 Safari/534.30
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
Cookie: users_res=1280x1024

The following error was encountered:

Invalid Response


The actual code I am using for the presentblog() function is shown below, if it helps.

function presentblog($postid) {
$query = null;
if($postid) {
$query = "SELECT * FROM blog_post
WHERE author = '".$_GET["blog"]."' AND blog_post_id = '".$_GET["postid"]."'
ORDER BY blog_post_id DESC";
}
if(!$postid) {$query = "SELECT * FROM blog_post
WHERE author = '".$_GET["blog"]."'
ORDER BY blog_post_id DESC"; }
if(!mysql_query($query)) {
echo "<div id=\"blogpost\">";
echo "<span id=\"blogtitle\"><h1 style=\"text-align:center;\">Welcome to ".$_GET["blog"]."'s blog!</h1></span>";
echo "<div><br /><span id=\"blogcontent\">Come back later!</span></div>
</html><html>
<br />";
echo "<small>By: CauTi0N";
die();
}
else { $query = mysql_query($query);}
$row = mysql_fetch_assoc($query);
if(!$row['title'] || !$row['content']) {presentblog(null); return;}
//while($row = mysql_fetch_assoc($query)) {
echo "<div id=\"blogpost\">";
echo "<span id=\"blogtitle\"><h1 style=\"text-align:center;\">".$row['title']."</h1></span>";
echo "<div><br /><span id=\"blogcontent\">".closetags($row['content'])."</span></div>
</html><html>
<br />";
echo "<small>By: ".$row['author']. " - Date: ".$row['date'];
if($row['edit_date']) {echo " - Edited: ".$row['edit_date']; }
if($_SESSION["username"] == $row['author']) {echo " - <a href=\"http://johnnytest.host22.com/MyLoginSystem/index.php?blog=".$_GET["blog"]."&blog_edit=".$row['blog_post_id']."\">Edit Post</a> | <a href=\"http://johnnytest.host22.com/MyLoginSystem/index.php?blog=".$_GET["blog"]."&blog_del=".$row['blog_post_id']."\">Delete Post</a></small>";}
}
In response to CauTi0N
Hm, it's fixed. I realized I was missing a die() command in presentblog. Though, I still have no idea why it continues to go through when it definitely should not be going through -_-
In response to CauTi0N
Recommend looking into Smarty to separate that HTML from your PHP. Makes life so much easier, believe me.
In response to CauTi0N
Caution, how do you understand all of that?...I tried working with SQL, PHP, etc. I gave up. I was successful in installing everything I needed to utilize these features...and that's about it.
In response to OrangeWeapons
OrangeWeapons wrote:
Caution, how do you understand all of that?...I tried working with SQL, PHP, etc. I gave up. I was successful in installing everything I needed to utilize these features...and that's about it.

It's just like everything else, you have to do it for a bit to learn it. :P