Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hi fellow forumer,
Need your help as I new in php. First thing is what the " : " symbol means? I cannot find in post or other search in google. Second, I wrote a php code and when I run, it produces error:
[b]Parse error: parse error, unexpected ':' in C:\Inetpub\wwwroot\formtest2.php on line 12[/b]
what this error mean? Can anybody explain what was the error indicate. Below is the code:Code: Select all
<?php
echo '<html><head><basefont face="Arial"></head><body>';
if (!isset($_POST['submit']) )
{
// form not submitted
echo '<form action="formtest2.php" method="post" onsubmit="redirect()">Username: <input type="text" name="username"><br />
Password: <input type="password" name="password"><br /><br /><input type="submit" name="submit" value="Sign Up"></form>';
}
else
{
if(
$username=(!isset($_POST['username']) || trim($_POST['username']) == "") or die('ERROR: Enter a username') : mysql_escape_string(trim($_POST['username']));
$password = (!isset($_POST['password']) || trim($_POST['password'] == "")) or die ('ERROR: Enter a password') : mysql_escape_string(trim($_POST['password']));
// connect to database
// open connection
/*$connection = mysql_connect('localhost', ' ', ' ')
or die ('Unable to connect!');*/
$connection = mysql_connect('localhost','','') or die ('Unable to connect!');;
// select database
mysql_select_db('ebcaptive') or die ('Unable to select database!');
// create query
$query = "INSERT INTO user (username, password)
VALUES ('$username', '$password')";
// execute query
$result = mysql_query($query)
or die ("Error in query: $query. " . mysql_error());
// close connection
mysql_close($connection);
)
echo 'You have successfully registered!';
echo '</body></html>';
}
?>
thanks.scottayy | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]