Click to See Complete Forum and Search --> : Where to start???...Help Please


tenniskid493
02-03-2006, 11:15 PM
Help.

I learned PHP and now want to get into MySQL. I have a host w/ MySQL supported and I'm using phpMyAdmin to update. What exactly do I need to do to get my database up and running. I understand the whole SQL language, I just can't seem to get it to work properly. Does anyone know of any good tutorials that deal with incorporating the SQL code into the web document...not just with all the SQL commands??

NogDog
02-03-2006, 11:48 PM
It never hurts to start with the manual:
http://www.php.net/mysql_connect
http://www.php.net/mysql_select_db
http://www.php.net/mysql_query
http://www.php.net/mysql_fetch_assoc

tenniskid493
02-04-2006, 11:22 AM
Ok...i get it so far..but how do you execute a multiple line query using mysql_query(

For example...how would I put this into a code.

INSERT INTO Test
VALUES ('Name', 'Age', 'Birthday')

NogDog
02-04-2006, 12:10 PM
Note that the multiple lines are just a visual formatting thing - the query would execute the same if you had it all on the same line. However, it is often convenient to break it up to make the source code easier to read. I usually do that by using the "heredoc" method of defining a string:

$query = <<<EOD
INSERT INTO test
VALUES ('Name', 'Age', 'Birthday')
EOD;

$result = mysql_query($query) or die(mysql_error());
$rows = mysql_affected_rows();
echo "<p>$rows row(s) inserted into database</p>\n";

tenniskid493
02-04-2006, 01:50 PM
ok..that makes sense