logo
g Text Version
Beauty & Self
Books & Music
Career
Computers
Education
Family
Food & Wine
Health & Fitness
Hobbies & Crafts
Home & Garden
Money
News & Politics
Relationships
Religion & Spirituality
Sports
Travel & Culture
TV & Movies

dailyclick
Bored? Games!
Nutrition
Postcards
Take a Quiz
Rate My Photo

new
European Travel
Action Movies
Bible Basics
Houseplants
Romance Movies
Creativity
Family Travel


dailyclick
All times in EST

Low Carb: 8:00 PM

Full Schedule
g
g PHP Site

BellaOnline's PHP Editor

g

Personal Activities Calendar Program - INSERT SQL Statement and mysql_query( ) Function - 2

Guest Author - Diane Cipollo

The mysql_query( ) Function

Now we need a way to send this query to the server and for the server to let us know if all went well. We can use the mysql_query( ) function to do this. As in the code we just discussed, we will again set this function to a variable and this time we will name the variable $result. However, you can use any name for this variable. As before, it is not necessary to do this, but it does make the code much easier to read. The code for the mysql_query( ) function itself is placed after the equal size but no quotation marks are needed. The statement ends with a semicolon.

$result = @mysql_query($sql_send, $connection)
or die
("Could not connect to the database at this time. Please try later.");
Note--Due to space limitations, this code is wrapped but can really be all on one line.

As you can see, this statement uses two variables that are placed between the parenthesis. ($sql_send and $connection). We initialized the $sql_send variable in the sql INSERT statement. The $connection variable was created in the mysql_connect( ) function from a previous tutorial.

Also, we reused some of the things you learned in this same previous tutorial. This new mysql_query( ) function also uses the @ to suppress the default error message and the die( ) statement to customized an error message for the possibility that we cannot connect to the database.

When you are using PHP, the connection to the server is automatically closed for you.

← Back



The MySQL Database and Rules for Using SQL Queries
Personal Activities Calendar Program Use the strtotime and mysql_select_db Functions
How to Connect to the MySQL Server with the PHP mysql_connect Function



This site needs an editor - click to learn more!

Add Personal+Activities+Calendar+Program+%2D+INSERT+SQL+Statement+and+mysql%5Fquery%28+%29+Function+%2D+2 to Twitter Add Personal+Activities+Calendar+Program+%2D+INSERT+SQL+Statement+and+mysql%5Fquery%28+%29+Function+%2D+2 to Facebook Add Personal+Activities+Calendar+Program+%2D+INSERT+SQL+Statement+and+mysql%5Fquery%28+%29+Function+%2D+2 to MySpace Add Personal+Activities+Calendar+Program+%2D+INSERT+SQL+Statement+and+mysql%5Fquery%28+%29+Function+%2D+2 to Del.icio.us Digg Personal+Activities+Calendar+Program+%2D+INSERT+SQL+Statement+and+mysql%5Fquery%28+%29+Function+%2D+2 Add Personal+Activities+Calendar+Program+%2D+INSERT+SQL+Statement+and+mysql%5Fquery%28+%29+Function+%2D+2 to Yahoo My Web Add Personal+Activities+Calendar+Program+%2D+INSERT+SQL+Statement+and+mysql%5Fquery%28+%29+Function+%2D+2 to Google Bookmarks Add Personal+Activities+Calendar+Program+%2D+INSERT+SQL+Statement+and+mysql%5Fquery%28+%29+Function+%2D+2 to Stumbleupon Add Personal+Activities+Calendar+Program+%2D+INSERT+SQL+Statement+and+mysql%5Fquery%28+%29+Function+%2D+2 to Reddit




RSS | Related Articles | Editor's Picks Articles | Top Ten Articles | Previous Features | Site Map


For FREE email updates, subscribe to the PHP Newsletter


Past Issues


print
Printer Friendly
bookmark
Bookmark
tell friend
Tell a Friend
forum
Forum
email
Email Editor


Content copyright © 2014 by Diane Cipollo. All rights reserved.
This content was written by Diane Cipollo. If you wish to use this content in any manner, you need written permission. Contact BellaOnline Administration for details.

g


g features
Archives | Site Map

forum
Forum
email
Contact

Past Issues
memberscenter


vote
Poetry
Daily
Weekly
Monthly
Less than Monthly



BellaOnline on Facebook
g


| About BellaOnline | Privacy Policy | Advertising | Become an Editor |
Website copyright © 2014 Minerva WebWorks LLC. All rights reserved.


BellaOnline Editor