bookmark - Problems With Php Saving Data Into Mysql HELP! I can't get my php documents to work with the mySQL

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
 
bookmark - Problems With Php Saving Data Into Mysql HELP! I can't get my php documents to work with the mySQL  
    
free web hosting
 
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

Tue Apr 10, 2007    Reply    New Discussion   


Please share the code snippet that you used to do the process or the details about the CMS if you use any. Only then we'll be able to help you.

Tue Apr 10, 2007    Reply    New Discussion   

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

Tue Apr 10, 2007    Reply    New Discussion   

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

CODE

<?php
mysql_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. :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)

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 me
Link: 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   

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

Sat Mar 15, 2008    Reply    New Discussion   

QUOTE (Habble)

i reccomend you get a mate to look at it
Link: view Post: 120474

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   

Quickly Post to Problems With Php Saving Data Into Mysql HELP! I can't get my php documents to work with the mySQL w/o signup Share Info about Problems With Php Saving Data Into Mysql HELP! I can't get my php documents to work with the mySQL using Facebook, Twitter etc. email your friend about Problems With Php Saving Data Into Mysql HELP! I can't get my php documents to work with the mySQL Print
Reply / Comment Ask a Question? Share / Bookmark E-Mail a Friend Print

Oracle 10g - Dba Less? Oracle's Drive for their new RDBMS  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...  (help With Sql And Php)retrive Datas From Realted Tables And Display Them! Please help me to diplay datas by combining 3 tables!