Help with a blank php page?

I run a fantasy basketball league. My php / sql database is designed to allow a person working in a team to do everything through the site - they can refuse the player and the player will automatically go to the FA pool, etc.

Everything worked fine about a week ago. At any time when the team is about to sign the player, after clicking "Register" they get a blank PHP page. I have no idea why - I did not make any changes to any files. This is just the beginning. Below is the code for a blank PHP page - can someone help?

<?php $username = "me"; $password = "mypassword"; $database = "mydatabase"; mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $Team_Offering = $_POST['Team_Name']; $Fields_Counter = $_POST['counterfields']; $Roster_Slots = $_POST['rosterslots']; $Healthy_Roster_Slots = $_POST['healthyrosterslots']; $Type_Of_Action = $_POST['Action']; $queryt="SELECT * FROM nuke_ibl_team_info WHERE team_name = '$Team_Offering' "; $resultt=mysql_query($queryt); $teamid=mysql_result($resultt,0,"teamid"); $Timestamp = intval(time()); // ADD TEAM TOTAL SALARY FOR THIS YEAR $querysalary="SELECT * FROM nuke_iblplyr WHERE teamname = '$Team_Offering' AND retired = 0 "; $results=mysql_query($querysalary); $num=mysql_numrows($results); $z=0; while($z < $num) { $cy=mysql_result($results,$z,"cy"); $cyy = "cy$cy"; $cy2=mysql_result($results,$z,"$cyy"); $TotalSalary = $TotalSalary + $cy2; $z++; } //ENT TEAM TOTAL SALARY FOR THIS YEAR $k=0; $Salary=0; while ($k < $Fields_Counter) { $Type=$_POST['type'.$k]; $Salary=$_POST['cy'.$k]; $Index=$_POST['index'.$k]; $Check=$_POST['check'.$k]; $queryn="SELECT * FROM nuke_iblplyr WHERE pid = '$Index' "; $resultn=mysql_query($queryn); $playername=mysql_result($resultn,0,"name"); $players_team=mysql_result($resultn,0,"tid"); if ($Check == "on") { if ($Type_Of_Action == "drop") { if ($Roster_Slots < 4 and $TotalSalary > 7000) { echo "You have 12 players and are over $70 mill hard cap. Therefore you can't drop a player! <br>You will be automatically redirected to <a href=\"http://www.chibul.com/iblv2\">the main IBL page</a> in a moment. If you are not redirected, click the link."; }else{ $queryi = "UPDATE nuke_iblplyr SET `ordinal` = '1000', `droptime` = '$Timestamp' WHERE `pid` = '$Index' LIMIT 1;"; $resulti=mysql_query($queryi); $topicid=32; $storytitle=$Team_Offering." make waiver cuts"; $hometext="The ".$Team_Offering." cut ".$playername." to waivers."; // ==== PUT ANNOUNCEMENT INTO DATABASE ON NEWS PAGE $timestamp=date('Ymd H:i:s',time()); $querycat="SELECT * FROM nuke_stories_cat WHERE title = 'Waiver Pool Moves'"; $resultcat=mysql_query($querycat); $WPMoves=mysql_result($resultcat,0,"counter"); $catid=mysql_result($resultcat,0,"catid"); $WPMoves=$WPMoves+1; $querycat2="UPDATE nuke_stories_cat SET counter = $WPMoves WHERE title = 'Waiver Pool Moves'"; $resultcat2=mysql_query($querycat2); $querystor="INSERT INTO nuke_stories (catid,aid,title,time,hometext,topic,informant,counter,alanguage) VALUES ('$catid','Associated Press','$storytitle','$timestamp','$hometext','$topicid','Associated Press','0','english')"; $resultstor=mysql_query($querystor); echo "<html><head><title>Waiver Processing</title> </head> <body> Your waiver moves should now be processed. <br>You will be automatically redirected to <a href=\"http://www.chibul.com/iblv2\">the main IBL page</a> in a moment. If you are not redirected, click the link. </body></html>"; } } else { if ($players_team == $teamid) { $queryi = "UPDATE nuke_iblplyr SET `ordinal` = '800', `teamname` = '$Team_Offering', `tid` = '$teamid' WHERE `pid` = '$Index' LIMIT 1;"; $resulti=mysql_query($queryi); $Roster_Slots++; $topicid=33; $storytitle=$Team_Offering." make waiver additions"; $hometext="The ".$Team_Offering." sign ".$playername." from waivers."; // ==== PUT ANNOUNCEMENT INTO DATABASE ON NEWS PAGE $timestamp=date('Ymd H:i:s',time()); $querycat="SELECT * FROM nuke_stories_cat WHERE title = 'Waiver Pool Moves'"; $resultcat=mysql_query($querycat); $WPMoves=mysql_result($resultcat,0,"counter"); $catid=mysql_result($resultcat,0,"catid"); $WPMoves=$WPMoves+1; $querycat2="UPDATE nuke_stories_cat SET counter = $WPMoves WHERE title = 'Waiver Pool Moves'"; $resultcat2=mysql_query($querycat2); $querystor="INSERT INTO nuke_stories (catid,aid,title,time,hometext,topic,informant,counter,alanguage) VALUES ('$catid','Associated Press','$storytitle','$timestamp','$hometext','$topicid','Associated Press','0','english')"; $resultstor=mysql_query($querystor); echo "<html><head><title>Waiver Processing</title> </head> <body> Your waiver moves should now be processed. <br>You will be automatically redirected to <a href=\"http://www.chibul.com/iblv2\">the main IBL page</a> in a moment. If you are not redirected, click the link. </body></html>"; } else { if ($Healthy_Roster_Slots < 4 and $TotalSalary + $Salary > 7000) { echo "You have 12 or more healthy players and this signing will put you over $70. Therefore you can not make this signing. <br>You will be automatically redirected to <a href=\"http://www.chibul.com/iblv2\">the main IBL page</a> in a moment. If you are not redirected, click the link."; } elseif ($Healthy_Roster_Slots > 3 and $TotalSalary + $Salary > 7000 and $Salary > 103) { echo "You are over the hard cap and therefore can only sign players who are making veteran minimum contract! <br>You will be automatically redirected to <a href=\"http://www.chibul.com/iblv2\">the main IBL page</a> in a moment. If you are not redirected, click the link."; } elseif ($Healthy_Roster_Slots < 1) { echo "You have full roster of 15 players. You can't sign another player at this time! <br>You will be automatically redirected to <a href=\"http://www.chibul.com/iblv2\">the main IBL page</a> in a moment. If you are not redirected, click the link."; } else { $queryi = "UPDATE nuke_iblplyr SET `ordinal` = '800', `bird` = '0', `cy` = '1', `cy1` = '$Salary', `teamname` = '$Team_Offering', `tid` = '$teamid' WHERE `pid` = '$Index' LIMIT 1;"; $resulti=mysql_query($queryi); $Roster_Slots++; $topicid=33; $storytitle=$Team_Offering." make waiver additions"; $hometext="The ".$Team_Offering." sign ".$playername." from waivers."; // ==== PUT ANNOUNCEMENT INTO DATABASE ON NEWS PAGE $timestamp=date('Ymd H:i:s',time()); $querycat="SELECT * FROM nuke_stories_cat WHERE title = 'Waiver Pool Moves'"; $resultcat=mysql_query($querycat); $WPMoves=mysql_result($resultcat,0,"counter"); $catid=mysql_result($resultcat,0,"catid"); $WPMoves=$WPMoves+1; $querycat2="UPDATE nuke_stories_cat SET counter = $WPMoves WHERE title = 'Waiver Pool Moves'"; $resultcat2=mysql_query($querycat2); $querystor="INSERT INTO nuke_stories (catid,aid,title,time,hometext,topic,informant,counter,alanguage) VALUES ('$catid','Associated Press','$storytitle','$timestamp','$hometext','$topicid','Associated Press','0','english')"; $resultstor=mysql_query($querystor); echo "<html><head><title>Waiver Processing</title> </head> <body> Your waiver moves should now be processed. <br>You will be automatically redirected to <a href=\"http://www.chibul.com/iblv2\">the main IBL page</a> in a moment. If you are not redirected, click the link. </body></html>"; } } } } $k++; } ?> 
+1
source share
10 answers

Put the following rights after the open PHP tag:

 error_reporting(E_ALL); ini_set('display_errors', 'On'); 

If this does not work, there may be a parsing error and you will need to check the error log.

You will also need to avoid the values โ€‹โ€‹that you specify in the queries. This may cause the MySQL query to fail. If someone puts " in $ _POST ['Team_Name'], your first request may fail.

Another final possible problem: are you sure that it can still connect to MySQL?

The option to find the problem is to comment on large parts of the code, and then in parts of the uncommenting sectons.

Edit: So your first problem is the mysql_connect line. It needs to be changed, pay attention to the quotation marks: mysql_connect('localhost',$username,$password); In addition, the variable $result and $queryt spelled incorrectly in this line and are used in their correct spelling: $resultt=mysql_query($queryt); I did not check the rest, but there may be other errors that will lead to the break of your script. Some of the error lists are important to fix, but will not break your script.

Escaping: Browse the following page: http://php.net/manual/en/function.mysql-escape-string.php This basically prevents people from deleting your entire database.

Check the sample code on this page to find out how to connect to MySQL and see if you are connected.

Another suggestion: Are you sure none of your queries work? You probably want to check if the query result is false before continuing, for example:

 if ($resultcat2 === false) { trigger_error('query failed ' . $sql, E_USER_ERROR); echo 'Sorry, there was a problem processing your request. Please try again later.'; exit; } 
+11
source

Include an error report for PHP in your php.ini file and see if any errors or warnings are being reported. Also try removing trailing spaces at the end of the file to the last? > This has caused problems in the past.

+2
source

Comments have been added to some of the answers above. Please try to commit suicide as deep as possible - I am very unfamiliar with this. I canโ€™t understand why it suddenly stops working, although when I didnโ€™t make any changes to the code.

+2
source

If you didnโ€™t make any changes to any files, but simply โ€œbrokeโ€, this would mean that your web host went through a configuration change, your database was somehow closed, or that someone else had something changed.

To help identify the culprit, after each of these

 if{ else{ while{ 

and / or after every few statements (ending with semicolons;) add this to the next line

 print "<br> made it to this label: some_unique_label_name_here"; 

Where you should replace the label every time to help you trace the code. This will be your first step in debugging a script to find out how far code execution takes.

+2
source

Without looking at my code in too much detail, I suggest you look for any sections that may loop for a long time without returning

0
source

After you enable the error report, be sure to add the else statements that correspond to all your if statements so that you can determine whether these statements run or not. Throw some echoes.

0
source

Also, to clarify - I probably have three dozen PHP files on the site - this is ONLY that stops working.

0
source

Here I got ... everything below the print line will not appear if I put a print line under it. A.

 $k=0; $Salary=0; print "<br> made it to this label: some_unique_label_name_here"; while ($k < $Fields_Counter) { $Type=$_POST['type'.$k]; $Salary=$_POST['cy'.$k]; $Index=$_POST['index'.$k]; $Check=$_POST['check'.$k]; $queryn="SELECT * FROM nuke_iblplyr WHERE pid = '$Index' "; $resultn=mysql_query($queryn); $playername=mysql_result($resultn,0,"name"); $players_team=mysql_result($resultn,0,"tid"); 
0
source

As an aside, you must change each variable from get or post, for example:

 $Team_Offering = $_POST['Team_Name']; 

to

 $Team_Offering = mysql_real_escape_string($_POST['Team_Name']); 

before using it in mysql query, otherwise you can resort to SQL injection attacks.

0
source

So update ... nothing. lol

If you look at this code:

 $k=0; 

$ s = 0;

print "
did it on this shortcut: some_unique_label_name_here ";

while ($ k <$ Fields_Counter)

{

$ Type = $ _ POST ['type' $ k.];

$ Income = $ _ POST ['CY' $ k.];

$ Index = $ _ POST ['index' $ k.];

$ Check = $ _ POST ['check' $ k.];

$ queryn = "SELECT * FROM nuke_iblplyr WHERE pid = '$ Index'"; $ Resultn = mysql_query ($ queryn);

$ PlayerName = mysql_result ($ resultn, 0, "name");

$ players_team = mysql_result ($ resultn, 0, "TID");

If I put the print instruction below, the page will be blank and it will not appear. If the print expression is previously shown, the expression appears, but no action is taken on the page. The end result is that when you start this page, the player selected on the previous page must be removed from Free Agents, added to the user team, and the story should be published on the first page announcing this. Obviously, none of them are happening here.

0
source

Source: https://habr.com/ru/post/894359/


All Articles