[SOLVED]Parse error: parse error, unexpected '?' in c:\.....

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Jascn
Forum Newbie
Posts: 7
Joined: Fri Nov 07, 2003 2:10 pm

[SOLVED]Parse error: parse error, unexpected '?' in c:\.....

Post by Jascn »

Hello,

Im working through a tutorial and am having difficulty with this lesson. I have double checked the code it has me write and I can not seem to locate where my mistake is.

Im getting this error:
Parse error: parse error, unexpected '?' in c:\program files\apache group\apache\htdocs\create_db.php on line 11

http://localhost/create_db.php

Code: Select all

<?php
$conn = @mysql_connect("localhost","root","password")
or die("Sorry - unable to connect to MySQL');
$rs1=	@mysql_create_db( $db );
$rs2=	@mysql_list_dbs($conn);
for($row=0; $row < mysql_num_rows($rs2); $row++)
&#123; $list .= mysql_tablename($rs2,$row)." | "; &#125;
?>
<html><head><title> Create New Database</title></head>
<body>
<form action="<?php echo($PHP_SELF); ?>" method="post">
Current databases: <?php echo($list); ?> <hr>
Name:<input type="text" name="db">
<input type="submit" values="create database">
</form></body></html>
I have register_globals ON, but that didnt reslove my problem.

Could you please assist me?
Last edited by Jascn on Fri Nov 07, 2003 7:40 pm, edited 1 time in total.
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

echo is a keyword, not a function. use it as follows:

Code: Select all

echo "something\n";
Jascn
Forum Newbie
Posts: 7
Joined: Fri Nov 07, 2003 2:10 pm

Post by Jascn »

weird.... that code i have in the first post is copied character for character from my tutorial book.

anyhow, Ive attempted your suggestion and still am recieving the same parse error.

Code: Select all

<?php
$conn = @mysql_connect("localhost","root","5suhide7")
or die("Sorry - unable to connect to MySQL');
$rs1=	@mysql_create_db( $db );
$rs2=	@mysql_list_dbs($conn);
for($row=0; $row < mysql_num_rows($rs2); $row++)
&#123; $list .= mysql_tablename($rs2,$row)." | "; &#125;
?>
<html><head><title> Create New Database</title></head>
<body>
<form action="<?php echo "$PHP_SELF\n"; ?>" method="post">
Current databases: <?php echo"$list"; ?> <hr>
Name:<input type="text" name="db">
<input type="submit" values="create database">
</form></body></html>
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

Code: Select all

<form action="<?php echo $PHP_SELF; ?>" method="post">
try that.
Jascn
Forum Newbie
Posts: 7
Joined: Fri Nov 07, 2003 2:10 pm

Post by Jascn »

Same error....

Code: Select all

<?php
$conn = @mysql_connect("localhost","root","5suhide7")
or die("Sorry - unable to connect to MySQL');
$rs1=	@mysql_create_db( $db );
$rs2=	@mysql_list_dbs($conn);
for($row=0; $row < mysql_num_rows($rs2); $row++)
&#123; $list .= mysql_tablename($rs2,$row)." | "; &#125;
?>
<html><head><title> Create New Database</title></head>
<body>
<form action="<?php echo $PHP_SELF; ?>" method="post">
Current databases: <?php echo $list; ?> <hr>
Name:<input type="text" name="db">
<input type="submit" values="create database">
</form></body></html>
Any other suggestions?
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

Code: Select all

$conn = @mysql_connect("localhost","root","password")
or die("Sorry - unable to connect to MySQL");
$rs1=   @mysql_create_db( $db );
$rs2=   @mysql_list_dbs($conn);
for($row=0; $row < mysql_num_rows($rs2); $row++)
{
   $list .= mysql_tablename($rs2,$row)." | ";
}
?>
<html><head><title> Create New Database</title></head>
<body>
<form action="<?php echo($PHP_SELF); ?>" method="post">
Current databases: <?php echo($list); ?> <hr>
Name:<input type="text" name="db">
<input type="submit" values="create database">
</form></body></html>
Jascn
Forum Newbie
Posts: 7
Joined: Fri Nov 07, 2003 2:10 pm

RE:

Post by Jascn »

Well we are on to something here...
Last edited by Jascn on Fri Nov 07, 2003 3:29 pm, edited 1 time in total.
Jascn
Forum Newbie
Posts: 7
Joined: Fri Nov 07, 2003 2:10 pm

Post by Jascn »

LiLpunkSkateR wrote:

Code: Select all

$conn = @mysql_connect("localhost","root","password")
or die("Sorry - unable to connect to MySQL");
$rs1=   @mysql_create_db( $db );
$rs2=   @mysql_list_dbs($conn);
for($row=0; $row < mysql_num_rows($rs2); $row++)
{
   $list .= mysql_tablename($rs2,$row)." | ";
}
?>
<html><head><title> Create New Database</title></head>
<body>
<form action="<?php echo($PHP_SELF); ?>" method="post">
Current databases: <?php echo($list); ?> <hr>
Name:<input type="text" name="db">
<input type="submit" values="create database">
</form></body></html>
What is different here, than in my original post???
This made it start working. Id like to learn from my mistake.
Thanks for the help too!

Note: I found the need to add <?php to the begginning , probably just a copy/paste error you made.

Here is my error free code now:

Code: Select all

&lt;?php 
$list = " ";
$conn = @mysql_connect("localhost","root","5suhide7") 
or die("Sorry - unable to connect to MySQL"); 
$rs1=   @mysql_create_db( $db ); 
$rs2=   @mysql_list_dbs($conn); 
for($row=0; $row &lt; mysql_num_rows($rs2); $row++) 
&#123; $list .= mysql_tablename($rs2,$row)." | "; &#125; 
?&gt; 
&lt;html&gt;&lt;head&gt;&lt;title&gt; Create New Database&lt;/title&gt;&lt;/head&gt; 
&lt;body&gt; 
&lt;form action="&lt;?php echo($PHP_SELF); ?&gt;" method="post"&gt; 
Current databases: &lt;?php echo($list); ?&gt; &lt;hr&gt; 
Name:&lt;input type="text" name="db"&gt; 
&lt;input type="submit" values="create database"&gt; 
&lt;/form&gt;&lt;/body&gt;&lt;/html&gt;
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

Opened it in winSyntax

Syntax highlighting stopped and turned green after this line:

Code: Select all

or die("Sorry - unable to connect to MySQL');
so i changed it to this:

Code: Select all

or die("Sorry - unable to connect to MySQL");
you just tried to end your quotes with an apostraphy (sp?)
Last edited by d3ad1ysp0rk on Fri Nov 07, 2003 3:51 pm, edited 1 time in total.
Jascn
Forum Newbie
Posts: 7
Joined: Fri Nov 07, 2003 2:10 pm

Post by Jascn »

THANK YOU

I see the light.
/slaps self with large trout[/b]

Last question....
What program you editing in? (im using notepad)
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

Opened it in winSyntax
;)
Jascn
Forum Newbie
Posts: 7
Joined: Fri Nov 07, 2003 2:10 pm

Post by Jascn »

thanks again.

[/being stupid]
qads
DevNet Resident
Posts: 1199
Joined: Tue Apr 23, 2002 10:02 am
Location: Brisbane

Post by qads »

checkout viewtopic.php?t=6288 if your looking for a editor :).
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

Dreamweaver 18% (31 votes)
and you wonder why i'm not going to rely on that thread to help me get a good php editor.. :P
qads
DevNet Resident
Posts: 1199
Joined: Tue Apr 23, 2002 10:02 am
Location: Brisbane

Post by qads »

what is wrong with dreamwaver? 8O, it might not be the greatest but when it comes to php and design at the same time, it is better then most of WYSIWYG editors...


frontpage any one? :lol:
Post Reply