Jump to content
xisto Community
marksman

Problems With Php Saving Data Into Mysql HELP I cant get my php documents to work with the mySQL

Recommended Posts

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 me

Share this post


Link to post
Share on other sites

As soon as Fantastico will work again, I suggest that you install phpbb forum or 4image gallery, and look how the autimatically installed php program insert data into the mysql databas and how they retrieve the forum posts from the database and display them on the webpage.yordan

Share this post


Link to post
Share on other sites

Well, in order to do that...you'd have to connect to the database first:

<?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:

mysql_query("INSERT INTO people (name, email) VALUES('Person', 'person@gmail.com' ) ") or die(mysql_error());

Most mysql queries are nice like that. :ph34r: The insert into basically just puts the data into the database called "people". The database people has columns name and email, of which the values "person" and "person@gmail.com" are added into, respectively.

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)

Share this post


Link to post
Share on other sites

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 me

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.

Share this post


Link to post
Share on other sites

hmmmmmmmmmmmmmmmmmmmmmmmmm i see well all i can reccomend for this is get free hosting with mysql and run it on there ummmmmmmmmmmmm are you sure its not you script the may not be coded right i reccomend you get a mate to look at it it would be way to hard to explan how to fix some thing like that on a forum Lol

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.