Welcome to WebmasterWorld Guest from 54.205.119.93

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Parse error</b>: parse error, unexpected T_CONSTANT_ENCAPSED_STRING i

Parse error</b>: parse error, unexpected T_CONSTANT_ENCAPSED_STRING in <b>

   
5:49 pm on Apr 26, 2005 (gmt 0)

10+ Year Member



Someone please help me with this as i am getting the above errors.. in line 6 i..e mysql...
<html>
<?php
if ($submit)
{
$db = mysql_connect ("localhost", "root, "");
mysql_select_db ("learndb", $db);
$sql = INSERT INTO personnel (firstname, lastname, nick, email, salary) VALUES ('$first', '$last', '$nick', '$email', '$salary')
$result = mysql_query ($sql);
echo "Thank you! Information entered.\n";
}
else
{
?>
<form method="post" action="input.php">
First name:<input type="Text" name="first"><br>
Last name:<input type="Text" name="last"><br>
Nick name:<input type="Text" nickname="first"><br>
E-mail:<input type="Text" name="email"><br>
Salary:<input type="Text" name="salary"><br>
input type="Submit" name="submit" value=" Enter information">
</form>

<?php

}

php?>
</HTML>

6:02 pm on Apr 26, 2005 (gmt 0)

10+ Year Member



Don't know if this is a type or not but

$sql = INSERT INTO personnel (firstname, lastname, nick, email, salary) VALUES ('$first', '$last', '$nick', '$email', '$salary')

should be :

$sql = "INSERT INTO personnel (firstname, lastname, nick, email, salary) VALUES ('$first', '$last', '$nick', '$email', '$salary')";

-sned

6:08 pm on Apr 26, 2005 (gmt 0)

10+ Year Member



hiya. i have tried it but unfortunately it does not work...
6:51 pm on Apr 26, 2005 (gmt 0)

WebmasterWorld Administrator jatar_k is a WebmasterWorld Top Contributor of All Time 10+ Year Member



sned's correction is right but I think your error is above that

$db = mysql_connect ("localhost", "root, "");

you're missing a "

$db = mysql_connect ("localhost", "root", "");

6:56 pm on Apr 26, 2005 (gmt 0)

10+ Year Member



hiya..

i observed that and corrected it with a " and there is still an error apparently...

7:23 pm on Apr 26, 2005 (gmt 0)

WebmasterWorld Administrator jatar_k is a WebmasterWorld Top Contributor of All Time 10+ Year Member



php?>

should be

?>

8:33 pm on Apr 26, 2005 (gmt 0)

10+ Year Member



It doesn't tell you which line the error is on?
8:46 pm on Apr 26, 2005 (gmt 0)

10+ Year Member



you're still missing a ; in line five, if you're still getting the same error. if that's not it post the new version of your script
8:50 pm on Apr 26, 2005 (gmt 0)

10+ Year Member



actually just try this

<html>
<?
if ($submit) {
$db = mysql_connect ("localhost", "username", "password");
mysql_select_db ("learndb", $db);
$sql = "INSERT INTO personnel (firstname, lastname, nick, email, salary) VALUES ('$first', '$last', '$nick', '$email', '$salary')";
$result = mysql_query($sql);
if (!$result) {
die('Query failed: ' . mysql_error());
} else {
echo "Thank you! Information entered.\n";
}
}
?>
<form method="post" action="input.php">
First name:<input type="Text" name="first"><br>
Last name:<input type="Text" name="last"><br>
Nick name:<input type="Text" nickname="first"><br>
E-mail:<input type="Text" name="email"><br>
Salary:<input type="Text" name="salary"><br>
input type="Submit" name="submit" value="Enter information">
</form>
</html>
 

Featured Threads

Hot Threads This Week

Hot Threads This Month