-
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
:confused:
-
Re: Parse Error
Quote:
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
:confused:
<form method='post'> is not PHP.
Whatever is not PHP, put outside the <? ?> tags.
-
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.
-
Quote:
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.
-
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 :)
-
Re: Parse Error
Quote:
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
:confused:
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.