Page 1 of 1

Is it PHP or MySQL command?

Posted: Sat Sep 14, 2002 12:53 pm
by Alex Papa
Hi.

I am new to database driven applications and I have some basic questions. Do the following commands belong to PHP or MySQL?

mysql_query("select * from guestbook")
mysql_fetch_array($result)
mysql_free_result($result);
mysql_query("select * from guestbook")

And if I suppose the above commands are based on PHP, does this mean that PHP offers different commands for each individual database? What if for example I want to connect to SQL or Oracle database?
Does PHP offers commands for all the databases in the world?

The above commands have been taken from the following Demo PHP script.

Code: Select all

<?php include("dbconnect.php"); ?>
<h2>View My Guest Book!!!</h2>
<?php
     $result = mysql_query("select * from guestbook") or die (mysql_error());
	 while ($row = mysql_fetch_array($result))
	 &#123;
	     echo "<b>Name:</b>";
		 echo $row &#1111;"name"];
		 echo "<br>\n";
		 
		 echo "<b>Email:</b>";
		 echo $row &#1111;"email"];
		 echo "<br>\n";
		 
		 echo "<b>URL:</b>";
		 echo $row &#1111;"url"];
		 echo "<br>\n";
		 
		 echo "<b>Comments:</b>";
		 echo $row &#1111;"comments"];
		 echo "<br>\n";
		 echo "<br>\n";
		 echo "<br>\n";
		 &#125;
		 mysql_free_result($result);
		 ?>
Thanks

Posted: Sat Sep 14, 2002 1:33 pm
by Gonik
in the example you mention..

Code: Select all

&lt;?php
mysql_query("select * from guestbook");
mysql_fetch_array($result);
mysql_free_result($result);
mysql_query("select * from guestbook");
?&gt;
The PHP Functions (they are related to mysql and only for it) are mysql_query, mysql_fetch_array and mysql_free_result.

The select * from guestbook stuff is called a SQL Query and it will select all the fields in a database named guestbook.

For More information about PHP and the databases that it supports you can find at http://www.php.net/manual/en/ and specifically for MSSQL here and Oracle here

hope these will help

Posted: Sat Sep 14, 2002 1:35 pm
by hob_goblin

Posted: Sat Sep 14, 2002 3:44 pm
by Alex Papa
So finally it seems that the functions belong to PHP and I need to install extra modules if I want to control other databases.

Well its pain unless you need to set up a network for a bank. Far beyond my capacities at the moment

I prefer to stick with My MySQL and My PHP.

Again MySQL and PHP can still bring some money to my pocket. I am working on them NOW!!!!!

Thank you for your kind replies!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Posted: Sun Sep 15, 2002 2:29 am
by Takuma
I love MySQL. But I wish I had Oracle... For a list of MySQL function of PHP:-

http://www.php.net/manual/en/ref.mysql.php

Posted: Sun Sep 15, 2002 12:31 pm
by Alex Papa
Thank you Takuma