Jump to content

Recommended Posts

Hii phpfreaks...

I'm running a simple mysql insert statement and getting a Parse Error.My code is :

 

<html>
<body>
<?php
$con=mysql_connect("localhost","root","");
if(!$con)
{
die ('Can not connect to :' .mysql_error());
}
   mysql_select_db("brite",$con);
   $sql="insert into subjects VALUES('$_POST['subname']','$_POST]['submarks']','$_POST['subgrade']','T')";
   mysql_close();
header('Location:subject.php');
<?> 

 

My help me someone ,I'm screwed trying to fight it.

Thanx in advance.

 

MOD EDIT: code tags added

Although I suspect there will be other problems, try these changes.

 

$sql="INSERT INTO subjects VALUES('{$_POST['subname']}', '{$_POST['submarks']}', '{$_POST['subgrade']}', 'T')";

 

AND

 

?> // NOT <?>

heyy...every1 ...I tried everything but still nothings working...

and @Pikachu 2000- sir i evn tried that syntax but no gain.

My exact error is - Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in C:\wamp\www\My files\insert.php on line 10.

 

Plzz someone help me.I'm helpless!!!

Try this:

<html>
<body>
<?php
$con=mysql_connect("localhost","root","");
if(!$con)
{
die ('Can not connect to :' .mysql_error());
}
mysql_select_db("brite",$con);
   
   $sql="insert into subjects VALUES('{$_POST['subname']}','{$_POST['submarks']}','{$_POST['subgrade']}','T')";
   
   mysql_query($sql) or trigger_error( mysql_error() );
   mysql_close();
header('Location:subject.php');
exit();
?> 

 

You had an extra bracket (]) around one of your $_POST variables.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.