Page 1 of 1

blank HTML displaying from simple script. [solved]

Posted: Sat Sep 22, 2007 7:56 pm
by lafflin
Hello good people,

I have started a script, to allow for deleting related records from my DB. What the sript does really doesn't matter though, the issue is that
when this script is called via a link from another page where the url is assembled from a variable it displays nothing. The URL is as it should be:

http://localhost/Studio_manager/act_delete.php?sid=91

When I look at the source HTML I see:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=windows-1252"></HEAD>
<BODY></BODY></HTML>

I have just added some text to my external include file which serves as an HTML header.

The script isn't running at all. Yet I'm not getting a 404 error or anything like that. I recently changed my PHP.ini setting to show all errors.
All my other scripts are running fine.

There is most likely something very obvious that is wrong with this script, but I'm not seeing it.

Any help is greatly appreciated.

I'm going to try restarting my pc. I'm so lost!

here's the script

Code: Select all

<?php


require_once ('./includes/mysql_connect.php');
require_once ('./includes/functions.php') ;
include ('./includes/header_footer/header.inc.htm');

$page_title = 'deleting the student';

echo '<p>the script is running</p>';


if $_SESSION['sid'] == $_GET['sid'] {    //----IF THIS PAGE WAS REACHED INTENTIONALLY-------------------                       1




$s_nfo_query = 

          "SELECT
		     
		         sid,
			     first_name,
				 last_name,
			     sex,
				 reg_date,
				 dob, 
			     school, 
				 active, 
				 medical_issues,  
			     secret_classification, 
			     last_update,
				 pid   
			   
		   FROM 
		       student_info
		   LEFT JOIN
		        student_parent
		   USING
		        (sid)
		   LEFT JOIN 
		        parent_info
		   USING
		        (pid)		   
		   WHERE
		       (student_info.sid = '".$_GET['sid']."' ) " ;
			   
$result = mysql_query($s_nfo_query) or die(mysql_error()."[sql:$s_nfo_query]");
			 
	$s_nfo = mysql_fetch_assoc($result);
	
	//-------------------CHECK TO SEE IF THIS PARENT HAS ANOTHER STUDENT ASSOCIATED WITH IT-------------
                         $p_nfo_query ="
                                    SELECT
									        sid,
											first_name,
											last_name
									FROM
									       	student_info
									LEFT JOIN
									        student_parent
									USING  
									        (sid)
									WHERE
									       ( pid = '".$s_nfo['pid']."') 
									AND
									       ( student_info_sid != '".$result['sid']." ) ";
											
				$result1 = mysql_query($p_nfo_query) or die(mysql_error()."[sql:$p_nfo_query]");
				
				if ($result1>1) {	
				                    
									$delete_s_p = "
	                 DELETE
                                student_info ,
                                student_parent 
                              
                               
                      FROM
                                student_info ,
                                student_parent 
                                 
                              
                      WHERE
                                student_info.sid = student_parent.sid
                    
                      AND 

						        student_info.sid = ".$result['sid']."  ";
	  
	        $deleted_s_p =mysql_query(delete_s_p) or die(mysql_error()."[sql:$delete_s_p]");
			
			
			     
				  IF ($deleted_s_p) {
				  
	$delete_c_s1 = "
	
	           DELETE 
			      classes_students
			   WHERE 
			       sid = ".$result1['sid']."  ";
				   
				   
				   
	 $deleted_c_s1 =mysql_query(delete_c_s1) or die(mysql_error()."[sql:$delete_c_s1]");
	 
				                
								
				                      
	echo" <div align =\"center\">the student ".$result['first_name'] ." ". $result['first_name']." Has been deleted
								 from your records. \n
								 This student's parent will remain in your records because there is atleast one other student \n
								 in your records that is registered with this parent. If you would like to delete this parent's record \n
								 from your records then you must delete the associated student. When you delete the last student \n
								 associated with this parent the parent's record will automatically be deleted.
								 If an error was made when entering a student or parents information and you find yourself \n
								 in a situation where you need to associate the parent to a different student then you may retrieve \n
								 all of the neccesary information from your email to re-enter it as it was stored in your records. \n
								 Any record, student or parent, is emailed to you upon being deleted from your records. \n\n\n\n
								  
								  The following student(s) are registered with this same student's parent" ;
								  
								  				
					while ($result1 = mysql_fetch_array($result1, MYSQL_ASSOC)  {
					
					   echo" ".$result1['sid']." </div>" ; }
								   
                               
							   }
							      }  else {  //----------------IF THIS IS RECORD HAS NO SIBLINGS IN DB------
						
  						
$delete_s_p2 = "
	                 DELETE
                                student_info ,
                                student_parent ,
                                parent_info 
                               
                      FROM
                                student_info ,
                                student_parent ,
                                parent_info 
                              
                      WHERE
                                student_info.sid = student_parent.sid
                      AND
                                student_parent.pid=parent_info.pid
                      AND 

						        student_info.sid = ".$result['sid']."  ";
	  
	        $deleted_s_p2 =mysql_query(delete_s_p2) or die(mysql_error()."[sql:$delete_s_p2]");
			     
				  IF ($deleted_s_p2) {
				  
	$delete_c_s2 = "
	
	           DELETE 
			      classes_students
			   WHERE 
			       sid = ".$result1['sid']."  ";
				   
				   
	 $deleted_c_s2 =mysql_query(delete_c_s2)  or die(mysql_error()."[sql:$delete_c_s2]");
	 
	       if ($deleted_c_s2) {   
		                           echo " the student ".$result['first_name'] ." ". $result['first_name']." Has been deleted
								           from your records along with any associated data and records.\n" ;
	   
								
                 						  }
	                                         }
								  
					
                                                 } //-----------------END ELSE STATEMENT-----------
 
     
 }  //-----------END OF IF PAGE WAS REAHED INTENTIONALLY----------                                                               1
     else { 
	 
	         // Redirect the user to the next page.
				// Start defining the URL.
				$url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']);
				
				// Check for a trailing slash.
				if ((substr($url, -1) == '/') OR (substr($url, -1) == '\\') ) {
					$url = substr ($url, 0, -1); // Chop off the slash.
				}
				
				// Add the page.
				$url .= '/index.php';
				
				header("Location: $url");
				exit();                     }  //------------END REDIRECT
		
 
   include ('./includes/header_footer/footer.inc.htm');


?>

Posted: Sat Sep 22, 2007 8:00 pm
by lafflin
Wow, sorry it looks like that, I code in DW and use alot of white space to keep it neat. In anycase, whatever is creating the issue it's something major, not the misspelling of a variable or anything, the script isn't running at all so it's probably useless even posting it.

Posted: Sat Sep 22, 2007 8:12 pm
by feyd
From a quick look through I see at least one parse error (the first if) and several notices about unknown constants (missing "$" on a few variable references.)

Posted: Sat Sep 22, 2007 9:05 pm
by lafflin
Ok, I appreciate it. I corrected those issues, but still the script doesn't run at all. I have to come to the conclusion that the changes that I made to my PHP.ini did me in. I'm using WAMP, anyone know of a way to reset the file to all it's defaults, or where to get a copy of a default php.ini without having to reinstall it. Actually I'm pretty sure that I changed the settings in that file correctly, but I think I changed some other setting on the WAMP menu (in my system tray) but I have no idea what it was, anyone know what setting would cause a script not to run at all if it finds errors or anything like that?

Posted: Sat Sep 22, 2007 10:27 pm
by lafflin
ok, so it seems that there is an error in this script somewhere which is keeping any of it from being run. The queries are not running and no HTML output is being returned. I have commented out most of the script and echoed hello world and I can see the words. Yet when the script runs as it is posted, I don't even see the background image which is defined in my HTML include.

So myquestion is what type of error would produce a blank HTML page with no errors at all? error reporting is on in my php.ini, I thought I turned it to the most sensative setting e-strict i believe it was, I have to go look into that.

Posted: Sat Sep 22, 2007 10:28 pm
by feyd
If you download the zip version of php, it includes several initialization file variants.

I would guess you aren't displaying errors, or don't have error reporting set high enough. Error reporting should be "E_ALL," or sometimes "E_ALL | E_STRICT" during development (and production, in my opinion.)

Posted: Sat Sep 22, 2007 11:36 pm
by lafflin
wow, so what it was was error reporting was turned off. Which was a mistake I made thinking the little arrows on the php settings menu in WAMP meant that more option would expand out from the menu, as it turns out it the little arrows indicate that a service or setting is turned on.
That one was frusterating. Thanks Feyd. Your avitar is frightening, looks like one of the dudes from Gwar.