473,320 Members | 1,946 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

A bad tutorial ?

Hello,
I am learning PHP/MySQL at the moment.
I found what looked like an excellent tutorial site, but the first
program I wrote already left me with an error to which I cannot find an
answer.
I typed in the following program:
<html>
<head><title>Connect Server</title></head>
<body>
<?
$link =
mysql_connect("localhost",$_POST['username'],$_POST['password'])or
die("Connect Error: ".mysql_error());
print "Successfully connected.\n";
mysql_close($link);
?>
</body>
</html>
Iobviously typed in my own username and password instead of 'username'
and 'password' in the line
"mysql_connect("localhost",$_POST['username'],$_POST['password'])or...."

However, I keep getting the following error when running it from my
browser:
"Parse error: syntax error, unexpected T_VARIABLE in C:\Program
Files\Abyss Web Server\htdocs\logon.php on line 5"

Can anyone enlighten me please ?
I use PHP v 5.1.1.0 and MySQL v 4.1.13

Any help will be much appreciated.
TIA,
Newsscanner.
Jul 27 '05 #1
7 1464
On Wed, 27 Jul 2005 19:02:18 +0100, Newsscanner wrote:
Hello,
I am learning PHP/MySQL at the moment.
I found what looked like an excellent tutorial site, but the first
program I wrote already left me with an error to which I cannot find an
answer.
I typed in the following program:
<html>
<head><title>Connect Server</title></head>
<body>
<?
$link =
mysql_connect("localhost",$_POST['username'],$_POST['password'])or
die("Connect Error: ".mysql_error());
print "Successfully connected.\n";
mysql_close($link);
?>
</body>
</html>
Iobviously typed in my own username and password instead of 'username'
and 'password' in the line
"mysql_connect("localhost",$_POST['username'],$_POST['password'])or...."

However, I keep getting the following error when running it from my
browser:
"Parse error: syntax error, unexpected T_VARIABLE in C:\Program
Files\Abyss Web Server\htdocs\logon.php on line 5"

Can anyone enlighten me please ?
I use PHP v 5.1.1.0 and MySQL v 4.1.13

Any help will be much appreciated.
TIA,
Newsscanner.

Have you got the short_open_tag set to true, if not your opening tag needs
to be <?php not <?
Jul 27 '05 #2
Rincewind wrote:
On Wed, 27 Jul 2005 19:02:18 +0100, Newsscanner wrote:

Hello,
I am learning PHP/MySQL at the moment.
I found what looked like an excellent tutorial site, but the first
program I wrote already left me with an error to which I cannot find an
answer.
I typed in the following program:
<html>
<head><title>Connect Server</title></head>
<body>
<?
$link =
mysql_connect("localhost",$_POST['username'],$_POST['password'])or
die("Connect Error: ".mysql_error());
print "Successfully connected.\n";
mysql_close($link);
?>
</body>
</html>
Iobviously typed in my own username and password instead of 'username'
and 'password' in the line
"mysql_connect("localhost",$_POST['username'],$_POST['password'])or...."

However, I keep getting the following error when running it from my
browser:
"Parse error: syntax error, unexpected T_VARIABLE in C:\Program
Files\Abyss Web Server\htdocs\logon.php on line 5"

Can anyone enlighten me please ?
I use PHP v 5.1.1.0 and MySQL v 4.1.13

Any help will be much appreciated.
TIA,
Newsscanner.


Have you got the short_open_tag set to true, if not your opening tag needs
to be <?php not <?

I have now adjusted as follows :
" <html>
<head><title>Connect Server</title></head>
<body>
<? php
$link = mysql_connect("localhost",$_POST["*****"],$_POST["*****"])or
die("Connect Error: ".mysql_error());
print "Successfully connected.\n";
mysql_close($link);
?>
</body>
</html>"
(Replaced the logon details by asterisks for security resons).
Now I get the following in the browser:
"Parse error: syntax error, unexpected T_VARIABLE in C:\Program
Files\Abyss Web Server\htdocs\logon.php on line 5"

Heeeeeeeeeeeelp!!!!
TIA,
Newsscanner.
Jul 27 '05 #3
Newsscanner wrote:
Rincewind wrote:
On Wed, 27 Jul 2005 19:02:18 +0100, Newsscanner wrote:

Hello,
I am learning PHP/MySQL at the moment.
I found what looked like an excellent tutorial site, but the first
program I wrote already left me with an error to which I cannot find
an answer.
I typed in the following program:
<html>
<head><title>Connect Server</title></head>
<body>
<?
$link =
mysql_connect("localhost",$_POST['username'],$_POST['password'])or
die("Connect Error: ".mysql_error());
print "Successfully connected.\n";
mysql_close($link);
?>
</body>
</html>
Iobviously typed in my own username and password instead of
'username' and 'password' in the line
"mysql_connect("localhost",$_POST['username'],$_POST['password'])or...."

However, I keep getting the following error when running it from my
browser:
"Parse error: syntax error, unexpected T_VARIABLE in C:\Program
Files\Abyss Web Server\htdocs\logon.php on line 5"

Can anyone enlighten me please ?
I use PHP v 5.1.1.0 and MySQL v 4.1.13

Any help will be much appreciated.
TIA,
Newsscanner.



Have you got the short_open_tag set to true, if not your opening tag
needs
to be <?php not <?


I have now adjusted as follows :
" <html>
<head><title>Connect Server</title></head>
<body>
<? php
$link = mysql_connect("localhost",$_POST["*****"],$_POST["*****"])or
die("Connect Error: ".mysql_error());
print "Successfully connected.\n";
mysql_close($link);
?>
</body>
</html>"
(Replaced the logon details by asterisks for security resons).
Now I get the following in the browser:
"Parse error: syntax error, unexpected T_VARIABLE in C:\Program
Files\Abyss Web Server\htdocs\logon.php on line 5"

Heeeeeeeeeeeelp!!!!
TIA,
Newsscanner.


Replace the whole $_POST["*****"] with your username/password, unless
you're passing your username and password via a POST form (I'm guessing
you're not). Either way, it's a good step one in troubleshooting. You
can put the $_POST array back later once you get it working.
Jul 28 '05 #4
On Wed, 27 Jul 2005 19:02:18 +0100, in mailing.database.mysql
Newsscanner <fr******@NOSPAM.netvigator.co.uk> wrote:
| Hello,
| I am learning PHP/MySQL at the moment.
| I found what looked like an excellent tutorial site, but the first
| program I wrote already left me with an error to which I cannot find an
| answer.
| I typed in the following program:
| <html>
| <head><title>Connect Server</title></head>
| <body>
| <?
| $link =
| mysql_connect("localhost",$_POST['username'],$_POST['password'])or
| die("Connect Error: ".mysql_error());
| print "Successfully connected.\n";
| mysql_close($link);
| ?>
| </body>
| </html>
| Iobviously typed in my own username and password instead of 'username'
| and 'password' in the line
| "mysql_connect("localhost",$_POST['username'],$_POST['password'])or...."
|
| However, I keep getting the following error when running it from my
| browser:
| "Parse error: syntax error, unexpected T_VARIABLE in C:\Program
| Files\Abyss Web Server\htdocs\logon.php on line 5"
|
| Can anyone enlighten me please ?
| I use PHP v 5.1.1.0 and MySQL v 4.1.13
|
| Any help will be much appreciated.
| TIA,
| Newsscanner.


You should have another form with 2 input boxes (Username and
Password).
This other form should have the following html code:
<form name="???" action="login.php" method="post">
User Name <input type="text" name="username" value="" />
User Name <input type="password" name="password" value="" />
<input type="Submit" value="Submit" />
</form>

If this is not the case then in your login.php file then change
$_POST['username'] and $_POST['password'] to the information that you
want to use i.e.
mysql_connect("localhost",'myUsername','myPassword ')
---------------------------------------------------------------
jn******@yourpantsyahoo.com.au : Remove your pants to reply
---------------------------------------------------------------
Jul 28 '05 #5
Jeff North wrote:
On Wed, 27 Jul 2005 19:02:18 +0100, in mailing.database.mysql
Newsscanner <fr******@NOSPAM.netvigator.co.uk> wrote:

| Hello,
| I am learning PHP/MySQL at the moment.
| I found what looked like an excellent tutorial site, but the first
| program I wrote already left me with an error to which I cannot find an
| answer.
| I typed in the following program:
| <html>
| <head><title>Connect Server</title></head>
| <body>
| <?
| $link =
| mysql_connect("localhost",$_POST['username'],$_POST['password'])or
| die("Connect Error: ".mysql_error());
| print "Successfully connected.\n";
| mysql_close($link);
| ?>
| </body>
| </html>
| Iobviously typed in my own username and password instead of 'username'
| and 'password' in the line
| "mysql_connect("localhost",$_POST['username'],$_POST['password'])or...."
|
| However, I keep getting the following error when running it from my
| browser:
| "Parse error: syntax error, unexpected T_VARIABLE in C:\Program
| Files\Abyss Web Server\htdocs\logon.php on line 5"
|
| Can anyone enlighten me please ?
| I use PHP v 5.1.1.0 and MySQL v 4.1.13
|
| Any help will be much appreciated.
| TIA,
| Newsscanner.

You should have another form with 2 input boxes (Username and
Password).
This other form should have the following html code:
<form name="???" action="login.php" method="post">
User Name <input type="text" name="username" value="" />
User Name <input type="password" name="password" value="" />
<input type="Submit" value="Submit" />
</form>

If this is not the case then in your login.php file then change
$_POST['username'] and $_POST['password'] to the information that you
want to use i.e.
mysql_connect("localhost",'myUsername','myPassword ')
---------------------------------------------------------------
jn******@yourpantsyahoo.com.au : Remove your pants to reply
---------------------------------------------------------------

I do, but when I slot it in, as in this:
"<html>
<head><title>Connect Server</title></head>
<body>
<?
$link = mysql_connect("localhost",$_POST['*****'],$_POST['********'])or
die("Connect Error: ".mysql_error());
print "Successfully connected.\n";
mysql_close($link);
?>
<form method="POST" action="kiekteki.php">
Enter Username: <input type="text" name="username" size="20">
Enter Password:<input type="password" name="password" size="20">
<input type="submit" value="Submit"><input type="reset">
</form>
</body>
</html>"
I get the following errors in the browser:
"Notice: Undefined index: ****** in C:\Program Files\Abyss Web
Server\htdocs\kiekteki.php on line 5

Notice: Undefined index: ******** in C:\Program Files\Abyss Web
Server\htdocs\kiekteki.php on line 5

Warning: mysql_connect() [function.mysql-connect]: Access denied for
user 'ODBC'@'localhost' (using password: NO) in C:\Program Files\Abyss
Web Server\htdocs\kiekteki.php on line 5
Connect Error: Access denied for user 'ODBC'@'localhost' (using
password: NO)"

(Once again, the stars in the text were put there by me for security
reasons as they revealed my password etc.)

Thanks,
Newsscanner.
Jul 28 '05 #6
On Wed, 27 Jul 2005 23:10:48 +0100, Newsscanner wrote:
Rincewind wrote:
On Wed, 27 Jul 2005 19:02:18 +0100, Newsscanner wrote:

Hello,
I am learning PHP/MySQL at the moment.
I found what looked like an excellent tutorial site, but the first
program I wrote already left me with an error to which I cannot find an
answer.
I typed in the following program:
<html>
<head><title>Connect Server</title></head>
<body>
<?
$link =
mysql_connect("localhost",$_POST['username'],$_POST['password'])or
die("Connect Error: ".mysql_error());
print "Successfully connected.\n";
mysql_close($link);
?>
</body>
</html>
Iobviously typed in my own username and password instead of 'username'
and 'password' in the line
"mysql_connect("localhost",$_POST['username'],$_POST['password'])or...."

However, I keep getting the following error when running it from my
browser:
"Parse error: syntax error, unexpected T_VARIABLE in C:\Program
Files\Abyss Web Server\htdocs\logon.php on line 5"

Can anyone enlighten me please ?
I use PHP v 5.1.1.0 and MySQL v 4.1.13

Any help will be much appreciated.
TIA,
Newsscanner.


Have you got the short_open_tag set to true, if not your opening tag needs
to be <?php not <?

I have now adjusted as follows :
" <html>
<head><title>Connect Server</title></head>
<body>
<? php
$link = mysql_connect("localhost",$_POST["*****"],$_POST["*****"])or
die("Connect Error: ".mysql_error());
print "Successfully connected.\n";
mysql_close($link);
?>
</body>
</html>"
(Replaced the logon details by asterisks for security resons).
Now I get the following in the browser:
"Parse error: syntax error, unexpected T_VARIABLE in C:\Program
Files\Abyss Web Server\htdocs\logon.php on line 5"

Heeeeeeeeeeeelp!!!!
TIA,
Newsscanner.


take the space out of the <?php in your script between the ? and php and it
should work
Jul 28 '05 #7
On Thu, 28 Jul 2005 09:57:17 +0100, Newsscanner wrote:
Jeff North wrote:
On Wed, 27 Jul 2005 19:02:18 +0100, in mailing.database.mysql
Newsscanner <fr******@NOSPAM.netvigator.co.uk> wrote:

| Hello,
| I am learning PHP/MySQL at the moment.
| I found what looked like an excellent tutorial site, but the first
| program I wrote already left me with an error to which I cannot find an
| answer.
<snip> Thanks,
Newsscanner.


I've seen that tutorial and as far as I can see, you seem to be confused
about the whole process.

The login form:

<html>
<head>
<title>Connect Server</title>
</head>
<body>
<form method="POST" action="kiekteki.php">
Enter Username: <input type="text" name="username" size="20">
Enter Password:<input type="password" name="password" size="20">
<input type="submit" value="Submit"><input type="reset">
</form>
</body>
</html>
is seperate from the php script that connects to the server, using the
above will bring up a box for you to enter your username and password (for
your MySQL installation).

Once you have entered the details this form passes on the variables
'username' and 'password' to your script named kiekteki.php. This will then
process the information and connect to Mysql, this part does that:

<html>

<head>
<title>kiekteki</title>
</head>

<body>

<?php
$link = mysql_connect("localhost",$_POST['username'],$_POST['password'])or
die("Connect Error: ".mysql_error());
print "Successfully connected.\n";
mysql_close($link);
?>

</body>

</html>
and should be saved as kiekteki.php.

Do not change $_POST['username'] and $_POST['password'] these are the names
of the variables you are passing(posting) from your login script.

try it and see.

I would suggest that you try the tutorial at
http://www.php-mysql-tutorial.com/ I think you will find it much better.
Jul 28 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Rhino | last post by:
Can anyone point me to a good free XSLT Tutorial online? I looked for some a few months ago and didn't find anything very good. I'm hoping some of the experts here can point me to a good XSLT...
15
by: binnyva | last post by:
Hello Everyone, I have just compleated a JavaScript tutorial and publishing the draft(or the beta version, as I like to call it) for review. This is not open to public yet. The Tutorial is...
18
by: Xah Lee | last post by:
i've started to read python tutorial recently. http://python.org/doc/2.3.4/tut/tut.html Here are some quick critique: quick example: If the input string is too long, they don't truncate it,...
0
by: Joe Mayo | last post by:
I've recently updated the C# Tutorial at C# Station with a new addition, Lesson 17: Enums. The C# Tutorial may be found at http://www.csharp-station.com/Tutorial.aspx. Other updates include:...
10
by: Safalra | last post by:
When a poster in a forum I frequent said they were beginning to learn HTML, I thought I should direct them to a good HTML tutorial so that they wouldn't start using <blink> and the like....
11
by: Magnus Lycka | last post by:
While the official Python Tutorial has served its purpose well, keeping it up to date is hardly anyones top priority, and there are others who passionately create really good Python tutorials on...
7
by: Turbo | last post by:
I have a written a detailed html tutorial here:- http://sandy007smarty.seo.iitm.ac.in/2006/09/26/html-tutorial/ I know there are a couple of html tutorials out there. But its a tutorial without...
2
by: sara | last post by:
Hi All, I learned C++ long time ago and now I want to review all of its details in a short time like a week. I wonder if there is a good tutorial you know which I can read for this purpose....
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.