473,748 Members | 2,578 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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>Co nnect Server</title></head>
<body>
<?
$link =
mysql_connect(" localhost",$_PO ST['username'],$_POST['password'])or
die("Connect Error: ".mysql_error() );
print "Successful ly connected.\n";
mysql_close($li nk);
?>
</body>
</html>
Iobviously typed in my own username and password instead of 'username'
and 'password' in the line
"mysql_connect( "localhost",$_P OST['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\l ogon.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 1480
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>Co nnect Server</title></head>
<body>
<?
$link =
mysql_connect(" localhost",$_PO ST['username'],$_POST['password'])or
die("Connect Error: ".mysql_error() );
print "Successful ly connected.\n";
mysql_close($li nk);
?>
</body>
</html>
Iobviously typed in my own username and password instead of 'username'
and 'password' in the line
"mysql_connect( "localhost",$_P OST['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\l ogon.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>Co nnect Server</title></head>
<body>
<?
$link =
mysql_connect ("localhost",$_ POST['username'],$_POST['password'])or
die("Connec t Error: ".mysql_error() );
print "Successful ly connected.\n";
mysql_close($li nk);
?>
</body>
</html>
Iobviously typed in my own username and password instead of 'username'
and 'password' in the line
"mysql_connec t("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\l ogon.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>Co nnect Server</title></head>
<body>
<? php
$link = mysql_connect(" localhost",$_PO ST["*****"],$_POST["*****"])or
die("Connect Error: ".mysql_error() );
print "Successful ly connected.\n";
mysql_close($li nk);
?>
</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\l ogon.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>Co nnect Server</title></head>
<body>
<?
$link =
mysql_connect(" localhost",$_PO ST['username'],$_POST['password'])or
die("Connect Error: ".mysql_error() );
print "Successful ly connected.\n";
mysql_close($li nk);
?>
</body>
</html>
Iobviously typed in my own username and password instead of
'username' and 'password' in the line
"mysql_connect( "localhost",$_P OST['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\l ogon.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>Co nnect Server</title></head>
<body>
<? php
$link = mysql_connect(" localhost",$_PO ST["*****"],$_POST["*****"])or
die("Connect Error: ".mysql_error() );
print "Successful ly connected.\n";
mysql_close($li nk);
?>
</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\l ogon.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.databas e.mysql
Newsscanner <fr******@NOSPA M.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>Co nnect Server</title></head>
| <body>
| <?
| $link =
| mysql_connect(" localhost",$_PO ST['username'],$_POST['password'])or
| die("Connect Error: ".mysql_error() );
| print "Successful ly connected.\n";
| mysql_close($li nk);
| ?>
| </body>
| </html>
| Iobviously typed in my own username and password instead of 'username'
| and 'password' in the line
| "mysql_connect( "localhost",$_P OST['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\l ogon.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.p hp" 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",'myU sername','myPas sword')
---------------------------------------------------------------
jn******@yourpa ntsyahoo.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.databas e.mysql
Newsscanner <fr******@NOSPA M.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>Co nnect Server</title></head>
| <body>
| <?
| $link =
| mysql_connect(" localhost",$_PO ST['username'],$_POST['password'])or
| die("Connect Error: ".mysql_error() );
| print "Successful ly connected.\n";
| mysql_close($li nk);
| ?>
| </body>
| </html>
| Iobviously typed in my own username and password instead of 'username'
| and 'password' in the line
| "mysql_connect( "localhost",$_P OST['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\l ogon.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.p hp" 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",'myU sername','myPas sword')
---------------------------------------------------------------
jn******@yourpa ntsyahoo.com.au : Remove your pants to reply
---------------------------------------------------------------

I do, but when I slot it in, as in this:
"<html>
<head><title>Co nnect Server</title></head>
<body>
<?
$link = mysql_connect(" localhost",$_PO ST['*****'],$_POST['********'])or
die("Connect Error: ".mysql_error() );
print "Successful ly connected.\n";
mysql_close($li nk);
?>
<form method="POST" action="kiektek i.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\k iekteki.php on line 5

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

Warning: mysql_connect() [function.mysql-connect]: Access denied for
user 'ODBC'@'localho st' (using password: NO) in C:\Program Files\Abyss
Web Server\htdocs\k iekteki.php on line 5
Connect Error: Access denied for user 'ODBC'@'localho st' (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>Co nnect Server</title></head>
<body>
<?
$link =
mysql_connec t("localhost",$ _POST['username'],$_POST['password'])or
die("Conne ct Error: ".mysql_error() );
print "Successful ly connected.\n";
mysql_close($li nk);
?>
</body>
</html>
Iobviously typed in my own username and password instead of 'username'
and 'password' in the line
"mysql_conne ct("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\Abys s Web Server\htdocs\l ogon.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,
Newsscanne r.


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>Co nnect Server</title></head>
<body>
<? php
$link = mysql_connect(" localhost",$_PO ST["*****"],$_POST["*****"])or
die("Connect Error: ".mysql_error() );
print "Successful ly connected.\n";
mysql_close($li nk);
?>
</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\l ogon.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.databas e.mysql
Newsscanner <fr******@NOSPA M.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>Connec t Server</title>
</head>
<body>
<form method="POST" action="kiektek i.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",$_PO ST['username'],$_POST['password'])or
die("Connect Error: ".mysql_error() );
print "Successful ly connected.\n";
mysql_close($li nk);
?>

</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
2931
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 tutorial..... -- Rhino --- rhino1 AT sympatico DOT ca "There are two ways of constructing a software design. One way is to make it
15
4228
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 avaliable at... http://www.geocities.com/binnyva/code/javascript/advanced_tutorial/ If any of you could spare the time, please have a look at my tutorial
18
1955
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, but return it unchanged; this will mess up your column lay-out but that's usually better than the alternative, which would be lying about a value. (If you really want truncation you can always add a slice operation, as in
0
1781
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: 1. Downloadable source code. 2. All example programs run on-line as NTD apps. 3. A support forum for discussing the Tutorial.
10
3085
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. Remembering that this group has discussed HTML tutorials several times in the past, I searched the Google Groups archives, but all I can find are tutorials unfortunately demonstrating Flavell's Law. Searching the internet, the only accurate tutorials for...
11
2935
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 the web. I think 'A Byte of Python' by Swaroop C H is a good beginners tutorial, and 'Dive Into Python' by Mark Pilgrim is a good tutorial for more experienced programmers.
7
2253
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 links!! Everything in one page. Please leave a comment if you like it.
2
2108
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. Thanks a lot.
0
8996
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9562
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9386
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9254
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8255
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6078
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4608
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3319
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2217
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.