Jump to content

Archived

This topic is now archived and is closed to further replies.

Unseeeen

Insert into?

Recommended Posts

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 work

Can anyone see what's wrong with it? Thanks.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

×

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.