SitePoint Sponsor |
|
User Tag List
Results 1 to 3 of 3
Thread: can't write to database?
-
Jun 26, 2001, 18:58 #1
- Join Date
- Jun 2001
- Posts
- 2
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
can't write to database?
So I wrote a tiny bit of PHP script to write to my database, looking like this:
PHP Code:<?
if ($signup == go) {
MYSQL_CONNECT(localhost, shh, xxxxx) OR DIE("Unable to connect to database");
@mysql_select_db("shh") or die("Unable to select database");
$query = "INSERT INTO users VALUES('$username','$password')";
$result = MYSQL_QUERY($query);
echo ("Thank you:" . $username . "and" . $password . "have been added to the database.");
MYSQL_CLOSE();
} else {
echo ("<form action=" . $PHP_SELF . " method=get>username: <input type=text name=username><br>password: <input type=text name=password><br><input type=submit name=signup value=go>");
}
?>
The script, when run, returns that the values have been added, but when I check on the database, it's empty.
Can anyone explain where I've gone wrong?
-
Jun 26, 2001, 19:08 #2
- Join Date
- Apr 2001
- Location
- Calgary,AB
- Posts
- 345
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Change this:
$query = "INSERT INTO users VALUES('$username','$password')";
$result = MYSQL_QUERY($query);
To This:
$query = "INSERT INTO users (username,password) VALUES('$username','$password')";
$result = MYSQL_QUERY($query)or die("Something Bummed out");
Then run it. See what happens
-
Jun 27, 2001, 06:11 #3
- Join Date
- Jun 2001
- Posts
- 2
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
thank you! it now works like a charm!
Bookmarks