connecting to MYSQL using PHP and Apache

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • srinivasMP51
    New Member
    • Mar 2008
    • 3

    connecting to MYSQL using PHP and Apache

    I setted all settings
    in php.ini & windows directory system32 libmysql.dll
    I tried all that three steps u expalined

    later i tried this code
    1.
    <?php
    2.
    echo mysql_connect(" localhost", "root", "YOURPWHERE ");
    3.
    ?>

    i got output resource #2

    then i tried this
    1.
    error_reporting (E_ALL);
    2.
    echo mysql_connect(" localhost", "root", "ROOTPWD") or die(mysql_error ());
    i got output only 1

    plz anyone help me to solve this problem on my system

    I am using APACHE HTTP SERVER 2.0.50
    WINDOWS XP
    MYSQL 5.0
    PHP 5.2.5
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    The result of an mysql_conect is either a resource connection id or a FALSE, So your code is allright. But now you hgave to select a database, ussie a query, retirve the resuklts of the query, etc.like[php]
    // connect to server
    $conn=mysql_con nect("localhost ", "root", "ROOTPWD")
    or die('Connection error: '.mysql_error() );
    // select the database
    mysql_select_db (SQL_DB,$conn)
    or die("Cannot select database: " . mysql_error());
    // select rows from a table
    $res=mysql_quer y("SELECT * FROM table_name")
    or die("SELECT error: ".mysql_error() );
    if (mysql_num_rows ($res) < 1)
    die("No rows selected");
    // there are rwos in the rsult, process them
    else {
    // get all rows in a while loop
    while ($row=mysql_fet ch_assoc($res) ) {
    $myvar=$row['xxxx'];
    // etc ........
    }
    }[/php]This is a simple example of how to do it.

    Ronald

    Comment

    • srinivasMP51
      New Member
      • Mar 2008
      • 3

      #3
      i tried this one simply my output is blank screen

      Comment

      • ronverdonk
        Recognized Expert Specialist
        • Jul 2006
        • 4259

        #4
        The sample shown is exactly what it says: just a sample. You have to fill in all variable fields for your own system! Have you done that? If so, show the code you have used to get nothing.

        And show the code within the appropriate code tags. See the Posting Guidelines.

        Ronald

        Comment

        Working...