Forum Moderators: coopster

Message Too Old, No Replies

Blank page.

Is all I am getting

         

Ben878

10:21 pm on Feb 7, 2008 (gmt 0)

10+ Year Member



I am having some real trouble with mysql. The page just shows up as blank, any idea whats going on, I feel like it will be such a basic error.

<?php
$con = mysql_connect("localhost","","");
if (!$con)
{
echo "8";
}


mysql_select_db("897897", $con);
error_reporting(E_ALL);


$check_if_got_award = mysql_query("SELECT ID_MEMBER , ID_AWARD FROM smf_awards_members WHERE ID_MEMBER=$zx35 AND ID_AWARD=$awardid") or die(mysql_error());


while ($row = mysql_fetch_assoc($check_if_got_award))
{
if(mysql_num_rows($check_if_got_award)==0)
{
$give_award = mysql_query("SELECT ID_MEMBER FROM smf_awards_members WHERE ID_MEMBER=$zx35") or die(mysql_error());
while ($row = mysql_fetch_assoc($give_award))
{
if ($row['ID_MEMBER']==$zx35)
{
mysql_query("INSERT INTO smf_award_members (ID_AWARD , ID_MEMBER)
VALUES ($awardid, $zx35") or die(mysql_error());
echo '1';
}
}
}
}


if(mysql_num_rows($check_if_got_award)!==0)
{
echo '5';
}


mysql_close($con);
?>

[edited by: Ben878 at 10:24 pm (utc) on Feb. 7, 2008]

[edited by: eelixduppy at 10:44 pm (utc) on Feb. 7, 2008]

whoisgregg

10:54 pm on Feb 7, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The first thing to do is to add some debugging code to your page. Immediately following the opening <?php tag, add these lines:

ini_set("display_errors", "on");
ini_set("error_reporting", E_ALL);

If you still have a completely blank page, then there is a parse error somewhere. In other words, a missing semicolon, mismatched () or {}, or perhaps an invisible character.

A good approach to that situation is to add something at the top of your code like

echo 'Hi!';
and remove entire blocks of code until you can get that message to appear. Then add back in your code in smaller chunks until the message disappears. Whichever block of code you added back in last is causing the problem, look carefully at that block to find the cause.

These two threads are good reads as well:
Troubleshooting 101 revisited [webmasterworld.com]
Troubleshooting [webmasterworld.com]

Ben878

11:31 pm on Feb 7, 2008 (gmt 0)

10+ Year Member



ok... Thanks, I haven't solved it sadly. But with you help I have managed to narrow it down.

Now this appears to be the only problem:


if(mysql_num_rows($check_if_got_award)==0)
{
$give_award = mysql_query("SELECT ID_MEMBER FROM smf_awards_members WHERE ID_MEMBER=$zx35");
while ($row = mysql_fetch_assoc($give_award))
{
if ($row['ID_MEMBER']==$zx35)
{
mysql_query("INSERT INTO smf_award_members VALUES (ID_AWARD , ID_MEMBER);
VALUES ($awardid, $zx35");
echo '1';
}
}
}

If the query $check_if_got_award returns 0 I get a blank page. However if a query returns something other than 0 it works as it is meant to. :) So basically it is jsut this section of code that is messing up.

phnord

2:44 pm on Feb 8, 2008 (gmt 0)

10+ Year Member



Check the value of $check_if_got_award. The mysql_query() function returns FALSE if there is an error with your query. The function mysql_num_rows() only takes a resource object. So if you are sending a boolean value or anything else, it will break your application.

Also, if you get blank pages and you have access to your log files, the answer will be in your error log. (error.log if you are using apache) An error may be occurring before your ini setting calls.

whoisgregg

7:29 pm on Feb 10, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



These lines aren't quite right... There shouldn't be two VALUES blocks and the nesting of quotes and parentheses isn't balanced...

mysql_query("INSERT INTO smf_award_members VALUES (ID_AWARD , ID_MEMBER); 
VALUES ($awardid, $zx35");

Try replacing those two lines with this one line:

mysql_query("INSERT INTO smf_award_members (`ID_AWARD`, `ID_MEMBER`) VALUES ($awardid, $zx35);");