Unseeeen Posted June 27, 2006 Share Posted June 27, 2006 I honestly cant find anything wrong with this script, other than it's extremely insecure (and I'll fix that later [img src=\"style_emoticons/[#EMO_DIR#]/unsure.gif\" style=\"vertical-align:middle\" emoid=\":unsure:\" border=\"0\" alt=\"unsure.gif\" /])[code]<?php$dbconnect = mysql_connect ("localhost", "***", "***") or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db ("***");$title = $_POST['title'];$author = $_POST['author'];$news = $_POST['news'];$submit = $_POST['submit'];$time = date('D M j'); if(isset($submit))$sql = "INSERT INTO news ( id, title, newsbody, username, time ) values ( 'NULL', '$title', '$news', '$author', '$time' )";mysql_query ($sql) or die(mysql_error();echo "News successfully submitted!";} else {?>[/code]I get a unexpected ';' error on line 12, and thats[code]if(isset($submit))[/code]I'm pretty sure I used isset() correctly? I was thinking there could be an error on the next line...but I've been trying everything I can think of and it just won't workCan anyone see what's wrong with it? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/13001-insert-into/ Share on other sites More sharing options...
Brandon Jaeger Posted June 27, 2006 Share Posted June 27, 2006 You need an { on that line with the error. Quote Link to comment https://forums.phpfreaks.com/topic/13001-insert-into/#findComment-49983 Share on other sites More sharing options...
phpstuck Posted June 27, 2006 Share Posted June 27, 2006 Just take out that line and it should function perfectly, since everything is coming in POST anyway. Just srip out any special characters someone might add and you are there. Quote Link to comment https://forums.phpfreaks.com/topic/13001-insert-into/#findComment-49984 Share on other sites More sharing options...
Unseeeen Posted June 27, 2006 Author Share Posted June 27, 2006 v3x: That didn't fix the error. phpstuck: the reason why I have that if there is because that's not all of it...I made it so if there's a post, basically send it to the database, else post the form. I didn't bother posting the form because I didn't feel it was needed and would just make my post longer. Quote Link to comment https://forums.phpfreaks.com/topic/13001-insert-into/#findComment-49990 Share on other sites More sharing options...
Brandon Jaeger Posted June 27, 2006 Share Posted June 27, 2006 You're also missing an ) here:[code]mysql_query ($sql) or die(mysql_error();[/code] Quote Link to comment https://forums.phpfreaks.com/topic/13001-insert-into/#findComment-49991 Share on other sites More sharing options...
Unseeeen Posted June 27, 2006 Author Share Posted June 27, 2006 Haha wow, I would of never saw that.Thanks! That's what fixed it. :) Quote Link to comment https://forums.phpfreaks.com/topic/13001-insert-into/#findComment-49996 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.