Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 02-04-2003, 07:42 PM   #1 (permalink)
trevor
Code Monkey
 
Join Date: Jan 2003
Location: Canada
Posts: 91
trevor is on a distinguished road
ok, what is wrong with this code?

I cant figure this one out. What this page does is it gets the user info from register.php and if it is all there, it inserts it into the database. if not it tells you what is wrong.

ok my error is:
PHP Parse error: parse error, unexpected T_STRING in /var/www/htdocs/register2.php on line 34

PHP Code:
<?
include("connect.php");

$active "1";

$username=$_GET['username'];
$password=$_GET['password'];
$password2=$_GET['password2'];
$email=$_GET['email'];
$gender=$_GET['gender'];
$age=$_GET['age'];

$ok=0;
while(
$ok != 1) {
if ((
$password == "" ) or ($password2 == "") or ($email == "" ) or ($username == "" ))
{
print(
"<font color="red"> There Was an Error in Your Submition: Some Fields Were Not Entered <br> All Fields Must Be Filled In!</font>");  //line 34
print("<br>press back on your browser or click <a href="register.php">here</a> to go back.");
}
$query "select username from users";
$result mysql_query($query$db)
   or die(
"****");

while (
$row mysql_fetch_array($result)) {

elseif (
$username == $row["username"]) {
print(
"<font color="red"> There Was an Error in Your Submition: Username already Registered <br> All Fields Must Be Filled In!</font>");
print(
"<br>press back on your browser or click <a href="register.php">here</a> to go back.");
}
elseif (
$password != $password2) {
print(
"<font color="red" There Was an Error in Your Submition: Passwords don't match <br> All Fields Must Be Filled In!</font>");
}


$Pattern ".+@.+\..+";
elseif (!
eregi($Pattern$Array["email"])) {
print(
"<font color="red"> There Was an Error in Your Submition: Not A Correct Email Address <br> All Fields Must Be Filled In!</font>");
print(
"<br>press back on your browser or click <a href="register.php">here</a> to go back.");
}

else
{
$ok=1;
}
}
$query "insert into users values('0','$username','$password','$active','$email','$gender','$age','')";

if (@
mysql_query($query$db)) {
  print(
"<center><br><br> You Are Now Registered Under The Nick $username <br> <a href='index.php'> Return To Login</a> </center>");
} else {
    print(
"error");
}
}
mysql_close($db);
?>
WTF?!?!?

thanks all, its probably embarassingly obvious

Trevor
trevor is offline   Reply With Quote
Old 02-04-2003, 07:45 PM   #2 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,446
sde is on a distinguished road
try escaping your quotes inside other quotes:

PHP Code:
print("<font color=\"red\"> There Was an Error in Your Submition: Username already Registered <br> All Fields Must Be Filled In!</font>"); 
sde is offline   Reply With Quote
Old 02-04-2003, 08:29 PM   #3 (permalink)
trevor
Code Monkey
 
Join Date: Jan 2003
Location: Canada
Posts: 91
trevor is on a distinguished road
so thats what those /" are for. I just took out the " all together and it worked. then after about a million logical errors she works!!

thanks man,

Trevor
trevor is offline   Reply With Quote
Old 02-04-2003, 10:09 PM   #4 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,446
sde is on a distinguished road
sure =) .. i usually avoid quotes all together unless i know there is going to, our could be content with a space in the middle.

another option is to use single quotes. i've been doing this lately to be safe.

have fun !
sde is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cisco Code breaking sde Code Newbie News 0 05-21-2004 07:10 AM
Microsoft probes Windows code leak redhead Code Newbie News 0 02-13-2004 12:41 AM
whats wrong with this code trevor PHP 7 04-01-2003 06:00 PM


All times are GMT -8. The time now is 05:19 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting