PDA

View Full Version : Another Error


Tyler
June 25th, 2007, 04:16 PM
For some reason there's always a t_string error www.darkrai.org/login/register.php (http://www.darkrai.org/login/register.php)

Please help


<?php
$self = $_Server['PJP'];
$username = $_Post['username'];
$password = $_Post['password'];
$email = $_Post['email'];
$msn = $_Post['msn'];
$submit = $_Post['submit'];
if( ( !$username ) or ( !$password ) or ( !$email ) or ( !$msn ) )
{
$form = "Please Enter the Information";
$form.="<form action=\"$self\" method=\"post\">";
$form.="Username: <input type=\"text\" name=\"username\"";
$form.=" value=\"$username\"><br>Password: ";
$form.="<input type=\"password\" name=\"password\"";
$form.=" value=\"$password\"><br>Email: ";
$form.="<input type=\"text\" name=\"msn\"";
$form.=" value=\"$msn\"><br>";
$form.="<input type=\"submit\" value=\"submit\">";
$form.="</form>";
echo( $form );
}
else
{
$conn = mysql_connect( "localhost", "u70386370", "1fed5f" )
or die("Could not connect");
$db = mysql_select_db( "d60353121", $conn )
or die("Could not find Database");
$sql = insert into login
( username, password, email, msn ) values
(\"$username\", password(\"$password\"), ( \"$email\"), (\"$msn\"); #Create the Query
$result = mysql_query( $sql, $conn )
or die(" Could not execute query");
if( $result ) { echo("New user $username added"); }
}
?>

Scizz
June 25th, 2007, 04:21 PM
$form.="<input type="submit\" value=\"submit\">";
You're not escaping the first ". Change it to:
$form.="<input type=\"submit\" value=\"submit\">";

Gecko
June 25th, 2007, 04:21 PM
You forgot a "; at the end of $form.=" value=\"$msn\"><br>

Tyler
June 26th, 2007, 12:24 AM
It Still doenst work, could it be my hosting?

Virtual Headache
June 26th, 2007, 10:01 AM
Your hosting isn't responsible for PHP errors like this.
I'd also advise you to try fixing it yourself first. Look at the line mentioned in the error code and try changing stuff. This will help you learn about all that stuff more quickly.

Anyway, it's working for me now, at öleast it's error free.
The form doesn't seem like it's submitting though.

I changed $sql = INSERT INTO login ( 'username', 'password', 'email', 'msn' ) VALUES ($username, password(\"$password\"), ( \"$email\"), (\"$msn\"); #Create the Query;
to
$sql = "INSERT INTO login ( 'username', 'password', 'email', 'msn' ) VALUES ($username, password(\"$password\"), ( \"$email\"), (\"$msn\"); #Create the Query";

<?php
$self = $_SERVER['PJP'];
$username = $_POST['username'];
$password = $_POST['password'];
$email = $_POST['email'];
$msn = $_POST['msn'];
$submit = $_POST['submit'];
if( ( !$username ) or ( !$password ) or ( !$email ) or ( !$msn ) )
{
$form = "Please Enter the Information";
$form.="<form action=\"$self\" method=\"post\">";
$form.="Username: <input type=\"text\" name=\"username\"";
$form.=" value=\"$username\"><br>Password: ";
$form.="<input type=\"password\" name=\"password\"";
$form.=" value=\"$password\"><br>Email: ";
$form.="<input type=\"text\" name=\"msn\"";
$form.=" value=\"$msn\"><br>";
$form.="<input type=\"submit\" value=\"submit\">";
$form.="</form>";
echo( $form );
}
else
{
$conn = mysql_connect( "localhost", "u70386370", "1fed5f" )
or die("Could not connect");
$db = mysql_select_db( "d60353121", $conn )
or die("Could not find Database");

$sql = "INSERT INTO login ( 'username', 'password', 'email', 'msn' ) VALUES ($username, password(\"$password\"), ( \"$email\"), (\"$msn\"); #Create the Query";
$result = mysql_query( $sql, $conn )
or die(" Could not execute query");
if( $result ) { echo("New user $username added"); }
}
?>

Tyler
June 26th, 2007, 07:18 PM
Thats not the problem. The Problem is; is that there's an error with the Submit button

Virtual Headache
June 26th, 2007, 07:51 PM
Thats not the problem. The Problem is; is that there's an error with the Submit button
When I view your file in my browser, the error is in a different line (line 29 IIRC).
The submit form showed up after I made the changes I mentioned in my first post.
Did you try using my version?