|
|
Problems With Php Saving Data Into Mysql - HELP! I can't get my php documents to work with the mySQL | ||
Discussion by marksman with 6 Replies.
Last Update: March 15, 2008, 11:22 pm | |||
Tue Apr 10, 2007 Reply New Discussion
Tue Apr 10, 2007 Reply New Discussion
yordan
Tue Apr 10, 2007 Reply New Discussion
CODE
<?phpmysql_connect("hostname", "username", "password") or die("Unable to connect to MySQL");
mysql_select_db("name");
?>
The hostname on most servers is usually "localhost". If you find that that doesn't work, then you should probably contact your host. (Usually if it doesn't work, the host has some sort of warning telling you that as well...) The die part basically just prints an error message. If you want more detailed error messages, then mysql_error() would work better.
Then, to insert stuff:
CODE
mysql_query("INSERT INTO people(name, email) VALUES('Person', 'person@gmail.com' ) ")
or die(mysql_error());
Most mysql queries are nice like that.
That's about it for inserting data. Though for passwords it would obviously be a good idea to md5 hash it before inserting it into the database. And even before that, it'd be more secure if you got rid of quotes, semicolons and slashes. (php's stripslashes is quite nice for the latter)
Wed Apr 11, 2007 Reply New Discussion
QUOTE (marksman)
i have a server that says it allows php and mysql and in the control panel i can access mysqladmin and phpmyadmin but i cant get the php to save data into the mysql, i am trying to make a text-based MMOG so i need to save my users/passwords into a database(i thought) and it won't do it, can anyone help meLink: view Post: 101467
Can you provide some more details.. If you like, I can give you the class I am using to access the database.
The class is just a wrapper and very easy to understand. Works with mySQL only since I am using mySQL with my webbase needs.
Thu Apr 12, 2007 Reply New Discussion
Sat Mar 15, 2008 Reply New Discussion
that's exactly what he is doing right now : we hare his mates and he asks us to have a look at his code.
Sat Mar 15, 2008 Reply New Discussion
Oracle 10g - Dba Less? Oracle's Drive for their new RDBMS (9)
|
(4) (help With Sql And Php)retrive Datas From Realted Tables And Display Them! Please help...
|
Index




