January 17, 201115 yr Hi guys this script isnt working my form is here. <form method="POST" action="index2.php"> <input type="text" name="title"/> <input type="text" name="comment"/> <input type="submit" name="submit" value="Post Comment" /> </form> php is here <?php session_start(); //connection is present here $sql_statement = "INSERT INTO blog_pettit (title, comment) VALUES ('title', 'comment')"; $results = mysqli_query($mysqli, $sql_statement); if ($results == TRUE) { echo "Your comment has been posted."; } else { printf("Could not create post: %s\n", mysqli_error($mysqli)); } mysqli_close($mysqli); } ?> no errors nothing? Cheers
January 17, 201115 yr Have you actually connected to the database? Do you have error reporting turned on?
January 17, 201115 yr Author Have you actually connected to the database? Do you have error reporting turned on? obviously thats why it says //connection is present here, i am not going to put the actual connection in. error reporting is on nothing is being displayed. cheers
January 17, 201115 yr Hi guys this script isnt working my form is here. <form method="POST" action="index2.php"> <input type="text" name="title"/> <input type="text" name="comment"/> <input type="submit" name="submit" value="Post Comment" /> </form> php is here <?php session_start(); //connection is present here $sql_statement = "INSERT INTO blog_pettit (title, comment) VALUES ('title', 'comment')"; $results = mysqli_query($mysqli, $sql_statement); if ($results == TRUE) { echo "Your comment has been posted."; } else { printf("Could not create post: %s\n", mysqli_error($mysqli)); } mysqli_close($mysqli); } ?> no errors nothing? Cheers try $sql_statement = "INSERT INTO blog_pettit (`title`, `comment`) VALUES ('title', 'comment')";
January 17, 201115 yr nope. lol Ok rewrite the whole thing like this <?php session_start(); //connection is present here $sql_statement = "INSERT INTO blog_pettit (`title`, `comment`) VALUES ('title', 'comment')"; $results = mysqli_query($mysqli, $sql_statement); if (mysqli_errno($results)) { die(mysqli_error($mysqli)); } else { echo "Your comment has been posted"; } mysqli_close($mysqli); } ?> and to clarify make sure error_reporting is at the top of the page above session start and that it looks like ERROR_REPORTING(E_ALL);
January 17, 201115 yr Author still nothing.... no errors just a blank page. no data is being inserted into the database either!? Craig
January 17, 201115 yr still nothing.... no errors just a blank page. no data is being inserted into the database either!? Craig Mmmmm thats very odd as i can see nothings wrong with ur query
January 17, 201115 yr Have you actually had PHP errors show before? You need to set them to display as wel ini_set('display_errors', 1); If it's not showing anything then clearly there is a parse error. Have you checked your error log files?
January 17, 201115 yr Author Mmmmm thats very odd as i can see nothings wrong with ur query i know i always have these problems. my host wont take any responibity for it either...
January 17, 201115 yr i know i always have these problems. my host wont take any responibity for it either... mmm after all ur code do echo "Hello world"; see if that outputs if it does not u odviously have a hidden parse error EDIT: ok i just noticed something whats the last } bracket right before the closing php tag suppose to be going to? it looks like u need to remove that Edited January 17, 201115 yr by webdesigner93
January 17, 201115 yr Author Ok i am literally a massive idiot. i wouldnt usually own up to this but u all deserve a laugh!!! I didnt upload the file!! HAA
January 17, 201115 yr yeah its not echoing anything out. did u remove the bracket before the closing php tag? once thats removed should look like this <?php session_start(); //connection is present here $sql_statement = "INSERT INTO blog_pettit (`title`, `comment`) VALUES ('title', 'comment')"; $results = mysqli_query($mysqli, $sql_statement); if (mysqli_errno($results)) { die(mysqli_error($mysqli)); } else { echo "Your comment has been posted"; } mysqli_close($mysqli); ?> Edited January 17, 201115 yr by webdesigner93
Create an account or sign in to comment