|
-
May 30th, 2004, 07:17 PM
#1
Thread Starter
Junior Member
Parse Error
PHP Code:
<?
<form method='post'>
Username
<input type='text' name='alias' value='' size='30' maxlength='25'>
<input type='password' name='pass' value='' size='30' maxlength='10'>
IP
<input type='hidden' name='myip' value='' size='30' maxlength='10'>
<input type='hidden' name='action' value='join'>
<input type='submit' name='' value='Submit!'>
mysql_query("INSERT INTO `users` VALUES (
'$alias',
'$pass',
'$myip');");
}
?>
Parse error on line 3
I don't see any problems
-
May 31st, 2004, 01:09 AM
#2
Re: Parse Error
Originally posted by Neden
PHP Code:
<?
<form method='post'>
Username
<input type='text' name='alias' value='' size='30' maxlength='25'>
<input type='password' name='pass' value='' size='30' maxlength='10'>
IP
<input type='hidden' name='myip' value='' size='30' maxlength='10'>
<input type='hidden' name='action' value='join'>
<input type='submit' name='' value='Submit!'>
mysql_query("INSERT INTO `users` VALUES (
'$alias',
'$pass',
'$myip');");
}
?>
Parse error on line 3
I don't see any problems
<form method='post'> is not PHP.
Whatever is not PHP, put outside the <? ?> tags.
-
Jun 1st, 2004, 01:20 AM
#3
Junior Member
Alternatively you could echo it inside the PHP-code.
PHP Code:
<?php
echo "<form method=\"post\">";
// Rinse-repeat for the rest of the HTML-tags and text
?>
Note that you should use double quotes for HTML-attributes, and that you need to escape these (with the backslash \ character) so PHP will print these out.
If there is a way to solve your problems, there is no need to worry; if there is no way to solve your problems, there is no point to worry.
-
Jun 1st, 2004, 07:35 PM
#4
Stuck in the 80s
Originally posted by KTottE
Alternatively you could echo it inside the PHP-code.
PHP Code:
<?php
echo "<form method=\"post\">";
// Rinse-repeat for the rest of the HTML-tags and text
?>
Note that you should use double quotes for HTML-attributes, and that you need to escape these (with the backslash \ character) so PHP will print these out.
Or do:
PHP Code:
<?php
echo '<form method="post">';
// Rinse-repeat for the rest of the HTML-tags and text
?>
So that no escaping is required.
-
Jun 3rd, 2004, 01:45 AM
#5
Junior Member
That's true, but then it should be noted that single quotes is only to be used when no evaluation is required, that is, only use them for printing out plain strings.
If you need echo to evaluate something, you need to use double quotes.
PHP Code:
// Yes:
echo 'Hello World!';
// Yes:
$string = "Hello World";
echo "This is my string:\n $string";
// No:
$string = "Hello World";
echo 'This is my string:\n $string';
I'm sure you probably know this already, The Hobo, but it's worth noting for Neden, so he doesn't use single/double quotes wrong
If there is a way to solve your problems, there is no need to worry; if there is no way to solve your problems, there is no point to worry.
-
Jun 3rd, 2004, 12:43 PM
#6
Stuck in the 80s
Re: Parse Error
Originally posted by Neden
PHP Code:
<?
<form method='post'>
Username
<input type='text' name='alias' value='' size='30' maxlength='25'>
<input type='password' name='pass' value='' size='30' maxlength='10'>
IP
<input type='hidden' name='myip' value='' size='30' maxlength='10'>
<input type='hidden' name='action' value='join'>
<input type='submit' name='' value='Submit!'>
mysql_query("INSERT INTO `users` VALUES (
'$alias',
'$pass',
'$myip');");
}
?>
Parse error on line 3
I don't see any problems
A few more things to note:
1. You have no closing form tag.
2. You have no name for your submit button.
3. You're using native globals. Use superglobals (see topmost thread in this forum).
4. Your code is written badly. You need to create some kind of conditional:
PHP Code:
if (isset($_POST['submit'])) {
// call your query here
} else {
// output your form here
}
Or if you want the form to reappear when you're done, do this:
PHP Code:
if (isset($_POST['submit'])) {
// call your query here
}
// output your form here
If you leave it your way, you're going to get a lot of blank records.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|