Learning MySql and PHP

Posted by mooselumph on Aug. 9, 2005, 10:58 p.m.

My math class just ended, so I've had a little bit of free time. I started reading the PHP manual that I downloaded and fiddling around with the phpmyadmin client that I have.

It was all going well until I denied myself access to everything. Now, I'm going to uninstall xampp, and reinstal it. It's all great fun :)

EDIT:

Ok, I have it all working now. I figured out how to create a database, but I'm kind of unclear about how to add to it.

As far as I can tell, you use mysql_query with INSERT of UPDATE or something, but I can't figure out any more than that. Does anyone know of any good MySql tutorial sites?

Comments

firestormx 19 years, 4 months ago

INSERT adds a row to the mysql table, and UPDATE edits the table.

Just a tip, when using INSERT there is value, and value<u>S</u>, depending on how many fields you would like to fill in.

For example, this will give you an error:

mysql_query("INSERT INTO table (col1, col2, col3) VALUE ('1', '2', '3')");

This will also give you an error:

mysql_query("INSERT INTO table (column) VALUE<u>S</u> ('1')");

These are the correct ways:

mysql_query("INSERT INTO table (col1, col2, col3) VALUES ('1', '2', '3')");

mysql_query("INSERT INTO table (column) VALUE ('1')");

It took me two friggin' nights to figure that out. (I couldn't test the rest of the site I was working on, because I didn't know to use value, instead of values)

And when you use update, make sure to use "where", otherwise every single row will have the column changed. (Again, very frustrating, especialy if you havn't backed up the data in a while)

firestormx 19 years, 4 months ago

Oh, and also, before you can add to the database, you have to make a table first. =P

<a href="http://www.tizag.com/mysqlTutorial/mysqltables.php" target="_blank">http://www.tizag.com/mysqlTutorial/mysqltables.php</a>

Or, of course, there's always the official mysql site:

<a href="http://dev.mysql.com/doc/mysql/en/create-table.html" target="_blank">http://dev.mysql.com/doc/mysql/en/create-table.html</a>

mooselumph 19 years, 4 months ago

Wow, thanks! Let's see if I can get something working, now.