[advanced search]
Results from the most recent live auction are here.
21 members in the live chat room. Join Chat!
Register Rules & FAQ NP$ Store Active Threads Mark Forums Read
Go Back   NamePros.Com > Design and Development > Programming
User Name
Password

Old 05-30-2006, 09:18 AM   · #1
unknowngiver
Senior Member
 
Name: Zubair
Location: Ontario Canada
Trader Rating: (53)
Join Date: May 2005
Posts: 2,754
NP$: 724.15 (Donate)
unknowngiver is a name known to allunknowngiver is a name known to allunknowngiver is a name known to allunknowngiver is a name known to allunknowngiver is a name known to allunknowngiver is a name known to all
query wont run

Hey
whats wrong wid the query ? it wont work
PHP Code:
<?

$username
= $_GET['user'];
$pass = $_GET['pass'];
$email = $_GET['email'];
$registerpass = $_GET['registerpass'];
$dbusername="zubair";
$dbpassword="";
$database= "z_game";

if ((
$registerpass == "z3nixrul3s") && ($pass != '') && ($email !='') && ($username!='')) {
mysql_connect(localhost, $dbusername, $dbpassword);

@
mysql_select_db($database) or die( "Unable to select database");
$query= "INSERT INTO user (id, username,email,pass) VALUES ('', '$username','$email','$pass')";
mysql_query($query)or die('Error, insert query failed');
}
?>

or gives the error
Code:
Error, Insert Query Failed


Please register or log-in into NamePros to hide ads
unknowngiver is offline   Reply With Quote
Old 05-30-2006, 09:28 AM   · #2
SecondVersion
while ($awake){ code(); }
 
SecondVersion's Avatar
 
Name: Eric
Location: Kentucky
Trader Rating: (142)
Join Date: Mar 2005
Posts: 4,268
NP$: 1152.00 (Donate)
SecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond repute
Member of the Month
MOTM September 2005 Save a Life Child Abuse 9/11/01 :: Never Forget Baby Health Marrow Donor Program AIDS/HIV Breast Cancer Cystic Fibrosis Ethan Allen Fund Animal Cruelty Ethan Allen Fund Ethan Allen Fund Cancer Alzheimer's Protect Our Planet
1.) Why are you using $_GET?
2.) Try echo'ing $query and see what it prints.
__________________

SecondVersion.com - The Personal Blog of SecondVersion
Domain Name Portfolio - Get your free copy. - Version 1.0.3 now available!!
SecondVersion is offline   Reply With Quote
Old 05-30-2006, 09:33 AM   · #3
unknowngiver
Senior Member
 
Name: Zubair
Location: Ontario Canada
Trader Rating: (53)
Join Date: May 2005
Posts: 2,754
NP$: 724.15 (Donate)
unknowngiver is a name known to allunknowngiver is a name known to allunknowngiver is a name known to allunknowngiver is a name known to allunknowngiver is a name known to allunknowngiver is a name known to all
this is what i get :

Code:
INSERT INTO user (id, username,email,pass) VALUES ('', 'zubair','a','a')


I am using the GET statements because i am not making this for a website
i am making a Game in TURING [really old programming language ] and its almost impossible to make a game online..so i am using PHP to insert stuff from the game to a database and retract it from the database..using PHP...
unknowngiver is offline   Reply With Quote
Old 05-30-2006, 09:45 AM   · #4
SecondVersion
while ($awake){ code(); }
 
SecondVersion's Avatar
 
Name: Eric
Location: Kentucky
Trader Rating: (142)
Join Date: Mar 2005
Posts: 4,268
NP$: 1152.00 (Donate)
SecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond repute
Member of the Month
MOTM September 2005 Save a Life Child Abuse 9/11/01 :: Never Forget Baby Health Marrow Donor Program AIDS/HIV Breast Cancer Cystic Fibrosis Ethan Allen Fund Animal Cruelty Ethan Allen Fund Ethan Allen Fund Cancer Alzheimer's Protect Our Planet
k

Try this, instead of:
PHP Code:
mysql_query($query)or die('Error, insert query failed');


..

PHP Code:
mysql_query($query)or die(mysql_error());
__________________

SecondVersion.com - The Personal Blog of SecondVersion
Domain Name Portfolio - Get your free copy. - Version 1.0.3 now available!!
SecondVersion is offline   Reply With Quote
Old 05-30-2006, 10:32 AM   · #5
PoorDoggie
Soon to be RICHdoggie!
 
PoorDoggie's Avatar
 
Name: Tom
Location: UK
Trader Rating: (36)
Join Date: Jan 2005
Posts: 2,390
NP$: 300.50 (Donate)
PoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nice
dunno if this is a problem or not, but whenever you do a query from phpmyadmin with a autoincrement field, which I assume you have for "id" then it always puts "NULL" in for the id field ie:
PHP Code:
$query= "INSERT INTO user (id,username,email,pass) VALUES (NULL,'$username','$email','$pass')";

(also, have removed random spaces from before both cases of the username.)

To make sure I have the right code I always run a query from phpmyadmin first and then copy the code. I think that if the phpmyadmin code works there is no reason why it won't work un my code.
PoorDoggie is offline   Reply With Quote
Old 05-30-2006, 12:27 PM   · #6
Peter
NamePros Staff
 
Peter's Avatar
 
Name: Peter
Location: Scotland
Trader Rating: (47)
Join Date: Nov 2003
Posts: 4,337
NP$: 2039.40 (Donate)
Peter has much to be proud ofPeter has much to be proud ofPeter has much to be proud ofPeter has much to be proud ofPeter has much to be proud ofPeter has much to be proud ofPeter has much to be proud ofPeter has much to be proud ofPeter has much to be proud ofPeter has much to be proud of
Child Abuse Save The Children Save The Children
no need to put null in, he can just leave the id part out altogether:-

PHP Code:
$query= "INSERT INTO `user` (`username`,`email`,`pass`) VALUES ('$username','$email','$pass')";


I also put ` around the the field names and table name.
Peter is offline   Reply With Quote
Old 05-30-2006, 01:09 PM   · #7
MrBarby
NamePros Member
 
Trader Rating: (2)
Join Date: May 2006
Posts: 74
NP$: 0.00 (Donate)
MrBarby is on a distinguished road
mysql_connect(localhost, $dbusername, $dbpassword);

shouldnt the localhost be in speech marks?
MrBarby is offline   Reply With Quote
Old 05-30-2006, 04:47 PM   · #8
iNod
Eating Pie
 
iNod's Avatar
 
Name: Steve
Location: Canada
Trader Rating: (66)
Join Date: Nov 2004
Posts: 2,284
NP$: 91.30 (Donate)
iNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud of
Special Olympics AIDS/HIV Cystic Fibrosis Save The Children Baby Health Cystic Fibrosis
Hello,

If it is lower case which it is it is fine. If it was LOCALHOST or Localhost it is looking for a defined constant (define("PIE", $variable)
print PIE; would print what ever the variable $variable is equal too.

- Steve
__________________
RegisterDub.com - 200th Customer Milestone
ZuneParts.net - International Zune Parts and Accessories
FeaturedFont.com - One Top Free Font a Day!

Last edited by iNod : 05-30-2006 at 04:54 PM.
iNod is offline   Reply With Quote
Old 05-31-2006, 12:53 AM   · #9
Peter
NamePros Staff
 
Peter's Avatar
 
Name: Peter
Location: Scotland
Trader Rating: (47)
Join Date: Nov 2003
Posts: 4,337
NP$: 2039.40 (Donate)
Peter has much to be proud ofPeter has much to be proud ofPeter has much to be proud ofPeter has much to be proud ofPeter has much to be proud ofPeter has much to be proud ofPeter has much to be proud ofPeter has much to be proud ofPeter has much to be proud ofPeter has much to be proud of
Child Abuse Save The Children Save The Children
Originally Posted by MrBarby
mysql_connect(localhost, $dbusername, $dbpassword);

shouldnt the localhost be in speech marks?



well spotted I completely missed that.




Originally Posted by iNod
Hello,

If it is lower case which it is it is fine. If it was LOCALHOST or Localhost it is looking for a defined constant (define("PIE", $variable)
print PIE; would print what ever the variable $variable is equal too.

- Steve



I am sorry but that is just complete misinformation. A constant can be lower case as well and localhost in that command should have been in quotation marks.

It is true that most programmers use upper case when defining constants but it is not a requirement.

The following is taken from the php.net constants page:-

Quote:
The name of a constant follows the same rules as any label in PHP. A valid constant name starts with a letter or underscore, followed by any number of letters, numbers, or underscores. As a regular expression, it would be expressed thusly: [a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*

Example 13-1. Valid and invalid constant names


PHP Code:
<?php

// Valid constant names
define("FOO",    "something");
define("FOO2",    "something else");
define("FOO_BAR", "something more");

// Invalid constant names
define("2FOO",    "something");

// This is valid, but should be avoided:
// PHP may one day provide a magical constant
// that will break your script
define("__FOO__", "something");

?>
Quote:

Note: For our purposes here, a letter is a-z, A-Z, and the ASCII characters from 127 through 255 (0x7f-0xff).


Last edited by filth@flexiwebhost : 05-31-2006 at 01:02 AM.
Peter is offline   Reply With Quote
Closed Thread

NamePros is a revenue sharing forum.

Thread Tools

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


Site Sponsors
Buy Flash Arcade Game Script EscrowDNS Website Header Design
Advertise your business at NamePros
All times are GMT -7. The time now is 10:21 AM.


Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0