Jump to content

Why do I randomly get empty rows in my mysql table for no reason.


xerox02

Recommended Posts

Here is the part of my site that has access to my mysql tables http://excusesexcuses.net/submit1.php . I don't know why when I look at my table, I have some empty rows for no reason. It would seem impossible with the way my php is to have empty entries. When my program has a empty field, it WON't even go to mysql.

 

If people want to see the code:

<?php
$con = mysql_connect("","","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("mydatabase", $con);

require_once('recaptchalib.php');
  $privatekey = "";
  $resp = recaptcha_check_answer ($privatekey,
                                $_SERVER["REMOTE_ADDR"],
                                $_POST["recaptcha_challenge_field"],
                                $_POST["recaptcha_response_field"]);

$sql="INSERT INTO `pendingquotes` (`quotes`, `email`, `name`) VALUES('".$_POST[quotes]."','".$_POST[email]."','".$_POST[name]."')";

$quote = $_POST['quotes'];

if (!$resp->is_valid) {
    // What happens when the CAPTCHA was entered incorrectly
    die ("The reCAPTCHA wasn't entered correctly. Go back and try it again.");
  } else 
  
  {
  
if(empty($quote)) {
       // Tell them they missed a required field
   echo 'You did not write a quote.';
  		mysql_close($con);
  } 	  

else  {
mysql_query($sql,$con) or die(mysql_error());
echo 'Thanks for your submission ';
mysql_close($con);
  }

  }
  
  
?>

 

 

 

Link to comment
Share on other sites

So would this solve the problem.

 

 $sql="INSERT INTO `pendingquotes` (`quotes`, `email`, `name`) VALUES('".$_POST[quotes]."','".$_POST[email]."','".$_POST[name]."')";

$quote = $_POST['quotes'];
mysql_real_escape_string($quote);
$trimmed = trim($quote);

$quote1 = $_POST['email'];
mysql_real_escape_string($quote1);
$trimmed = trim($quote1);

$quote2 = $_POST['name'];
mysql_real_escape_string($quote2);
$trimmed = trim($quote2);


Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.