PHP MySQL


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 7 of 7

Thread: PHP MySQL

  1. #1
    Neil Guest

    PHP MySQL

    I have done development on Windows on IIS ASP SQL server.

    Now I want to work on PHP MYSQL, I had a few questions,

    1. what is the way to connect to database in PHP, in ASP we had ODBC or
    connectionless connections.
    2. Also how to I submit my web-site to google.
    3. How do I use Apache on my local computer just like IIS, in IIS we would
    load pages in a specific directory to test it on local server. What is the
    directory in Apache ? What is the procedure for all this ?

    Can someone suggest me some good web-sites ?

    Neil.





    Share on Google+

  2. #2
    Khaled Guest

    Re: PHP MySQL


    hi Neil,

    1. What I've tried personally (with my very little experience in PHP) is
    to connect to MySQL database. This seems to be the most famouse database
    used with PHP, PHP provides functions that support dealing with MYSQL easily,
    mysql_connect, mysql_select_db, mysql_query and a lot others.
    2.No idea.
    3.http://httpd.apache.org/ - have a nice time Similar to IIS you place
    your documents in some directory and test them through your local machine
    using http://localhost/whatever

    here are some usefule websites :
    www.apache.org //Apache Gruop homepage
    http://www.php.net/
    http://www.mysql.com/

    http://www.phpedit.net/products/PHPEdit/download.php [a nice PHP editor]

    http://hotwired.lycos.com/webmonkey/.../tutorial4.htm
    [nice PHP/MySQL tutorial - includes installation guide I think]

    bye

    "Neil" <neilharwani@icenet.net> wrote:
    >I have done development on Windows on IIS ASP SQL server.
    >
    >Now I want to work on PHP MYSQL, I had a few questions,
    >
    >1. what is the way to connect to database in PHP, in ASP we had ODBC or
    >connectionless connections.
    >2. Also how to I submit my web-site to google.
    >3. How do I use Apache on my local computer just like IIS, in IIS we would
    >load pages in a specific directory to test it on local server. What is the
    >directory in Apache ? What is the procedure for all this ?
    >
    >Can someone suggest me some good web-sites ?
    >
    >Neil.
    >
    >
    >
    >
    >


    Share on Google+

  3. #3
    dxt Guest

    Re: PHP MySQL


    to check out php/mysql on win platform the easiest setup can be found on http://www.firepages.com.au
    phpdev gives you apache+mysql+php in one install


    "Neil" <neilharwani@icenet.net> wrote:
    >I have done development on Windows on IIS ASP SQL server.
    >
    >Now I want to work on PHP MYSQL, I had a few questions,
    >
    >1. what is the way to connect to database in PHP, in ASP we had ODBC or
    >connectionless connections.
    >2. Also how to I submit my web-site to google.
    >3. How do I use Apache on my local computer just like IIS, in IIS we would
    >load pages in a specific directory to test it on local server. What is the
    >directory in Apache ? What is the procedure for all this ?
    >
    >Can someone suggest me some good web-sites ?
    >
    >Neil.
    >
    >
    >
    >
    >


    Share on Google+

  4. #4
    Join Date
    May 2004
    Posts
    5
    Greetings,
    Answer to first question a connection to a MySQL database on a local macine
    PHP Code:
    <?php              
    // Connecting, selecting database       
    $link mysql_connect("localhost""root""yourpassword") or die("Could not connect : " mysql_error());      
    echo 
    "Connected successfully";

    mysql_select_db("cardealerstudy") or die("Could not select database");        
    // Performing SQL query       
    $query "SELECT * FROM vehiclelistings";      
    $result mysql_query($query) or die("Query failed : " mysql_error());              
    while (
    $line mysql_fetch_array($resultMYSQL_BOTH))       
    {         
         
    printf("%s %s ",$line["Make"],$line["Model"]);
    }                  
    // Free resultset       
    mysql_free_result($result);        
    // Closing connection       
    mysql_close($link);  
    ?>
    I hope that helps.
    I didn't know you could do that with a computer...
    Share on Google+

  5. #5
    Join Date
    May 2004
    Posts
    5

    Installing Apache etc.

    Next Question:
    Having gone through this a number of times I can tell you that I have had great pain and success with the procedure.

    It's not hard (especially if your machine is rodent/bug free)

    As a matter of fact you can have IIS and Apache working together.

    Currently I have IIS set to look at port 8080 with the standard local directory that it normally defaults to.

    I have apache set to look at port 80.

    here's a link that will provide you with step by step instructions in how to set it up.

    http://www.devarticles.com/c/a/Apach...under-Windows/

    Regards,
    wiz
    I didn't know you could do that with a computer...
    Share on Google+

  6. #6
    Join Date
    May 2004
    Posts
    5

    M-V-C architecture for PHP/MySQL

    Hello,

    Further to the query by wizbang (I'm also new to PHP/MySQL)... is there any open source MVC frameworks for PHP, like Struts for Java?

    I'm now opening and closing a connection to the database everytime I load a page... is that the usual practise?

    Thanks.
    Share on Google+

  7. #7
    Join Date
    May 2004
    Posts
    5

    Re: M-V-C architecture for PHP/MySQL

    Originally posted by kaemags
    Hello,

    Further to the query by wizbang (I'm also new to PHP/MySQL)... is there any open source MVC frameworks for PHP, like Struts for Java?

    I'm now opening and closing a connection to the database everytime I load a page... is that the usual practise?

    Thanks.
    Regarding that particular question.

    For me, I find it prudent to open databases, request information or place information and then close them. Why? Even in an enviornment like Microsoft Access, when you create routines to get specific information or update some information, the usual practice is to open set an database object variable to the database, open a table or query, perform some operation and then close everything up.

    In the volatile world of the Internet with users clicking away from pages or closing browsers, or cable/DSL modems hanging ... all sorts of things, I believe, at least for me, that I minimize a number of problems that could arise database corruption, being one, by not having dangling references to tables or queries that are left behind if you transfer to another page.

    Now as to the question as to whether or not it is necessary?

    The scope of variables is found in the PHP manual.

    Variable scope
    The scope of a variable is the context within which it is defined. For the most part all PHP variables only have a single scope. This single scope spans included and required files as well. For example:

    PHP Code:
    <?php
    $a 
    1;
    include 
    "b.inc";
    ?>
    Here the $a variable will be available within the included b.inc script. However, within user-defined functions a local function scope is introduced. Any variable used inside a function is by default limited to the local function scope. For example:

    PHP Code:
    <?php
    $a 
    1/* global scope */ 

    function Test()

        echo 
    $a/* reference to local scope variable */ 


    Test();
    ?>
    This script will not produce any output because the echo statement refers to a local version of the $a variable, and it has not been assigned a value within this scope. You may notice that this is a little bit different from the C language in that global variables in C are automatically available to functions unless specifically overridden by a local definition. This can cause some problems in that people may inadvertently change a global variable. In PHP global variables must be declared global inside a function if they are going to be used in that function. An example:

    PHP Code:
    <?php
    $a 
    1;
    $b 2;

    function 
    Sum()
    {
        global 
    $a$b;

        
    $b $a $b;


    Sum();
    echo 
    $b;
    ?>
    ... There's a lot more about this in the manual.

    While I have not tried it, I believe PHP could access a database across different files that were included because they would share the environment space (at least that's my theory)
    I believe it could be done if you wanted to.

    I hope that helps.
    Regards,
    wiz
    I didn't know you could do that with a computer...
    Share on Google+

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center