regoch Posted December 28, 2011 Share Posted December 28, 2011 Hail! 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? <?php error_reporting (E_ALL ^ E_NOTICE); $post = (!empty($_POST)) ? true : false; if($post) { $name = stripslashes($_POST['name']); $email = trim($_POST['email']); $message = stripslashes($_POST['message']); $sigureca = $_POST['sigureca']; $error = ''; //provjera imena if(empty($name)) { $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>"; } if(!$error) { $visitorIP = getenv("HTTP_X_FORWARDED_FOR"); if (($visitorIP == null) or ($visitorIP == "")) { $visitorIP = getenv("REMOTE_ADDR"); } else { 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')"); } else { echo '<div class="notification_error">'.$error.'</div>'; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/253965-insert-into-error/ Share on other sites More sharing options...
ohdang888 Posted December 28, 2011 Share Posted December 28, 2011 well, first thoughts: this should be throwing an error: echo $email'; Remove the ' Quote Link to comment https://forums.phpfreaks.com/topic/253965-insert-into-error/#findComment-1301904 Share on other sites More sharing options...
regoch Posted December 28, 2011 Author Share Posted December 28, 2011 that i put just to test if variables are empty. variable are with data, echo write data on page, but data don't get in database Quote Link to comment https://forums.phpfreaks.com/topic/253965-insert-into-error/#findComment-1301906 Share on other sites More sharing options...
ManiacDan Posted December 28, 2011 Share Posted December 28, 2011 Ok, 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. Quote Link to comment https://forums.phpfreaks.com/topic/253965-insert-into-error/#findComment-1301922 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.