|
-
Aug 12th, 2001, 08:25 AM
#1
Thread Starter
Member
Problem writing to the database - php
Code:
<html>
<head></head>
<body><form method="post" action="register.php">
Name: <input type="text" name="name"> <br>
Age:</td><td> <input type="text" name="age"> <br>
Country: </td><td><input type="text" name="country"> <br>
Email: </td><td><input type="text" name="email"> <br>
Username: <input type="text" name="username"> <br>
Password:</td><td> <input type="text" name="password"> <br>
Gender: </td><td><input type="text" name="gender"> <br>
<input type="Submit" name="submit" value="Registrer"><br>
</form>
<?
IF ("$submit") {
$host = "*";
$user = "*";
$pass = "*";
if (!$db = @mysql_connect("$host","$user", "$pass")) {
$db_error = "couldn't connect.";
do_error($db_error);
}
{mysql_pconnect ("$host","$user");
}
mysql_select_db("hacker");
$sql = "insert into user(name, age, country, email, username, password, gender) values('$name', '$age', '$country', '$email', '$username', '$password', '$gender')";
$result = mysql_query($sql);
$ID = mysql_insert_id();
Print("Konto opprettet!");
}
?>
</body>
</html>
This thingy dosen't seem to write to the database, but it does connect.
Any ideas?
-
Aug 12th, 2001, 11:29 AM
#2
well,
Code:
{mysql_pconnect ("$host","$user");
}
mysql_select_db("hacker");
$sql = ("insert into user(name, age, country, email, username, password, gender) values('$name', '$age', '$country', '$email', '$username', '$password', '$gender')");
$result = mysql_query($sql);
$ID = mysql_insert_id();
Print("Konto opprettet!");
}
?>
why do you have those brackets (bold) there? and you forgot to add some more brackets see bold, try that and see what you get.
-
Aug 12th, 2001, 01:14 PM
#3
Thread Starter
Member
if dosn't seem to work.. 
Could it have anything to do with the config of the database?
-
Aug 12th, 2001, 01:27 PM
#4
ok did you add { or ( you need to add the latter to the $sql statement. are you getting any errors? now you said it connects just fine but it just won't save anything? am I right.
-
Aug 12th, 2001, 01:51 PM
#5
Thread Starter
Member
I added ( and ) , cause when I added the { i got:
Parse error: parse error in /public_html/register.php on line 44
Thats this line: $sql = "insert into user(name, age....
Your right, it does connect, but it dosn't save anything...
-
Aug 12th, 2001, 02:21 PM
#6
you can try to do it this way.
Code:
mysql_pconnect($host, $user, $pass) or die("error opening the MySQL server");
mysql_select_db("hacker") or die("error opening the MySQL Database");
$sql_insert = ("insert into user(name, age, country, email, username, password, gender) values('$name', '$age', '$country', '$email', '$username', '$password', '$gender')");
$result = mysql_query($sql_insert);
$ID = mysql_insert_id();
Print("Konto opprettet!");
//for debugging
{
print("$sql_insert");
}
and take out (delete) this
Code:
if (!$db = @mysql_connect("$host","$user", "$pass")) {
$db_error = "couldn't connect.";
do_error($db_error);
}
try that and see what you get. can you check you error.log and see if/what error you have when you did this. if this doesn't work i one more thing.
change the form action to this
action="<? echo $PHP_SELF ?>">
-
Aug 13th, 2001, 12:52 AM
#7
Thread Starter
Member
Access denied for user: '[email protected]' (Using password: YES)
Why? I've no idea!
Guess it's something to do with the config of the database?!
Just gotta keep trying til I get it right i guess.
Thanx for your help! =)
-
Aug 13th, 2001, 06:49 AM
#8
yup I would talk to the server guys about that.
-
Aug 13th, 2001, 10:15 AM
#9
Thread Starter
Member
ok, now i got access.
But, guess what.. still nothing happens.
I think I'll just start all over again.
-
Aug 13th, 2001, 10:32 AM
#10
so what error do you receive now?
-
Aug 13th, 2001, 11:54 AM
#11
Thread Starter
Member
Ohh, i got it to work!!!
Love you guys!!!
*happy boy*
This is what i love about programing!
-
Aug 13th, 2001, 12:09 PM
#12
cool, but what was the problem. let yus know who or if you fixed it.
-
Aug 13th, 2001, 12:17 PM
#13
Thread Starter
Member
I not sure why, but i changed a field in the database from int to char. But it was supposed to hold figures so..
-
Aug 13th, 2001, 01:33 PM
#14
Thread Starter
Member
Btw..
I'm trying to make a little game. Should I a) have all the data in one huge database or b) divide it into smaller ones?
-
Aug 13th, 2001, 05:45 PM
#15
that would be totally up to you. if you want to seperate it so you know where everything is then fine.
But if you do split it up and you have a lot and I mean a lot of information then it would improve the access time, as opposed to everything stuffed in one table.
but if you don't have a lot of information than I wouldn't worry about it.
what other info would you have execpt wha tyou have here?
-
Aug 14th, 2001, 10:08 AM
#16
Thread Starter
Member
I was thinking of haveing this:
money, points, rank, bytes, protection, and skills.
Would also have log in screen, attack code and a formula of creation bytes ever 10 minutes or so..
But that shouldn't mean more stuff in the database?
-
Aug 14th, 2001, 10:27 AM
#17
Originally posted by Mobic
I was thinking of haveing this:
money, points, rank, bytes, protection, and skills.
Would also have log in screen, attack code and a formula of creation bytes ever 10 minutes or so..
But that shouldn't mean more stuff in the database?
if those are the only things in the database I wouldn't worry about it. but if you have stuff under these then ya make more tables.
by rank do you mean like a top score. I would put that info in another table as it would opnly be called at the end or whenever.
-
Aug 14th, 2001, 12:03 PM
#18
Thread Starter
Member
Ok, thanks.
Rank = their current rank while their playing the game, with the possibility to log on later and continue.. 
If multiple users should be able to login and use the same sites but with different values in the variables, should i then use sessions?
Last edited by Mobic; Aug 14th, 2001 at 01:12 PM.
-
Aug 14th, 2001, 06:02 PM
#19
that wouldn't hurt. make sure the server is setup to use sessions.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|