How could I modify this syntax error ?
Posted: Wed Feb 20, 2008 2:49 pm
~pickle | Please use
I`m beginner with php and I don`t know how could I debug it ?
Please help me .
~pickle | 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]
Hi
I`m preparing this php class for using with amfphp and making an authentication interface with php and flash .
But I receive this error :
Parse error: syntax error, unexpected T_ELSE in C:\AppServ\www\amfphp\services\prev2~.php on line 69Code: Select all
<?php
//Include database info
include ('db_connect.inc.php');
// Create new service for PHP Remoting as Class.
class Login1 {
function Login1() {
//Define the methodTable
$this->methodTable = array(
"doPost" => array(
"description" => "Send a query to mySQL",
"access" => "remote"
),
"doCompare" => array(
"description" => "Comparison of user input and mySQL value",
"access" => "remote"
)
);
//Connect to MySQL and select database
$link = mysql_connect(HOST, DBUSER, PASS);
$db = mysql_select_db(DB);
}
//Function for login
function doPost($_POST) {
if (!session_is_registered('loginid') || !session_is_registered('username'))
{
// user is not logged in.
if (isset($_POST['cmdlogin']))
{
// retrieve the username and password sent from login form
// First we remove all HTML-tags and PHP-tags, then we create a md5-hash
// This step will make sure the script is not vurnable to sql injections.
$u = strip_tags($_POST['username']);
$p = md5(strip_tags($_POST['password']));
//Now let us look for the user in the database.
$query = sprintf("SELECT loginid FROM login WHERE username = '%s' AND password = '%s' LIMIT 1;",
mysql_real_escape_string($u), mysql_real_escape_string($p));
$result = mysql_query($query);
}
}
}
//Function for compare
function doCompare ($result) {
// If the database returns a 0 as result we know the login information is incorrect.
// If the database returns a 1 as result we know the login was correct and we proceed.
// If the database returns a result > 1 there are multple users
// with the same username and password, so the login will fail.
if (mysql_num_rows($result) != 1)
{
// invalid login information
return array("status" => "fail");
} else {
// Login was successfull
$row = mysql_fetch_array($result);
// Save the user ID for use later
$_SESSION['loginid'] = $row['loginid'];
// Save the username for use later
$_SESSION['username'] = $u;
// Now we show the userbox
return array("status" => "success");
}
else {
// User is not logged in and has not pressed the login button
// so we show him the loginform
return array("status" => "fail");
} else {
// The user is already loggedin, so we show the userbox.
return array("status" => "success");
}
}
}
?>Please help me .
~pickle | 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]