Insert query results in just a blank page

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
drayarms
Forum Contributor
Posts: 134
Joined: Fri Dec 31, 2010 5:11 pm

Insert query results in just a blank page

Post by drayarms »

The form below is meant to retrieve the named attribute of a form input called "limitedtextfield" , along side the current date and store those values in a database. The form contains some javascript which can be disregarded for this particular problem.

Code: Select all


<form name="mymind" style= "position:relative;left:40px;" action="insert_status.php" method="post">

					<input  name="limitedtextfield" type="text" onKeyDown="limitText(this.form.limitedtextfield,this.form.countdown,55);" 

					onKeyUp="limitText(this.form.limitedtextfield,this.form.countdown,55);" maxlength="55"><br>

					<font size="1">(Maximum characters: 55)<br>

					You have <input readonly type="text" name="countdown" size="3" value="55"> characters left.</font>

					<input type="hidden" name="submitted" value="TRUE"/>

					<input style="position:relative;left:0px;bottom:0px;" type="submit" name="submit" value="Submit!" />

					</form>


Here is the php script that processes the form. What it is meant to do is search the database and if no record is found for the authenticated member, input the relevant values into the database. If a record is found, it should update the record. Well every time I hit the submit button, all I get is a blank page. Any clue as to what is going wrong?

PS: I checked the database and no values got inserted.

Code: Select all


<?php

//address error handling

ini_set ('display_errors', 1);
error_reporting (E_ALL & ~E_NOTICE);


//authenticate user
require('auth.php');

//Connect to database
require ('config.php');
	



if (isset($_POST['submitted'])) {

	$query = "SELECT* FROM publications WHERE member_id ='".$_SESSION['id']."' AND cartegory='status'";
        $result = @mysql_query($query);
        $num = @mysql_num_rows($result);
       
        if ($num> 0) {

		$update = mysql_query("UPDATE publications SET publication = '{$_POST['limitedtextfield']}' WHERE member_id = '".$_SESSION['id']."' AND cartegory = 'status'"); 
		
		header("Location: member.php");
            
        } else {

	
	
        	$query = "INSERT INTO publications ( member_id, publication, cartegory, pub_date)

		 	VALUES ( '{$_SESSION['id']}','{$_POST['limitedtextfield']}', 'status', NOW() )";

			
		header("Location: member.php");
            

	}

}



?>
 
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: Insert query results in just a blank page

Post by social_experiment »

Code: Select all

$query = "INSERT INTO publications ( member_id, publication, cartegory, pub_date)

                        VALUES ( '{$_SESSION['id']}','{$_POST['limitedtextfield']}', 'status', NOW() )";
mysql_query($query);
You are not executing the query. It needs to be inside the function mysql_query().
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Post Reply