Jump to content

While Loop Shows Blank Screen


Tenaciousmug

Recommended Posts

Ok, the sql seems to  be working fine, but when I go into the while loop, it gives me an internal error 500 and doesn't load anything. It just shows me a blank white screen:

 

$sql = "SELECT alertID,alertName,alertMessage,activateSubj,activateBody,deactivateSubj,deactivateBody FROM alerts ORDER BY alertName";
$result = mysqli_query($cxn, $sql) or die(mysqli_error());
while ($row = mysqli_fetch_assoc($result))
{
$alertID = $row['alertID'];
$alertName = stripcslashes($row['alertName']);
$alertMessage = stripcslashes($row['alertMessage']));
$activateSubj = stripcslashes($row['activateSubj']));
$activateBody = stripcslashes($row['activateBody']));
$deactivateSubj = stripcslashes($row['deactivateSubj']));
$deactivateBody = stripcslashes($row['deactivateBody']));

<div class="alert" style="border:1px solid #000;border-radius:5px;padding:12px;">
	echo $alertID."<br />";
	echo $alertName."<br />";
	echo $alertMessage."<br />";
	echo $activateSubj."<br />";
	echo $activateBody."<br />";
	echo $deactivateSubj."<br />";
	echo $deactivateBody."<br />";
</div>
}

Link to comment
Share on other sites

Oh wow... I can't believe I did that. I'm sorry. I never did that before. I'm so retarded. xD

Here is my updated code:

 

$sql = "SELECT alertID,alertName,alertMessage,activateSubj,activateBody,deactivateSubj,deactivateBody FROM alerts ORDER BY alertName";
$result = mysqli_query($cxn, $sql) or die(mysqli_error());
while ($row = mysqli_fetch_assoc($result))
{
	$alertID = $row['alertID'];
	$alertName = stripcslashes($row['alertName']);
	$alertMessage = stripcslashes($row['alertMessage']));
	$activateSubj = stripcslashes($row['activateSubj']));
	$activateBody = stripcslashes($row['activateBody']));
	$deactivateSubj = stripcslashes($row['deactivateSubj']));
	$deactivateBody = stripcslashes($row['deactivateBody']));

	echo "<div class=\"alert\" style=\"border:1px solid #000;border-radius:5px;padding:12px;\">";
		echo $alertID."<br />";
		echo $alertName."<br />";
		echo $alertMessage."<br />";
		echo $activateSubj."<br />";
		echo $activateBody."<br />";
		echo $deactivateSubj."<br />";
		echo $deactivateBody."<br />";
	echo "</div>";
}

 

Still giving me a blank screen. I don't understand why no parse errors or anything will pop up like they usually do. It's giving me a rough time debugging my scripts.

Anyway, the stripcslashes() are there because I had to strip the \ from when I escaped the string when inputting it into the database with real_escape_string().

Link to comment
Share on other sites

Nevermind, PHP changed their way of showing errors. I'm looking at the error_log file. I should have been doing this the whole time. I just didn't know they didn't display them right in the browser anymore.

Thanks!

I was adding an extra ")" onto the variables I was creating in the while loop.

Link to comment
Share on other sites

Anyway, the stripcslashes() are there because I had to strip the \ from when I escaped the string when inputting it into the database with real_escape_string().

 

:facepalm: Um, no. mysql_real_escape_string() will add slashes to certain characters to prevent them from being interpreted as non-data characters. but, the actual content that is stored in the database is the content as it existed before mysql_real_escape_string().

Link to comment
Share on other sites

Nevermind, PHP changed their way of showing errors. I'm looking at the error_log file. I should have been doing this the whole time. I just didn't know they didn't display them right in the browser anymore.

Thanks!

I was adding an extra ")" onto the variables I was creating in the while loop.

 

PHP displays errors however its configured to display them in the php.ini file.

 

And if you have escaping slashes being stored with your data, something is wrong with the way the data is being inserted to begin with.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.