Jump to content

Insert into error


Recommended Posts


I got this script for insert message in my guestbook. But it wont insert any data in rows. Error checking is working, I even echo every variable to test it, try to manualy test code in mysql myadmin and everything working fine. So variables are ok, mysql code is ok, but script wont insert anything in rows. Any ideas?


error_reporting (E_ALL ^ E_NOTICE);

$post = (!empty($_POST)) ? true : false;


$name = stripslashes($_POST['name']);
$email = trim($_POST['email']);
$message = stripslashes($_POST['message']);
$sigureca = $_POST['sigureca'];
$error = '';

//provjera imena
$error .= '<strong>Molimo upišite ime.</strong><br />';
//checks for an email
if (empty($email)) {
$error .= '<strong>Molimo upišite e-mail.</strong><br />';
} else {
	if (!eregi ('^[[:alnum:]][a-z0-9_\.\-]*@[a-z0-9\.\-]+\.[a-z]{2,4}$', stripslashes($email))) {
	$error .= '<strong>Molimo upišite ispravan e-mail.</strong><br />';
} // if eregi
} // if empty email

//provjera poruke
if(empty($message) || strlen($message) < 15)
$error .= "<strong>Molimo upišite poruku. Mora imati bar 15 znakova.</strong><br />";
//provjera šigurece
if($sigureca <> "H6F7N1")
$error .= "<strong>Kod nije ispravan.</strong>";

$visitorIP = getenv("HTTP_X_FORWARDED_FOR");
		if (($visitorIP == null) or ($visitorIP == ""))
		$visitorIP = getenv("REMOTE_ADDR");
		list ($proxyIP, $visitorIP) = split ('[,]', $visitorIP);
		$visitorIP = ltrim($visitorIP);
$datum = date('Y-m-d');
		echo $visitorIP;
		echo $name;
		echo $email';
		echo $datum;
		echo $message;
mysql_query("INSERT INTO cakula (ime, e_mail, poruka, datum, ip) VALUES ('$name','$email','$message','$datum', '$visitorIP')");
echo '<div class="notification_error">'.$error.'</div>';


Link to comment
Share on other sites



1)  He's saying the script you posted contains fatal PHP errors and will not execute or even parse.  The script you posted cannot possibly be echoing and sending emails, because it will not run in the form you gave us.


2)  You run an insert statement without running your arguments through mysql_real_escape_string.


3)  You have a query you believe is failing and you're not echoing (a) the query, or (b) the results of mysql_error(). 


Learn to help yourself and you'll be a much better programmer.  You have 2 error checking steps you have not performed.

Link to comment
Share on other sites

This thread is more than a year old.

Join the conversation

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

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.