PDA

View Full Version : UNEXPECTED T_STRING! help!!!!!!!!!


Atia
Mon 15th Nov '04, 12:44pm
Can anyone help me, I get an unexpected T_String error on line 52.
Now this is the first time I am using php, therefore i do not understand what this errror means.

The error is shown on the following paragraph:

} else if ($_POST[op] == "add") {
//time to add to tables, so check for required fields
if (($_POST[f_name] == "") ¦¦ ($_POST[l_name] == "")) {
header ("Location: addentry.php");
exit();
}

Line 54 starts at the IF statement.

I am also posting the whole of my code:
<?php
if ($_POST[op] !="add") {
//havent seen the for, so how it
$display_block = "<h1>Add an Entry</h1>
<form method=\"post\" action=\"$_SERVER[PHP_SELF]\">
<p><strong> General Details:</srtong><br>
<p><storng>First/ Name:<strong><br>
<input type=\"text\" name=\"f_name\" size=30 maxlength=75>
<input type=\"text\" name=\"l_name\" size=30 maxlength=75>
<p><strong>Personal Details:</strong><br>
<p><strong>Address:</strong><br>
<input type=\"text\" name=\"address\" size=30>
<p><Strong>City/Postcode:</strong><br>
<input type=\"text\" name=\"city\" size=30 maxlength=30>
<input type=\"text\" name=\"postcode\" size=6 maxlength=6>
<p><Strong>address type:</strong><br>
<input type=\"radio\" name=\"add_type\" value=\"home\" checked> home
<input type=\"radio\" name=\"add_type\" value=\"work\"> work
<input type=\"radio\" name=\"add_type\" value=\"other\"> other
<p><Strong>Telephone Number:</strong><br>
<input type=\"text\" name=\"tel_number\" size=30 maxlength=25>
<input type=\"radio\" name=\"tel_number\" value\"home\" checed> home
<input type=\"radio\" name=\"tel_type\" value=\"work\">work
<input type=\"radio\" name=\"tel_type\" value=\"other\">other
<p><Strong>Fax Number:</strong><br>
<input type=\"text\" name=\"fax_number\" size=30 maxlength=25>
<input type=\"radio\" name=\"fax_number\" value\"home\" checed> home
<input type=\"radio\" name=\"fax_type\" value=\"work\">work
<input type=\"radio\" name=\"fax_type\" value=\"other\">other
<p><Strong>Email Address:</strong><br>
<input type=\"text\" name=\"email\" size=30 maxlength=150>
<input type=\"radio\" name=\"email\" value\"home\" checed> home
<input type=\"radio\" name=\"email\" value=\"work\">work
<input type=\"radio\" name=\"email\" value=\"other\">other

<p><Strong>Interests:</strong><br>
<textarea name=\"comment\" cols=35 rows=5 wrap=virtual></textarea>
<input type=\"hidden\" name\"op\" value=\"add\">
<p><input type=\"submit\" name=\"submit\" value=\"Add Entry\"><\p>
</FORM>";
} else if ($_POST[op] == "add") {
//time to add to tables, so check for required fields
if (($_POST[f_name] == "") ¦¦ ($_POST[l_name] == "")) {
header ("Location: addentry.php");
exit();
}
//connect to database
$conn = mysql_connect ("localhost", "Atia Khan", "mouse337")
or die(mysql_error());
mysql_select_db("ivc_journal_database", $conn) or die(mysql_error());
if ($_POST[members_id] == "") {
//add to members table
$add_members = "insert into members values (' ', now(), now(), '$_POST[f_name]','$_POST[l_name]')";
mysql_query ($add_members) or die (mysql_error());
//get members_id for use with other tables
$member_id = mysql_insert_id ();
} else {
$members_id = $_POST[members_id];
}
if (($_POST [password]) ¦¦ ($_POST [type]) ¦¦ ($_POST [title]) ¦¦($_POST [f_name]) ¦¦($_POST [l_name]) ¦¦($_POST [DOB]) ¦¦($_POST [address]) ¦¦($_POST [city]) ¦¦($_POST [postcode]) ¦¦($_POST [tel_number]) ¦¦ ($_POST [email]) ¦¦($_POST [fax]) ¦¦ ($_POST [interests]) ¦¦
//something relevent, so add to members table
$add_members = "insert into address values (", $members_id, now (), now(), '$_POST[password]','$_POST[type]','$_POST[title]','$_POST[address]','$_POST[tel_number]','$_POST[email]','$_POST[fax]','$_POST[interest]')";
mysql_query ($add_members)or die (mysql_error());
$display_block ="<h1>Entry Added</h1>
<p>Your entry has been added</p>";
}
?>
<HTLM>
<HEAD>
<TITLE> Add an Entry</TITLE>
</HEAD>
<BODY>
</php echo $display_block; />
</BODY>
</HTML>

can anyone please help me.

THANKS

ATIA

Alan @ CIT
Mon 15th Nov '04, 1:02pm
Sorry, but your code isn't particularly clear. If you could edit your post and put [ PHP ] at the start of your code blocks, and [ /PHP ] at the end (without the spaces), vBulletin will format it to make it easier to read.

But... I did notice one thing in your code:

if (($_POST [password]) ¦¦ ($_POST [type]) ¦¦ ($_POST [title]) ¦¦($_POST [f_name]) ¦¦($_POST [l_name]) ¦¦($_POST [DOB]) ¦¦($_POST [address]) ¦¦($_POST [city]) ¦¦($_POST [postcode]) ¦¦($_POST [tel_number]) ¦¦ ($_POST [email]) ¦¦($_POST [fax]) ¦¦ ($_POST [interests]) ¦¦

This line here doesn't seem to end correctly. It just trails off without finishing off the IF block. This would throw up a fatal error itself.

Also, once you've added the tags to format your code, if you could clearly indicate which line is the one with the error, it would be appreciated.

Many thanks,
Alan.

Zachery
Mon 15th Nov '04, 2:06pm
Just so you know, this is a support forum for vBulletin licensed users, not for the general public, however


</php echo $display_block; />

Is going to be your problem :)

<?php echo $display_block; ?>

Atia
Mon 15th Nov '04, 5:44pm
ALAN thanks,
ok, I have just checked over the code again and noticed I forgot to close the brackets after the mistake you found.
Also i have do what you have said and posted the code.


<?php
if ($_POST[op] !="add") {
//havent seen the for, so how it
$display_block = "<h1>Add an Entry</h1>
<form method=\"post\" action=\"$_SERVER[PHP_SELF]\">
<p><strong> General Details:</srtong><br>
<p><storng>First/ Name:<strong><br>
<input type=\"text\" name=\"f_name\" size=30 maxlength=75>
<input type=\"text\" name=\"l_name\" size=30 maxlength=75>
<p><strong>Personal Details:</strong><br>
<p><strong>Address:</strong><br>
<input type=\"text\" name=\"address\" size=30>
<p><Strong>City/Postcode:</strong><br>
<input type=\"text\" name=\"city\" size=30 maxlength=30>
<input type=\"text\" name=\"postcode\" size=6 maxlength=6>
<p><Strong>address type:</strong><br>
<input type=\"radio\" name=\"add_type\" value=\"home\" checked> home
<input type=\"radio\" name=\"add_type\" value=\"work\"> work
<input type=\"radio\" name=\"add_type\" value=\"other\"> other
<p><Strong>Telephone Number:</strong><br>
<input type=\"text\" name=\"tel_number\" size=30 maxlength=25>
<input type=\"radio\" name=\"tel_number\" value\"home\" checed> home
<input type=\"radio\" name=\"tel_type\" value=\"work\">work
<input type=\"radio\" name=\"tel_type\" value=\"other\">other
<p><Strong>Fax Number:</strong><br>
<input type=\"text\" name=\"fax_number\" size=30 maxlength=25>
<input type=\"radio\" name=\"fax_number\" value\"home\" checed> home
<input type=\"radio\" name=\"fax_type\" value=\"work\">work
<input type=\"radio\" name=\"fax_type\" value=\"other\">other
<p><Strong>Email Address:</strong><br>
<input type=\"text\" name=\"email\" size=30 maxlength=150>
<input type=\"radio\" name=\"email\" value\"home\" checed> home
<input type=\"radio\" name=\"email\" value=\"work\">work
<input type=\"radio\" name=\"email\" value=\"other\">other

<p><Strong>Interests:</strong><br>
<textarea name=\"comment\" cols=35 rows=5 wrap=virtual></textarea>
<input type=\"hidden\" name\"op\" value=\"add\">
<p><input type=\"submit\" name=\"submit\" value=\"Add Entry\"><\p>
</FORM>";
} else if ($_POST[op] == "add") {
//time to add to tables, so check for required fields
if (($_POST[f_name] == "") ¦¦ ($_POST[l_name] == "")) {
header ("Location: add.php");
exit();
}
//connect to database
$conn = mysql_connect ("localhost", "Atia Khan", "mouse337")
or die(mysql_error());
mysql_select_db("ivc_journal_database", $conn) or die(mysql_error());
//add to members table
$add_members = "insert into members values (' ', now(), now(), '$_POST[f_name]','$_POST[l_name]')";
mysql_query ($add_members) or die (mysql_error());

//get members_id for use with other tables
$member_id = mysql_insert_id ();
}
if (($_POST [password]) ¦¦ ($_POST [type]) ¦¦ ($_POST [title]) ¦¦($_POST [f_name]) ¦¦($_POST [l_name]) ¦¦($_POST [DOB]) ¦¦($_POST [address]) ¦¦($_POST [city]) ¦¦($_POST [postcode]) ¦¦($_POST [tel_number]) ¦¦ ($_POST [email]) ¦¦($_POST [fax]) ¦¦ ($_POST [interests])){
//something relevent, so add to members table
$add_members = "insert into address values (", $members_id, now (), now(), '$_POST[password]','$_POST[type]','$_POST[title]','$_POST[address]','$_POST[tel_number]','$_POST[email]','$_POST[fax]','$_POST[interest]')";
mysql_query ($add_members)or die (mysql_error());
}
$display_block ="<h1>Entry Added</h1>
<p>Your entry has been added</p>";
}
?>
<HTLM>
<HEAD>
<TITLE> Add an Entry</TITLE>
</HEAD>
<BODY>
<?php echo $display_block; ?>
</BODY>
</HTML>


Also this is where the error comes up:

if (($_POST[f_name] == "") ¦¦ ($_POST[l_name] == "")) {


And this is the following that is shows:
Parse error: parse error, unexpected T_STRING in C:\Program Files\Apache Group\Apache2\htdocs\add.php on line 52

Would really appreciate it if you can help.

Zachery, when I signed up it didnt really say anything about being a licensed users. Also I would have thought signing up makes me a licensed user. Anyways. I didnt really understand what you ment, I mean did you want me to replace '/' with '?'. plz clarify what you meant.

Also guys I am a newbie at this program so please expain in baby language. :D

THANKS,
Atia

Alan @ CIT
Mon 15th Nov '04, 6:06pm
Hi Atia,

To become a licenced user, you need to purchase vBulletin :)

Also, what Zachery meant was that you had a line of code that read </php echo $display_block; /> near the end - those "/" should be "?" :)

I've fixed a couple of things below (see my comments starting "// Alan @ CIT :") See if that works any better.


<?php
if ($_POST[op] !="add")
{
//havent seen the for, so how it
$display_block = "<h1>Add an Entry</h1>
<form method=\"post\" action=\"$_SERVER[PHP_SELF]\">
<p><strong> General Details:</srtong><br>
<p><storng>First/ Name:<strong><br>
<input type=\"text\" name=\"f_name\" size=30 maxlength=75>
<input type=\"text\" name=\"l_name\" size=30 maxlength=75>
<p><strong>Personal Details:</strong><br>
<p><strong>Address:</strong><br>
<input type=\"text\" name=\"address\" size=30>
<p><Strong>City/Postcode:</strong><br>
<input type=\"text\" name=\"city\" size=30 maxlength=30>
<input type=\"text\" name=\"postcode\" size=6 maxlength=6>
<p><Strong>address type:</strong><br>
<input type=\"radio\" name=\"add_type\" value=\"home\" checked> home
<input type=\"radio\" name=\"add_type\" value=\"work\"> work
<input type=\"radio\" name=\"add_type\" value=\"other\"> other
<p><Strong>Telephone Number:</strong><br>
<input type=\"text\" name=\"tel_number\" size=30 maxlength=25>
<input type=\"radio\" name=\"tel_number\" value\"home\" checed> home
<input type=\"radio\" name=\"tel_type\" value=\"work\">work
<input type=\"radio\" name=\"tel_type\" value=\"other\">other
<p><Strong>Fax Number:</strong><br>
<input type=\"text\" name=\"fax_number\" size=30 maxlength=25>
<input type=\"radio\" name=\"fax_number\" value\"home\" checed> home
<input type=\"radio\" name=\"fax_type\" value=\"work\">work
<input type=\"radio\" name=\"fax_type\" value=\"other\">other
<p><Strong>Email Address:</strong><br>
<input type=\"text\" name=\"email\" size=30 maxlength=150>
<input type=\"radio\" name=\"email\" value\"home\" checed> home
<input type=\"radio\" name=\"email\" value=\"work\">work
<input type=\"radio\" name=\"email\" value=\"other\">other
<p><Strong>Interests:</strong><br>
<textarea name=\"comment\" cols=35 rows=5 wrap=virtual></textarea>
<input type=\"hidden\" name\"op\" value=\"add\">
<p><input type=\"submit\" name=\"submit\" value=\"Add Entry\"><\p>
</FORM>";
}
else if ($_POST[op] == "add")
{
//time to add to tables, so check for required fields
if (($_POST[f_name] == "") ¦¦ ($_POST[l_name] == ""))
{
header ("Location: add.php");
exit();
}
//connect to database
$conn = mysql_connect ("localhost", "Atia Khan", "mouse337") or die(mysql_error());
mysql_select_db("ivc_journal_database", $conn) or die(mysql_error());

//add to members table
$add_members = "insert into members values (' ', now(), now(), '$_POST[f_name]','$_POST[l_name]')";
mysql_query ($add_members) or die (mysql_error());
//get members_id for use with other tables
$member_id = mysql_insert_id ();
}
if (($_POST [password]) ¦¦ ($_POST [type]) ¦¦ ($_POST [title]) ¦¦($_POST [f_name]) ¦¦($_POST [l_name]) ¦¦($_POST [DOB]) ¦¦($_POST [address]) ¦¦($_POST [city]) ¦¦($_POST [postcode]) ¦¦($_POST [tel_number]) ¦¦ ($_POST [email]) ¦¦($_POST [fax]) ¦¦ ($_POST [interests]))
{
//something relevent, so add to members table
$add_members = "insert into address values (", $members_id, now (), now()." '$_POST[password]','$_POST[type]','$_POST[title]','$_POST[address]','$_POST[tel_number]','$_POST[email]','$_POST[fax]','$_POST[interest]')"; // Alan @ CIT : Added a missing " after now().
mysql_query ($add_members)or die (mysql_error());
}
$display_block ="<h1>Entry Added</h1><p>Your entry has been added</p>";
// - Alan @ CIT : Removed a spare } from here
?>
<HTLM>
<HEAD>
<TITLE> Add an Entry</TITLE>
</HEAD>
<BODY>
<?php echo $display_block; ?>
</BODY>
</HTML>



Thanks,
Alan.

Atia
Tue 16th Nov '04, 5:29pm
Alan, Thanks so much, the changes you made, helped also made sense. One other thing I changed was the pipelines.

However now I get an error in line 63, which says the following:

Parse error: parse error, unexpected ',' in C:\Program Files\Apache Group\Apache2\htdocs\add.php on line 63

Line 63 is:

$add_members = "insert into address values (", $members_id, now (), now()." '$_POST[password]','$_POST[type]','$_POST[title]','$_POST[address]','$_POST[tel_number]','$_POST[email]','$_POST[fax]','$_POST[interest]')"; // Alan @ CIT : Added a missing " after now().

I will post the whole code too:


<?php
if ($_POST[op] !="add")
{
//havent seen the for, so how it
$display_block = "<h1>Add an Entry</h1>
<form method=\"post\" action=\"$_SERVER[PHP_SELF]\">
<p><strong> General Details:</srtong><br>
<p><storng>First/ Name:<strong><br>
<input type=\"text\" name=\"f_name\" size=30 maxlength=75>
<input type=\"text\" name=\"l_name\" size=30 maxlength=75>
<p><strong>Personal Details:</strong><br>
<p><strong>Address:</strong><br>
<input type=\"text\" name=\"address\" size=30>
<p><Strong>City/Postcode:</strong><br>
<input type=\"text\" name=\"city\" size=30 maxlength=30>
<input type=\"text\" name=\"postcode\" size=6 maxlength=6>
<p><Strong>address type:</strong><br>
<input type=\"radio\" name=\"add_type\" value=\"home\" checked> home
<input type=\"radio\" name=\"add_type\" value=\"work\"> work
<input type=\"radio\" name=\"add_type\" value=\"other\"> other
<p><Strong>Telephone Number:</strong><br>
<input type=\"text\" name=\"tel_number\" size=30 maxlength=25>
<input type=\"radio\" name=\"tel_number\" value\"home\" checed> home
<input type=\"radio\" name=\"tel_type\" value=\"work\">work
<input type=\"radio\" name=\"tel_type\" value=\"other\">other
<p><Strong>Fax Number:</strong><br>
<input type=\"text\" name=\"fax_number\" size=30 maxlength=25>
<input type=\"radio\" name=\"fax_number\" value\"home\" checed> home
<input type=\"radio\" name=\"fax_type\" value=\"work\">work
<input type=\"radio\" name=\"fax_type\" value=\"other\">other
<p><Strong>Email Address:</strong><br>
<input type=\"text\" name=\"email\" size=30 maxlength=150>
<input type=\"radio\" name=\"email\" value\"home\" checed> home
<input type=\"radio\" name=\"email\" value=\"work\">work
<input type=\"radio\" name=\"email\" value=\"other\">other
<p><Strong>Interests:</strong><br>
<textarea name=\"comment\" cols=35 rows=5 wrap=virtual></textarea>
<input type=\"hidden\" name\"op\" value=\"add\">
<p><input type=\"submit\" name=\"submit\" value=\"Add Entry\"><\p>
</FORM>";
}
else if ($_POST[op] == "add")
{
//time to add to tables, so check for required fields
if (($_POST[f_name] == "") || ($_POST[l_name] == ""))
{
header ("Location: add.php");
exit();
}
//connect to database
$conn = mysql_connect ("localhost", "Atia Khan", "mouse337") or die(mysql_error());
mysql_select_db("ivc_journal_database", $conn) or die(mysql_error());
//add to members table
$add_members = "insert into members values (' ', now(), now(), '$_POST[f_name]','$_POST[l_name]')";
mysql_query ($add_members) or die (mysql_error());
//get members_id for use with other tables
$member_id = mysql_insert_id ();
}
if (($_POST [password]) || ($_POST [type]) || ($_POST [title]) || ($_POST [f_name]) || ($_POST [l_name]) || ($_POST [DOB]) || ($_POST [address]) || ($_POST [city]) || ($_POST [postcode]) || ($_POST [tel_number]) || ($_POST [email]) || ($_POST [fax]) || ($_POST [interests]))
{
//something relevent, so add to members table
$add_members = "insert into address values (", $members_id, now (), now()." '$_POST[password]','$_POST[type]','$_POST[title]','$_POST[address]','$_POST[tel_number]','$_POST[email]','$_POST[fax]','$_POST[interest]')"; // Alan @ CIT : Added a missing " after now().
mysql_query ($add_members)or die (mysql_error());
}
$display_block ="<h1>Entry Added</h1><p>Your entry has been added</p>";
// - Alan @ CIT : Removed a spare } from here
?>
<HTLM>
<HEAD>
<TITLE> Add an Entry</TITLE>
</HEAD>
<BODY>
<?php echo $display_block; ?>
</BODY>
</HTML>


Getting there slowly!:)

Would really appreciate it if anyone can help!

Atia

Alan @ CIT
Wed 17th Nov '04, 6:22am
On that line you pasted, you've got a comma before $members_id - remove that and it should cure that error.

Thanks,
Alan.

Atia
Wed 17th Nov '04, 6:48pm
Alan, I removed the comma but it still didnt work.

Also one more question in the line of coding, what does the now () does it give current date and time?

Thanks,
Atia

Atia
Thu 18th Nov '04, 8:44am
Ok, I have sorted the problem out that I was having.

However it is not connecting to my database.

And the problem is in my user name. It is not excepting it.

The error it come up with is the following:

Parse error: parse error, unexpected T_STRING in C:\Program Files.....

However I dont understnad why it is not excepting it, as in MYSQL admin, my user name is defined at Atia and thats what it shows as too.

PLEASE HELP! If someone can sort this problem out I would really appreciate it, as then I can apply this to the rest of my project.

Thanks,
Atia

Zachery
Thu 18th Nov '04, 9:28am
You should try a website like

http://www.devshed.com/
or
http://www.sitepoint.com/

They are better suited to help you, as I had said elier we are mostly a community of vBulletin users. :)