- Every time i try to insert value in my mysql database from php script, the query fails.
Here are my codes.
if ( empty($_POST)) { echo '<script type="text/javascript"> alert("Tricky, you must have left something empty. That is why you are now will be redirected to Main page. Try again ;)"); window.location.href ="index.php"</script>'; }else { $first_name = $_POST['first_name']; $last_name = $_POST['last_name']; $email_id = $_POST['email_id']; $your_info = $_POST['your_info']; $title = $_POST['title']; $feed_area = $_POST['feed_area']; $remote_addr = $_SERVER['REMOTE_ADDR']; $type = $_POST['type']; if(!empty($first_name) || !empty($last_name) || !empty($email_id) || !empty($your_info) || !empty($title) || !empty($feed_area) || !empty($type)) { echo '<div id="header"> <div id="middle_heading">Confirmed!!!</div></div>'; $dbc = mysqli_connect('localhost', 'root', '', 'feed_update'); $query = "INSERT INTO feed_info (id, first_name, last_name, email_id, your_info, title,type, feed_area, feed_date, remote_addr)" VALUES (0, '$first_name', '$last_name', '$email_id', '$your_info', '$title', '$type', '$feed_area', NOW(), '$remote_addr')"; mysqli_query($dbc, $query) or die("<script type='text/javascript'>alert('query error alert');</script>"); mysqli_close($dbc); echo '<script type="text/javascript">window.location.href ="index.php"</script>'; }else { echo '<script type="text/javascript"> alert("Tricky, you must have left something empty. That is why you are now will be redirected to Main page. Try again ;)"); window.location.href ="index.php"</script>'; } } ?>
Note:
- the html is not php self form.
- I also installed wordpress in my database, is there any problem with it too ?