Click to See Complete Forum and Search --> : MySQL and PHP


Sux0rZh@jc0rz
12-23-2003, 05:30 PM
ok. just got back from being bedridden for 2 weeks.. (uhg. hate bein sick. got hit way to hard.) and i am back to this issue:

mysql and php... a match made in hell.(well not really but i cant get it to work.)

i get free SQL hosting and i have a php host too. so heres the page: register.html and register.php

register.html <form action="register.php" method="POST">
<p class="MainText" style="text-align:center;">Username: <input type="text" name="username" size="11" /><br /> &nbsp;Password: <input type="password" name="password" size="11" /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Email: <input type="text" name="email" size="11" /><br /></p>
<p class="MainText" style="text-align:center;"><input class="Submit" type="submit" value="Submit" /></p>
</form>

and register.php<?php

$username = "$_POST['username']";
$password = "$_POST['password']";
$email = "$_POST['email']";

$host = "sorry";
$dbusername = "sorry";
$dbpassword = "sorry";
$database = "sorry";

$signup = "INSERT INTO Users (id, created, username, userpass, email) VALUES ('', NOW(), '$username', '$password', '$email')";
$test = "INSERT INTO `Users` (`id`, `created`, `username`, `userpass`, `email`) VALUES ('', '666', 'xaxei', 'pass', 'xaxei@hotmail.com')";
$create = "CREATE TABLE `test` (`bob` TINYINT NOT NULL )";

mysql_connect($host, $username, $password);
mysql_select_db($database);
mysql_query($test);
mysql_close();

echo "Username: " $_POST['username'];<br />
echo "Password: " $_POST['password'];<br />
echo "Email: " $email;<br />
?>

pyro I don't see why this wont work. its annoying me. if i tell it to do $test it wont work, $create wont work and $signup wont work so im confused. it must be something stupid and im sure you'll be able to tell me what it is! (please?) its really annoying me :mad: ... anyone else can help too=P
also, i use phpmyadmin to check the database and i can give u all the passwords and information if u need to fix this cause i have no clue why it wont work and iv been working on it for a while and with this on top of being sick i just want to give up!

much thanks in advance

Khalid Ali
12-23-2003, 05:56 PM
you did not say that if you are getting any values from the form at all?..

pyro
12-23-2003, 06:10 PM
You've got several errors (that I notice just by taking a quick glance - perhaps there are others).

The first three lines and the last three lines of code.

The $_POST variables should not be contained in double quotes. Remove them, and that will be better.

And, at the bottom, you need to pass the values to your echo construct a bit differently. Try this:

echo "Username: ".$_POST['username']."<br />"; # did you mean to use $_POST for this one
echo "Password: ".$_POST['password']."<br />"; # and this one
echo "Email: ".$email."<br />"; # but not this one?

Sux0rZh@jc0rz
12-24-2003, 02:11 PM
ty much pyro for the tip about the quotes. and the echo works now... but the stupid database still won't work.

pyro
12-24-2003, 02:13 PM
Is the table `Users` capitalized? Or, are you getting any errors?

Sux0rZh@jc0rz
12-24-2003, 02:18 PM
yes. Users is how it is in the database. Ima PM you some details and see if you can see whats wrong.

pyro
12-24-2003, 02:20 PM
Ok, I'll take a look at it later. Right now, I'm going to go snowblow off our ice rink. ;)

Sux0rZh@jc0rz
12-25-2003, 05:48 PM
you ok pyro? you didnt die in a horrible ice skating accident did ya?

Paul Jr
12-25-2003, 05:58 PM
Originally posted by Sux0rZh@jc0rz
you ok pyro? you didnt die in a horrible ice skating accident did ya?
Maybe he fell in... it got kinda rainy here, and things melted a bit.

pyro
12-25-2003, 06:23 PM
hehe... Still alive and kicking, even after a day of skiing. Wanted to be out on a snowboard, but the rest of the group was on skis, so I was, as well. Gosh, I love winter... :p

Paul Jr
12-25-2003, 09:29 PM
Originally posted by pyro
hehe... Still alive and kicking, even after a day of skiing. Wanted to be out on a snowboard, but the rest of the group was on skis, so I was, as well. Gosh, I love winter... :p
Whooo! I love to ski! WOOOO!!!
But snowboarding sucks. :rolleyes:

Sux0rZh@jc0rz
12-26-2003, 03:44 PM
k pyro. i revamped my register.php but i get keep getting a parsing error on line 8. know what the problem may be? <?php

$username = $_POST['username'];
$password = $_POST['password'];
$email = $_POST['email'];
$created = Now()

$signup = "INSERT INTO `Users` (`id`, `created`, `username`, `userpass`, `email`) VALUES ('', '$created', '$username', '$password', '$email')";
$test = "INSERT INTO `Users` (`id`, `created`, `username`, `userpass`, `email`) VALUES ('', Now(), 'xaxei', 'xaxexi', 'xaxei@hotmail.com')";
$create = "CREATE TABLE `test` (`bob` TINYINT NOT NULL )";

mysql_connect ("localhost", "srry", "srry") or die ("I cannot connect to the database because: " . mysql_error());
mysql_select_db ("srry");
mysql_query($create);
mysql_close();

echo "Username: " . $username . "<br />";
echo "Password: " . $password . "<br />";
echo "Email: " . $email . "<br />";
echo "Created: " . $created . "<br />";

?>

pyro
12-26-2003, 04:15 PM
What error are you getting?

Sux0rZh@jc0rz
12-26-2003, 04:44 PM
Parse error: parse error in public_html/xaxei/register.php on line 8

Sux0rZh@jc0rz
12-26-2003, 04:50 PM
duh! omg! i forgot a ; after Now()... god. i spent like 30 minutes trying to figure out what was wrong with line 8 instead of what was missing from line 6. *smacks head*

Sux0rZh@jc0rz
12-26-2003, 05:17 PM
ok, yay! it all works now. the users are added to the database now. yay!

pyro
12-26-2003, 05:44 PM
Yes, I saw that after I posted to tell you to post the error message, but didn't have time to let you know. ;)

Anyway, it is always a good idea to look on the line before when you get a parse error.