Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Errors: Unexpected character in input...........unexpected T_String

Status
Not open for further replies.

SeeCharp

Programmer
Nov 15, 2006
12
US
<?
session_start();
if ($_SESSION[valid] != "yes") {
header ("Location: exit;
}

$db_name = "cayema";
$table_name = "my_contacts";


$connection = @mysql_connect("localhost", "*", "*") or die (mysql_error());

$db = @mysql_select_db($db_name, $connection) or die (mysql_error());

$sql = "SELECT id, f_name, l_name FROM $table_name ORDER BY l_name";
$result = @mysql_query($sql, $connection) or die (mysql_error());
$contact_list = "<ul>";
while ($row = mysql_fetch_array($result)) {
$id = $row['id'];
$f_name = $row['f_name'];
$l_name = $row['l_name'];

$contact_list .= "<li><a href=\"show_contact.php?id=$id\">$l_name, $f_name</a>";
}

$contact_list .= "</ul>";

?>

Hi all I'm getting several errors and I just need a set of fresh eyes to find them for me. Can you see the problem that generages these two errors?

Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /home/cayema/ on line 2

Parse error: parse error, unexpected T_STRING in /home/cayema/ on line 3

<html>
<head>
<title>My Contact Management Sytem RV: Contacts Listed by name in this case but it could be anything here</title>
</head>
<body>
<h1>My Contact System RV030807</h1>
<p>Select a contact from the list below, to view the contact's record.</p>
<?php echo "$contact_list"; ?>
<p><a href="contact_menu.php">Return to Main Menu Richie V 030807</a></p>
</body>
</html>
 
Sorry I didn't realize this text was down in the code.


Hi all I'm getting several errors and I just need a set of fresh eyes to find them for me. Can you see the problem that generages these two errors?

Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /home/cayema/ on line 2

Parse error: parse error, unexpected T_STRING in /home/cayema/ on line 3



<?
session_start();
if ($_SESSION[valid] != "yes") {
header ("Location: exit;
}

$db_name = "cayema";
$table_name = "my_contacts";


$connection = @mysql_connect("localhost", "cayema", "red27") or die (mysql_error());

$db = @mysql_select_db($db_name, $connection) or die (mysql_error());

$sql = "SELECT id, f_name, l_name FROM $table_name ORDER BY l_name";
$result = @mysql_query($sql, $connection) or die (mysql_error());
$contact_list = "<ul>";
while ($row = mysql_fetch_array($result)) {
$id = $row['id'];
$f_name = $row['f_name'];
$l_name = $row['l_name'];

$contact_list .= "<li><a href=\"show_contact.php?id=$id\">$l_name, $f_name</a>";
}

$contact_list .= "</ul>";

?>

<html>
<head>
<title>My Contact Management Sytem RV: Contacts Listed by name in this case but it could be anything here</title>
</head>
<body>
<h1>My Contact System RV030807</h1>
<p>Select a contact from the list below, to view the contact's record.</p>
<?php echo "$contact_list"; ?>
<p><a href="contact_menu.php">Return to Main Menu Richie V 030807</a></p>
</body>
</html>
 
For starters, you are missing the single quotes around the$_SESSIONS value.
Code:
if ($_SESSION[[red]'[/red]valid[red]'[/red]] != "yes") {
header ("Location: [URL unfurl="true"]http://localhost/contact_menu.php");[/URL]

I'm sure that will fix the other error as well as it seems to me its a byproduct of this line.

----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
I appreciate the help Vacunita but unfortunately that isn't what is causing the problem. I use that same code on the login page contact_menu and it opens up fine without any errors.

Any other suggestions? Does anyone know what types of mistakes generate the errors above and I can look for those things in particular?

Thanks.
 
I don't know what your display_error setting is but you should be getting a [red]Notice: Use of undefined constant valid - assumed 'valid' in ...[/red] by not using the quotes.


As for the error then, I fail to see anything in the part of the code you posted that would produce that kind of error.
This:
Code:
session_start();
if ($_SESSION['valid'] != "yes") {
header ("Location: [URL unfurl="true"]http://localhost/~website/tmplt.php");[/URL]
exit;
}

works for me as expected provided there is a session variable 'valid' in existence prior to this.

----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
exit is function
so you should have
exit();
and not exit;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top