 |
Account Login
|
 |
 |
Latest Articles
|
 |
 |
IRC Channel
|
 |
 |
Associates
|
 |
 |
Associates
|
 |
|
 |
 |
|
 |
11-23-2007, 12:54 PM
|
#1 (permalink)
|
|
The Prestige
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
|
register function
What's wrong with it? :S:S
php Code:
public function user_register ($user_name, $user_pass, $user_email, $user_firstname, $user_surname, $user_country, $user_location, $user_age, $user_access) { $sql = sprintf(" INSERT INTO `%s` SET `%s` = '%s', `%s` = '%s', `%s` = '%s', `%s` = '%s', `%s` = '%d', `%s` = '%s', `%s` = '%s', `%s` = '%s', `%s` = '%s, `%s` = '%s'", $this-> db-> table[ 'users'], $this-> db-> col[ 'user_name'], $user_name, $this-> db-> col[ 'user_pass'], md5($user_pass), $this-> db-> col[ 'user_email'], $user_email, $this-> db-> col[ 'user_firstname'], $user_firstname, $this-> db-> col[ 'user_access'], $user_access, $this-> db-> col[ 'user_surname'], $user_surname, $this-> db-> col[ 'user_country'], $user_country, $this-> db-> col[ 'user_location'], $user_location, $this-> db-> col[ 'user_registered'], $this-> now(), $this-> db-> col[ 'user_age'], $user_age); $query = $this-> db-> query($sql); if(! $query) { return false; } return true; }
php Code:
if($error == 0) { if($tanaxia[ 'user']-> user_register($user_name, $user_pass, $user_email, $user_firstname, $user_surname, $user_country, $user_location, $user_age, '0')) { echo 'Successfully registered!'; } else { echo '<font color="red">Something went wrong!</font><br />'; } }
Gives me "Something went wrong!" all the time I try to register :S
|
|
|
|
11-23-2007, 01:17 PM
|
#2 (permalink)
|
|
The Reckoner
Join Date: Sep 2007
Posts: 437
Thanks: 22
|
Try changing:
to
PHP Code:
if (!mysql_affected_rows())
__________________
Any fool can write code that a computer can understand. Good programmers write code that humans can understand.
|
|
|
|
11-23-2007, 01:42 PM
|
#3 (permalink)
|
|
The Prestige
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
|
Yea, it said "Successfully registered!", but when I check the database, the table is empty =//
|
|
|
|
11-23-2007, 01:53 PM
|
#4 (permalink)
|
|
The Reckoner
Join Date: Sep 2007
Posts: 437
Thanks: 22
|
Oops, I made an error. Remove the ! from the condition.
PHP Code:
if (!mysql_affected_rows())
to
PHP Code:
if (mysql_affected_rows())
Although going off your last message, this will still fail. This leads me to believe that the problem is actually in the query.
__________________
Any fool can write code that a computer can understand. Good programmers write code that humans can understand.
|
|
|
|
11-23-2007, 01:56 PM
|
#5 (permalink)
|
|
Moderateur
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
|
The SQL query is malformed. `%s` = '%s, is missing a single quotation mark before the comma. You really, really need some form of error reporting -- I can't imagine posting every little problem here being an efficient solution to your typing mistakes.
|
|
|
|
11-23-2007, 02:10 PM
|
#6 (permalink)
|
|
Super Moderator
Join Date: Sep 2007
Posts: 165
Thanks: 0
|
Also, if you are going to the trouble of getting each column name, it would be much easier to read and less coding if you make a function to do all the above for you, and you make an array to populate the query....
|
|
|
|
11-23-2007, 02:10 PM
|
#7 (permalink)
|
|
La Vida es Sueño
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
|
This will give you some nice feedback on the syntax errors:
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
|
|
|
11-23-2007, 02:39 PM
|
#8 (permalink)
|
|
The Prestige
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
|
Yea, I have no idea what you talk about bluesaga :P
Thanks salathe!
I also took wildhoneys advice, and after I fixed the thing that salathe pointed out, it gave me this:
Code:
Unknown column 'user_name' in 'field list'
|
|
|
|
11-23-2007, 02:50 PM
|
#9 (permalink)
|
|
The Wanderer
Join Date: Nov 2007
Posts: 12
Thanks: 0
|
That means that there is no user_name column in the table. :)
|
|
|
11-23-2007, 03:28 PM
|
#10 (permalink)
|
|
The Prestige
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
|
:S:S:S
There is a user_name column in the table =//
|
|
|
|
11-23-2007, 03:48 PM
|
#11 (permalink)
|
|
The Contributor
Join Date: Nov 2007
Location: France, near Paris
Posts: 53
Thanks: 6
|
Are you sure you're working on the right db ?
Are you sure of the content of your hashtable attribute "col" ?
solution of this kind of problem is often an oblivion :)
|
|
|
11-23-2007, 04:44 PM
|
#12 (permalink)
|
|
The Prestige
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
|
LOOL
Yea, rofl.. fixed it ;P
Thanks!
|
|
|
|
11-25-2007, 12:42 AM
|
#13 (permalink)
|
|
La Vida es Sueño
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
|
Let me guess, wrong database :) ?
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
|
|
|
11-25-2007, 10:21 AM
|
#14 (permalink)
|
|
The Prestige
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
|
hahha, yeaaa, lol ;)
I'm such a fool :p
|
|
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Hybrid Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|