Is it PHP or MySQL command?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Alex Papa
Forum Newbie
Posts: 10
Joined: Sat Sep 14, 2002 12:53 pm

Is it PHP or MySQL command?

Post 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
User avatar
Gonik
Forum Newbie
Posts: 19
Joined: Fri Aug 30, 2002 7:39 am
Location: Somewhere Around Nothing

Post 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
User avatar
hob_goblin
Forum Regular
Posts: 978
Joined: Sun Apr 28, 2002 9:53 pm
Contact:

Post by hob_goblin »

Alex Papa
Forum Newbie
Posts: 10
Joined: Sat Sep 14, 2002 12:53 pm

Post 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!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
User avatar
Takuma
Forum Regular
Posts: 931
Joined: Sun Aug 04, 2002 10:24 am
Location: UK
Contact:

Post 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
Alex Papa
Forum Newbie
Posts: 10
Joined: Sat Sep 14, 2002 12:53 pm

Post by Alex Papa »

Thank you Takuma
Post Reply