Showing posts with label article. Show all posts
Showing posts with label article. Show all posts

Sunday, 29 September 2013

How to Connect to MySQL Using PHP

If you already know some of the basics of writing PHP scripts, you may be ready to learn about a set of built-in PHP functions that allow you to connect to and manipulate a MySQL database. If you do not already have a MySQL server (Most web hosts with PHP do), I suggest either downloading and installing WampServer on your web server, or following this tutorial. It is also recommended that you understand basic concepts of SQL. In this tutorial we will learn how to connect to a MySQL database, select a database, query a table, and "fetch" and array from that data.

Steps

Connect to a Server

  1. 1
    Create a new PHP file on your web server, and open it in your favorite text editor.
  1. 2
    Start your file by typing the open and close PHP tags with some space in between to work with.
    <?php
     
     
     
    ?>
  1. 3
    Type this on a new line.
    $con = mysql_connect("localhost","root","");
    
    • This line of code creates the foundation for the communication with the MySQL server. The function "mysql_connect" takes a minimum of 3 string arguments. The first is the IP address or domain name of your server; you should change this from localhost to the address of your MySQL server. The second argument is the MySQL user that we will authenticate, and the third argument is the password for our MySQL user (in this case I left the password blank).
    • The output of "mysql_connect" is a resource datatype, and in the code above we assigned it to a variable ($con) so we could use it later. For more information on mysql_connect(), visit the PHP documentation.

Select a Database

  1. 1
    Type this on a new line.
    mysql_select_db("test", $con) or die(mysql_error());
    
    • This line is fairly simple. Before your can run any queries on a specific database, you must select which database. In PHP to do this we use the "mysql_select_db" function, which requires 1 argument. The first argument in the code is required, it is the name of the database to connect to. The second argument I used is not required but good practice; it defines which server connection to use to select the database.

Query a Table

  1. 1
    Type this on a new line.
    mysql_query("CREATE TABLE `php tutorial` (`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY, `name` VARCHAR( 255 ) NOT NULL) ENGINE = MYISAM", $con) or die(mysql_error());
    
    • The function mysql_query works in two ways. "For SELECT, SHOW, DESCRIBE, EXPLAIN and other statements returning resultset, mysql_query() returns a resource on success, or FALSE on error.
    • For other type of SQL statements, INSERT, UPDATE, DELETE, DROP, etc, mysql_query() returns TRUE on success or FALSE on error." (PHP documentation).
    • These lines of code do two things. First they call "mysql_query," which will return true or false based on the success of the query. If the output of mysql_query is false the script will die and run the "mysql_error" function (which simply returns the previous MySQL error).
    • The mysql_query function only requires one argument, but like the mysql_select_db function, it is good practice to include a second.
      • The first argument is a string: a single MySQL query (multiple queries not allowed). The query above creates a new table called "php tutorial".
      • The second argument is the connection resource we are using (in our case $con).
  2. 2
    Type this on a new line.
    mysql_query("INSERT INTO `php tutorial` (`name`) VALUES ('chuck')", $con) or die(mysql_error());
     
    $result = mysql_query("SELECT * FROM `php tutorial`", $con);
    if(!$result) {
            die(mysql_error());
    } else {
            while($row = mysql_fetch_array($result)) {
                    echo row['name'];
            }
    }
    
    • The first line of code is similar to the last step's code. It is in there to give of some data to select. Below, see we are setting the output of mysql_query to a variable called $result.
    • Also notice how the code does not use "or die(" instead it uses the if control statement. This can save you grief when you start getting into error handling beyond simply killing the script. You don't have to worry about it too much now, and you can use "or die" on MySQL queryies that return a result set if you want
    • After the else statement we have a while statement. This part of the code can be confusing so bear with me. mysql_fetch_array will return an array of data containing a single row of the result, labeled by column; however, the next time mysql_fetch_array is run it will return an array of the next row in the result set.
      • The while statement will keep iterating through all the rows (assigning them as arrays to $row), until mysql_fetch_array reaches the end of the result set, then it will return false and the while statement will close. Confusing yes. But this method works well.
  3. 3
    Take some time to play around with these concepts. These functions allow you to do so much more with PHP. I would suggest taking a look at this wikiHow page: How to Create a Basic Login Script in PHP. I would also suggest making your own project like a simple browser turn based rpg to get the hang of working with a database.
Source : www.wikihow.com

Monday, 23 September 2013

How to Use Adobe After Effects

Adobe After Effects is a software program that allows its users to create animation and other special effects for graphic-related projects. Graphic designers use it to provide their projects with layer-based animation, audio clips and still images. Part of the Adobe family of software, After Effects projects are compatible with other Adobe software, helping to provide versatility to designers. Here are a few tips about how to use Adobe After Effects in your projects.


Steps

  1. 1
    Start a new project. As you open After Effects, the option to start a new project is present.


    • Right-click in the project window and select "New Composition," or hold down "Ctrl + N" on your keyboard. From this point, you may also select the default size of the project and the projected video size.


    • You can import files by right-clicking in the project window and choosing "Import," or by holding down "Ctrl + I" on your keyboard. You may import files as a composition file if you wish to keep all layers during the transition.


  2. 2
    Now that you've imported your files, drag and drop them into the Timeline window. To adjust which layer appears in your Composition window, drag them up and down in your Timeline window. Each layer will have a grey box around it. To adjust the size, drag the corners. To adjust the width and height drag the sides. To adjust the length of your clip, drag the end or the beginning of your layer and release at the desired point.


  3. 3
    Animate key frames by clicking on the stopwatch beside each file. You will select a starting- and ending-point for each file. After Effects automatically fills in the animation clip between the stopwatch selections.


  4. 4
    Preview your project. Select "Windows." From here, click on "Time Controls." A preview pane will pop up where you can select "Play" to see a rough draft of your project. If you wish to see a more finished version, click on "Ram Render Play." If your project is especially long or requires a large amount of memory, adjust the resolution before you preview it. After clicking to play it, the video will run continually until you click on the screen to stop it.


  5. 5
    Jazz up your project with animations and effects. Click on "Window" and "Effects and Presets." You will see a list of various animations and effects that are available for application to your project. Simply drag and drop the effect or animation selection onto the object to which you'd like to apply it. You should see the change immediately. Samples of the effects are 3D, color correction and various camera views. Transitions are also included, such as wipe, fade and checkerboard. You may remove selections by dragging them off your projects.

    www.wikihow.com

Sunday, 22 September 2013

How to Write ASP Scripts

ASP or active server pages, is used to make websites that are both dynamic and static. Here, you will learn how to write a simple hello world script.


Steps

  1. 1
    Configure IIS.


  2. 2
    Open Notepad and type this<% response.write("Hello World!") %>


  3. 3
    Run the Notepad file from a browser.



    source : www.wikihow.com

Saturday, 21 September 2013

How to Make a Web Page Using Dreamweaver

Here's how to get started in making a website in Adobe Dreamweaver.


Steps

  1. 1
    Create a folder in the hard drive (not in Dreamweaver) and name it whatever you want. This is your root folder.


  2. 2
    Inside this folder create 4 sub-folders and name them: Images, Flash, Pages, and Other.


  3. 3
    Go into Dreamweaver and click on HTML. Save this page into your root folder as Home Page.


  4. 4
    Get Started.


  5. 5
    Dreamweaver is a little bit screwy so to put images, buttons, etc where you want them you have to add in tables. Go to insert, new table. You can set it to as many cubes as you want. It's a little tricky to get it where you want but a little playing with it works.


  6. 6
    If you want to, you can insert buttons by going to insert, form, button. Once you get it, you can right click on it and look for the page you want to connect it to or type in the url of the site.


  7. 7
    You can also use flash text and you can add in pictures.


  8. 8
    When adding a picture, do not copy/paste it. Go to insert, image and then search for the pic you want. Again, Dreamweaver is a little screwy.


  9. 9
    To change the background color and font go to modify, page properties, and it's self explanatory from there.


  10. 10
    That should get you on the right track!



    Source : www.wikihow.com


Friday, 20 September 2013

How to Make Your Laptop Work Faster

When you first buy a laptop, it always seems to accomplish most tasks very quickly. If you've had your laptop for six months or more, though, most of us would agree it tends to get bogged down, start up slower, take forever to do menial tasks. Thankfully, your laptop can be restored to its full speed a lot easier than you think.


Steps

  1. 1
    Uninstall unnecessary programs. If you have a lot of programs running in the background (otherwise known as "bloatware") it can slow down your system immensely. To look at a list of installed programs in Windows Vista or Windows 7, click on the start menu. In the search bar, type "Add or Remove Programs" and press enter. A list of programs will appear. If you remember installing a program, and you don't use it anymore, click on the program name then click "Uninstall." Windows will guide you through the uninstall process.


  2. 2
    Install and use a good registry cleaner.


  3. 3
    Check your computer for spyware. This is a type of software that runs in the background and monitors your usage, sending information back to companies without your approval.


  4. 4
    Install anti-virus software. This may seem counter-intuitive, but anti-virus software keeps malicious programs from invading your computer that could slow it down a lot more than an anti-virus program could.


  5. 5
    Keep big files off the desktop. If you tend to download a lot of things off the internet, chances are you keep it on the desktop. If your desktop looks cluttered, move any non-essential files into a separate folder. This keeps your computer from having to keep track of them whenever it is turned on.


  6. 6
    Disable Windows Aero. Aero makes the edges of windows pretty (semi-transparent) making your computer seem "smoother." If your computer isn't up to all these graphics, Aero will bog it down. To disable Aero, right click anywhere on your desktop and select "Personalize" from the drop-down menu. On the list of themes that appears, scroll to the bottom and select "Windows Classic."


  7. 7
    Upgrade your memory. If you want great performance without sacrificing your programs, you may want to consider a memory upgrade. These typically run $50 - 70 for laptops, and most small places will install it for free. A memory upgrade is the most cost-effective performance booster for laptops.