when submitting a form php code comes up blank

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • anfetienne
    Contributor
    • Feb 2009
    • 424

    when submitting a form php code comes up blank

    hi guys,

    as i previously posted I have a php code that i made to use generically to submit comments posted on certain pages... for some reason when i try post to the script it comes up blank... doesn't process or anything and i cant figure this out... can someone point me in the right direction? thanks in advance

    here is my form code:
    Code:
    <form method="POST" action="tstatusDB.php" >
                            <div align="center">
                              <input type="text" name="commentC" id="commentC" class="style6" value="whats on your mind?" size="20" onclick="this.value=''"/>
                              <input type="hidden" name="userName" id="userName" value="<?php print $userName;?>"/>
                 			  <input type="hidden" name="userAV" id="userAV"value="<?php print $userAV;?>"/>
                 			  <input type="hidden" name="commentID" id="commentID"value="<?php print $commentID;?>"/>
               				  <input type="hidden" name="firstName" id="firstName" value="<?php print $firstName;?>"/>
                		 	  <input type="hidden" name="lastName" id="lastName" value="<?php print $lastName;?>"/>
                 			  <input type="hidden" name="dateAdded" id="dateAdded" value="<?php print $dateAdded;?>"/>
                 			  <input type="hidden" name="formLocation" id="formLocation" value="tstatusUpdate"/>
                              <input type="submit" name="submit" value="submit" />
                            </div>
                          </form>
    here is my php script:
    Code:
    <? error_reporting(E_ALL);
    include ("admin-dbcon.php");
    
    	$comment= $_POST['commentC'];
    	$userName= $_POST['userName'];
    	$userAV= $_POST['userAV'];
    	$commentID= $_POST['commentID'];
    	$firstName= $_POST['firstName'];
    	$lastName= $_POST['lastName'];
    	$dateAdded= $_POST['dateAdded'];
    	$formLocation= $_POST['formLocation'];
    	
    	mysql_connect($hostname,$username,$password);
    	@mysql_select_db($database) or die( "Unable to select database");
    
    	$sql = "SELECT * FROM statusUpdates WHERE commentID = '{$commentID}'";
    	$res = mysql_query( $sql ) or die( mysql_error );
     
    	if ( mysql_num_rows( $res ) > 0 ){
    
    		$result = mysql_query("SELECT * FROM lastComment WHERE commentID = '{$commentID}'");
    		$rowA = mysql_fetch_array( $result );
    		$i=$rowA['lastDigit'];
    		$i= $i+1;
    		$lastDigit= $i;
    
    	$queryA="INSERT INTO statusUpdates (userName,userAV,firstName,lastName,commentID,comment,dateAdded,comOrder)
    	        VALUES ('".$userName."','".$userAV."','".$firstName."','".$lastName."','".$commentID."','".$comment."','".$dateAdded."','".$i++."')";
    	}
    	
    else {
    $i=1;
    
    $queryA="INSERT INTO statusUpdates (userName,userAV,firstName,lastName,commentID,comment,dateAdded,comOrder)
    
    VALUES ('".$userName."','".$userAV."','".$firstName."','".$lastName."','".$commentID."','".$comment."','".$dateAdded."','".$i++."')";
    	}
    	$resultA=mysql_query($queryA) or die("Error in query:".mysql_error()); 
    	//if ($result) 
    	    //echo mysql_affected_rows()." row inserted into the database effectively."; 
    		
    		
    	
    	$sqlB = "SELECT * FROM lastComment WHERE commentID = '{$commentID}'";
    	$resB = mysql_query( $sqlB ) or die( mysql_error );
     
    	if ( mysql_num_rows( $resB ) > 0 ){
    
    		$i=$lastDigit;
    
    	$queryB="UPDATE lastComment SET 
    		    lastDigit='{$i}' 
    			WHERE commentID= '{$commentID}'";
    	}
    	else {
    	$i=1;
    	$queryB="INSERT lastComment (commentID,lastDigit)
    
    	        VALUES(	
    	            '$commentID',
    				'$i')";
    	}
    	$resultB=mysql_query($queryB) or die("Error in query:".mysql_error()); 
    	//if ($result) 
    	    //echo mysql_affected_rows()." row inserted into the database effectively."; 
    	mysql_close();
    }
    
    	echo $comment;
    	echo $userName;
    	echo $userAV;
    	echo $commentID;
    	echo $firstName=;
    	echo $lastName;
    	echo $dateAdded;
    	echo $formLocation;
    ?>
  • anfetienne
    Contributor
    • Feb 2009
    • 424

    #2
    hi,

    I have fixed my problem... here is the code for it, i've also included something i found in a tutorial for adding the time and date with daylight saving.

    Code:
    <?php
    include ("admin-dbcon.php");
    
    function zonedate($layout, $countryzone, $daylightsaving, $time)
    {
    	if($daylightsaving) {
    		 $daylight_saving = date('I');
    		if($daylight_saving){ $zone=3600*($countryzone+1); }
    	}
    	else {
    		if( $countryzone>>0){ $zone=3600*$countryzone; }
    			else { $zone=0; }
    	}
    	if(!$time) { $time = time(); }
    	$date = gmdate($layout, $time + $zone);
    	return $date;
    }
    
    	$commentC= $_POST['commentC'];
    	$userName= $_POST['userName'];
    	$userAV= $_POST['userAV'];
    	$commentID= $userName.rand(0000000000,9999999999);
    	$firstName= $_POST['firstName'];
    	$lastName= $_POST['lastName'];
    	$dateAdded = zonedate('d M Y H:i:s',true);
    	$formLocation= $_POST['formLocation'];
    
    if($formLocation == "astatusUpdate") {
    mysql_connect($hostname,$username,$password);
    @mysql_select_db($database) or die( "Unable to select database");
    
    $sql = "SELECT * FROM audioStatus WHERE commentID = '{$commentID}'";
    $res = mysql_query( $sql ) or die( mysql_error );
     
    	if ( mysql_num_rows( $res ) > 0 ){
    		$result = mysql_query("SELECT * FROM lastComment WHERE commentID = '{$commentID}'");
    		$rowA = mysql_fetch_array( $result );
    		$i=$rowA['lastDigit'];
    		$i= $i+1;
    		$lastDigit= $i;
    
    		$queryA="INSERT INTO audioStatus (userName,userAV,firstName,lastName,commentID,comment,dateAdded,comOrder)
    	    VALUES ('".$userName."',
    				'".$userAV."',
    				'".$firstName."',
    				'".$lastName."',
    				'".$commentID."',
    				'".$commentC."',
    				'".$dateAdded."',
    				'".$i++."')";
    	}
    	else {
    		$nw=1;
    
    		$queryA="INSERT INTO audioStatus (userName,
    											userAV,
    											firstName,
    											lastName,
    											commentID,
    											comment,
    											dateAdded,
    											comOrder)
    
    				VALUES ('".$userName."',
    						'".$userAV."',
    						'".$firstName."',
    						'".$lastName."',
    						'".$commentID."',
    						'".$commentC."',
    						'".$dateAdded."',
    						'".$nw++."')";
    	}
    $resultA= mysql_query($queryA) or die("Error in query:".mysql_error()); 
    //if ($result) 
    //echo mysql_affected_rows()." row inserted into the database effectively.";
    
    mysql_close();
    
    
    mysql_connect($hostname,$username,$password);
    @mysql_select_db($database) or die( "Unable to select database");
    
    $sqlB = "SELECT * FROM lastComment WHERE commentID = '{$commentID}'";
    $resB = mysql_query( $sqlB ) or die( mysql_error );
     
    	if ( mysql_num_rows( $resB ) > 0 ){
    			$nw=$lastDigit;
    
    			$queryB="UPDATE lastComment SET 
    		    	lastDigit='{$nw}' 
    				WHERE commentID= '{$commentID}'";
    	}
    	else {
    	$nw=1;
    	$queryB="INSERT lastComment (commentID,lastDigit)
    
    	        VALUES(	
    	            '$commentID',
    				'$nw')";
    				
    				echo "chk=1";
    	}
    $resultB=mysql_query($queryB) or die("Error in query:".mysql_error()); 
    //if ($result) 
    //echo mysql_affected_rows()." row inserted into the database effectively."; 
    
    mysql_close();
    }
    ?>

    Comment

    Working...