|
| Author |
Message |
Triumvirate
Joined: 24 Feb 2004
Posts: 169
Location: NY, USA
|
Posted: 7/12/2004, 1:30 am Post subject: Drawing A Blank - PHP Question |
|
|
Okay, I know that I can do this, and I know that I know how to do this, but I can't, for the life of me, get this to work (and I'm getting rather frustrated and feeling rather stupid.)
I've done this before, but for some reason I seem to be drawing a blank today.
Anyway, the problem is I have a page that is supposed to take a set of values and insert them into the database. I set up the database table so it looks like this:
| Code: |
id
name
age
race
class
bio |
Then, I have the php file (located here in .txt form) which is supposed to take the form values and insert them into the database. The template file can be seen here. The problem is it is not inserting the values into the database.
I know that I'm going to kick myself when I get a response. But thanks in advance for the help. I've tried everything from post, to get, to simply assigning them as variables but nothing I do is working.
Thanks. _________________ GamingMMO.com |
|
| Back to top |
|
 |
chrispian
Joined: 25 Jan 2004
Posts: 22
Location: Huntsville, AL USA
|
Posted: 7/12/2004, 5:39 pm Post subject: |
|
|
You define your query in your $sql variable, but you never execute it. I bet that's your problem. You need to add after that line:
| Code: |
$result = mysql_query($sql);
|
|
|
| Back to top |
|
 |
Triumvirate
Joined: 24 Feb 2004
Posts: 169
Location: NY, USA
|
Posted: 7/12/2004, 8:19 pm Post subject: |
|
|
Thanks, I've updated the create.txt file. What you mentioned was certainly a problem (-kicks self-) but it still is not inserting into the database. This is most likely because I've been messing with the code for so long now I've created even more problems.
Thanks for the help. _________________ GamingMMO.com |
|
| Back to top |
|
 |
A_Jelly_Doughnut
Joined: 25 Jun 2004
Posts: 13
|
Posted: 7/17/2004, 3:00 am Post subject: |
|
|
Couple things I notice immediately:
1) INSERT INTO (columns) VALUES (values) is the syntax I always use for SQL. Why? If you add another column to the database, that query you use might just not work
2) You don't do
| Code: |
if(!mysql_query($sql))
{
die(mysql_error());
} |
to get any errors MySQL outputs
3) The sql query will be run on every page load because you use no logic  _________________ CMSformE |
|
| Back to top |
|
 |
|