<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://ideawaza.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=72.73.69.235</id>
	<title>IdeaWazaWiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://ideawaza.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=72.73.69.235"/>
	<link rel="alternate" type="text/html" href="https://ideawaza.com/wiki/Special:Contributions/72.73.69.235"/>
	<updated>2026-09-29T20:52:36Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.46.0</generator>
	<entry>
		<id>https://ideawaza.com/index.php?title=Archive:PHP_and_MySQL_Programming/Creating_a_Database&amp;diff=42775</id>
		<title>Archive:PHP and MySQL Programming/Creating a Database</title>
		<link rel="alternate" type="text/html" href="https://ideawaza.com/index.php?title=Archive:PHP_and_MySQL_Programming/Creating_a_Database&amp;diff=42775"/>
		<updated>2008-02-17T02:41:34Z</updated>

		<summary type="html">&lt;p&gt;72.73.69.235: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
MySQL is a relational database. In a relational database, data is stored as a collection of fields called a row. Like fields, rows are in turn collectively stored as a table. Tables are stored collectively in a database. One MySQL server can store multiple databases, and have users who have various rights to each database.&lt;br /&gt;
&lt;br /&gt;
Now a days, mysql is the one of the mostly used relational database among others as it is simple, free (free source), easy to maintain and cost effective.&lt;br /&gt;
&lt;br /&gt;
In order to store data into MySQL, it is thus obvious that we will need to prepare a space in MySQL for a table of data known as a database.&lt;br /&gt;
&lt;br /&gt;
== SQL Code ==&lt;br /&gt;
&lt;br /&gt;
The code for creating such a database in SQL (Sequential Query Language) is a simple query :&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
 mysql&amp;gt; CREATE DATABASE `database_name`;&lt;br /&gt;
&lt;br /&gt;
== Using the Database ==&lt;br /&gt;
&lt;br /&gt;
After a database has been created, you have to tell MySQL that to make it the active database before you can start running further queries on it. You do this as follows :&lt;br /&gt;
&lt;br /&gt;
 mysql&amp;gt; USE `database_name`;&lt;br /&gt;
&lt;br /&gt;
[[../Introduction to MySQL/|Previous: Introduction to MySQL]] | [[../|TOC]] | [[../Creating a Table/|Next: Creating a Table]]&lt;br /&gt;
&lt;br /&gt;
[[Category:PHP and MySQL Programming|{{SUBPAGENAME}}]]&lt;/div&gt;</summary>
		<author><name>72.73.69.235</name></author>
	</entry>
	<entry>
		<id>https://ideawaza.com/index.php?title=Archive:PHP_and_MySQL_Programming/Creating_a_Database&amp;diff=42774</id>
		<title>Archive:PHP and MySQL Programming/Creating a Database</title>
		<link rel="alternate" type="text/html" href="https://ideawaza.com/index.php?title=Archive:PHP_and_MySQL_Programming/Creating_a_Database&amp;diff=42774"/>
		<updated>2008-02-17T02:40:55Z</updated>

		<summary type="html">&lt;p&gt;72.73.69.235: /* SQL Code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
MySQL is a relational database. In a relational database, data is stored as a collection of fields called a row. Like fields, rows are in turn collectively stored as a table. Tables are stored collectively in a database. One MySQL server can store multiple databases, and have users who have various rights to each database.&lt;br /&gt;
&lt;br /&gt;
Now a days, mysql is the one of the mostly used relational database among others as it is simple, free (free source), easy to maintain and cost effective.&lt;br /&gt;
&lt;br /&gt;
In order to store data into MySQL, it is thus obvious that we will need to prepare a space in MySQL for a table of data known as a Database.&lt;br /&gt;
&lt;br /&gt;
== SQL Code ==&lt;br /&gt;
&lt;br /&gt;
The code for creating such a database in SQL (Sequential Query Language) is a simple query :&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
 mysql&amp;gt; CREATE DATABASE `database_name`;&lt;br /&gt;
&lt;br /&gt;
== Using the Database ==&lt;br /&gt;
&lt;br /&gt;
After a database has been created, you have to tell MySQL that to make it the active database before you can start running further queries on it. You do this as follows :&lt;br /&gt;
&lt;br /&gt;
 mysql&amp;gt; USE `database_name`;&lt;br /&gt;
&lt;br /&gt;
[[../Introduction to MySQL/|Previous: Introduction to MySQL]] | [[../|TOC]] | [[../Creating a Table/|Next: Creating a Table]]&lt;br /&gt;
&lt;br /&gt;
[[Category:PHP and MySQL Programming|{{SUBPAGENAME}}]]&lt;/div&gt;</summary>
		<author><name>72.73.69.235</name></author>
	</entry>
	<entry>
		<id>https://ideawaza.com/index.php?title=Archive:PHP_and_MySQL_Programming/Creating_a_Database&amp;diff=42773</id>
		<title>Archive:PHP and MySQL Programming/Creating a Database</title>
		<link rel="alternate" type="text/html" href="https://ideawaza.com/index.php?title=Archive:PHP_and_MySQL_Programming/Creating_a_Database&amp;diff=42773"/>
		<updated>2008-02-17T02:40:05Z</updated>

		<summary type="html">&lt;p&gt;72.73.69.235: /* Using the Database */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
MySQL is a relational database. In a relational database, data is stored as a collection of fields called a row. Like fields, rows are in turn collectively stored as a table. Tables are stored collectively in a database. One MySQL server can store multiple databases, and have users who have various rights to each database.&lt;br /&gt;
&lt;br /&gt;
Now a days, mysql is the one of the mostly used relational database among others as it is simple, free (free source), easy to maintain and cost effective.&lt;br /&gt;
&lt;br /&gt;
In order to store data into MySQL, it is thus obvious that we will need to prepare a space in MySQL for a table of data known as a Database.&lt;br /&gt;
&lt;br /&gt;
== SQL Code ==&lt;br /&gt;
&lt;br /&gt;
The code for creating such a database in SQL (Sequential Query Language) is a simple query :&lt;br /&gt;
&lt;br /&gt;
 mysql&amp;gt; CREATE DATABASE `database_name`;&lt;br /&gt;
&lt;br /&gt;
== Using the Database ==&lt;br /&gt;
&lt;br /&gt;
After a database has been created, you have to tell MySQL that to make it the active database before you can start running further queries on it. You do this as follows :&lt;br /&gt;
&lt;br /&gt;
 mysql&amp;gt; USE `database_name`;&lt;br /&gt;
&lt;br /&gt;
[[../Introduction to MySQL/|Previous: Introduction to MySQL]] | [[../|TOC]] | [[../Creating a Table/|Next: Creating a Table]]&lt;br /&gt;
&lt;br /&gt;
[[Category:PHP and MySQL Programming|{{SUBPAGENAME}}]]&lt;/div&gt;</summary>
		<author><name>72.73.69.235</name></author>
	</entry>
	<entry>
		<id>https://ideawaza.com/index.php?title=Archive:PHP_and_MySQL_Programming/File_Handling&amp;diff=42648</id>
		<title>Archive:PHP and MySQL Programming/File Handling</title>
		<link rel="alternate" type="text/html" href="https://ideawaza.com/index.php?title=Archive:PHP_and_MySQL_Programming/File_Handling&amp;diff=42648"/>
		<updated>2008-02-17T02:29:18Z</updated>

		<summary type="html">&lt;p&gt;72.73.69.235: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
As with most programming languages, filehandling is very important for storing and retrieving a wide variety of data.&lt;br /&gt;
&lt;br /&gt;
== Opening and Closing Files ==&lt;br /&gt;
&lt;br /&gt;
To open a file, we use the fopen() function. This function takes in two parameters. Firstly, a String containing the name of the file, and secondly, the mode with which to open the file with. It returns a filehandler. e.g. :&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;?&lt;br /&gt;
 $filename = &amp;quot;text.txt&amp;quot;;&lt;br /&gt;
 $f = fopen($filename, &#039;r&#039;);&lt;br /&gt;
 ?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above code assigns the file name of &amp;quot;text.txt&amp;quot; to a variable called $filename. Then it uses the fopen function to open up &amp;quot;text.txt&amp;quot; with &#039;r&#039; mode (meaning &amp;quot;read mode&amp;quot;) and returns a filehandler to $f.&lt;br /&gt;
&lt;br /&gt;
To close a file, we simply call the fclose() function, and pass it the filehandler. e.g. :&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;?&lt;br /&gt;
 fclose($f);&lt;br /&gt;
 ?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Including a File ==&lt;br /&gt;
&lt;br /&gt;
It is very easy, in PHP, to include code (be it PHP or HTML) from one file into another. This is achieved by means of the include() function.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;?&lt;br /&gt;
 include (&amp;quot;objects.php&amp;quot;);&lt;br /&gt;
 ?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the above example, the PHP code will look within the current directory of the PHP file calling the include function, it will then open the objects.php file, and include its content at of that file at the position of the include() function.&lt;br /&gt;
&lt;br /&gt;
== Writing to a File ==&lt;br /&gt;
&lt;br /&gt;
The procedure for writing to a file is:&lt;br /&gt;
1. Create a file handler.&lt;br /&gt;
2. Use the file handler to open up an input stream from a file.&lt;br /&gt;
3. Write Data to the file handler.&lt;br /&gt;
4. Close the file handler.&lt;br /&gt;
&lt;br /&gt;
Here is an example of writing two lines of text to a file:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;?&lt;br /&gt;
 $filename = &amp;quot;file.txt&amp;quot;;&lt;br /&gt;
 $f = fopen($filename, &#039;w&#039;);&lt;br /&gt;
 fputs($f, &amp;quot;Bonjour Madam.\n&amp;quot;);&lt;br /&gt;
 fputs($f, &amp;quot;Bonjour Monseur.\n&amp;quot;);&lt;br /&gt;
 fclose($f);&lt;br /&gt;
 ?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
fputs() is used to write data to the file. It takes 2 variables, firstly, the file handler, and secondly, a String to write to the file handler.&lt;br /&gt;
&lt;br /&gt;
== Reading from a File ==&lt;br /&gt;
&lt;br /&gt;
Reading from a file goes along much the same format as writing to one. The function used to read from a file is fgets() function. Which takes in two variables. Firstly, the filehandler from which to read, and secondly, the amount of data to retrieve.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;?&lt;br /&gt;
 $filename = &amp;quot;text.txt&amp;quot;;&lt;br /&gt;
 $f = fopen($filename, &#039;r&#039;);&lt;br /&gt;
 $line = fgets($f, 1024);&lt;br /&gt;
 print $line;&lt;br /&gt;
 print $total_contents;&lt;br /&gt;
 fclose($f);&lt;br /&gt;
 ?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above code opens up a file, reads the first line of the file, and then displays it. If we wanted to rather read the entire contents of the file into a variable, we could replace the $line=fgets() line with : &lt;br /&gt;
&lt;br /&gt;
  $total_contents = fread($f, filesize($filename));&lt;br /&gt;
&lt;br /&gt;
[[../Syntax Overview/|Previous: Syntax Overview]] | [[../|TOC]] | [[../Database Connectivity/|Next: Database Connectivity]]&lt;br /&gt;
&lt;br /&gt;
[[Category:PHP and MySQL Programming|{{SUBPAGENAME}}]]&lt;/div&gt;</summary>
		<author><name>72.73.69.235</name></author>
	</entry>
</feed>