Thread: Php example

Page 2 of 2 First 12
  • Jump to page:
    #16
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2008
    Posts
    241
    Rep Power
    11
    FIRST OFF thank you very much for your time and patience...its greatly appreciated.

    one more question if you would be so kind to lend me another hand...if you look at the link in my first post here...
    I am trying the example from the first entry you read or see below

    http://forums.devshed.com/php-faqs-and-stickies-167/how-to-program-a-basic-but-secure-login-system-using-891201.html

    Am I right to believe that I would take out the html code from each php page in the example and create new html files...these new html files would then call the php code which would return the values and info to the html pages being seen in the browser?

    ON the register.html page i created below it calls the PHP page register.php

    BUT I GET AN ERROR:
    Server error
    The website encountered an error while retrieving http://localhost:83/register.php. It may be down for maintenance or configured incorrectly.
    Here are some suggestions:
    Reload this webpage later.
    HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request.

    I am either getting the error because it cant find the php page, but its in the same folder
    It cant find the reference to the common.php file which is trying to create a connection to the db
    Or some other reason....

    Really want to get this example going...great learning tool...

    I GUESS MY MAIN question is am I right to assume that with this example I should be grabbing the html code from each php file and creating html files that call the php file?

    Code:
    <!DOCTYPE html>
    <html lang="en">
    
    <head>
            <meta charset="utf-8">
            <title>Hello World</title>
        </head>
        <body>
            <h1>Register</h1> 
            <form action="register.php" method="post"> 
                Username:<br /> 
                <input type="text" name="username" value="" /> 
                <br /><br /> 
                E-Mail:<br /> 
                <input type="text" name="email" value="" /> 
                <br /><br /> 
                Password:<br /> 
                <input type="password" name="password" value="" /> 
                <br /><br /> 
                <input type="submit" value="Register" /> 
            </form>  
        </body>
    </html>
    Last edited by jaykappy; February 1st, 2013 at 04:09 PM.
  2. #17
  3. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,301
    Rep Power
    7170
    PHP's PDO extension doesn't support MSSQL right now. In order to use MSSQL with PHP you need to use the SQLSRV API: http://www.php.net/manual/en/book.sqlsrv.php

    The API for this extension is different than the API for the PDO extension, so the parts of the tutorial that involve running SQL statements won't be that helpful. Additionally MSSQL uses a slightly different SQL syntax than MySQL, so the SQL queries in the tutorial will need modified as well.

    The tutorial is not really intended to have the files split into separate PHP and HTML files.

    The 500 error doesn't mean that it could not find the file; that would be a 404 error. The 500 error means something went wrong when it tried to execute the PHP script. You should check the error log for IIS to determine what went wrong.
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around
  4. #18
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2008
    Posts
    241
    Rep Power
    11
    Thanks again....no problem will move to mysql....free anyways from what I know and has users and roles the same as sql server right....will have to research what the difference is....
    Yea weird....I try and reference the php file as in the example I get that error....will have to check the logs although dont really know how....very green that that part of it....
    I installed php and activated it in IIS....is there something else that I am missing....that would cause that error......
    But I guess thats why you said check the log....will do that as soon as I get back to work...
    Again I thank you very much for you help here....know that once I get this potion going things will smooth out...
  6. #19
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2008
    Posts
    241
    Rep Power
    11
    Thanks for your help last week...still chuggin along here.

    I went into Event Viewer to try and find the error logs but cant find specifically what I am looking for....anyone
    Where do I find the error logs for my specific web site in IIS?

    THanks
  8. #20
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2008
    Posts
    241
    Rep Power
    11
    Think I found it in IIS under PHP Manager...going to check that out...installing MySQL and test.
    Thanks
  10. #21
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2008
    Posts
    241
    Rep Power
    11
    Im seeing installers for 32bit version of MySQL...will that be ok on a 64 bit machine?
  12. #22
  13. Wiser? Not exactly.
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    May 2001
    Location
    Bonita Springs, FL
    Posts
    5,905
    Rep Power
    3969
    Originally Posted by E-Oreo
    PHP's PDO extension doesn't support MSSQL right now. In order to use MSSQL with PHP you need to use the SQLSRV API: http://www.php.net/manual/en/book.sqlsrv.php
    The SQLSRV api can be accessed through a PDO driver, you just have to load the appropriate dll extension. Once loaded you'd construct the PDO object as:
    Code:
    new PDO('sqlsrv:SERVER='.$host.';DATABASE='.$database, $user, $pass);
    Recycle your old CD's, don't just trash them



    If I helped you out, show some love with some reputation, or tip with Bitcoins to 1N645HfYf63UbcvxajLKiSKpYHAq2Zxud
  14. #23
  15. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2008
    Posts
    241
    Rep Power
    11
    Was able to install MySQL Server.
    Trying to make a simple test call to it from my web page...

    This is installed on my local PC and the HTML code is being run from IIS on the same machine.

    1. Do I just put "localhost" for the hostname or the actual name of the instance?
    2. In the db I created an ADMIN account and a USER account the USER account is being referenced below
    3. HTML5Test is the name of the Schema/Database

    Any ideas why it is failing

    Code:
    <?php
    $db['hostname'] = "MySQL_PublicWorks";
    //$db['hostname'] = "localhost";
    $db['username'] = "jkappy";
    $db['password'] = "password";  //I did change this just not showing my password
    $db['database'] = "HTML5Test";
    
    //connection string
    $conn = mysql_connect($db['hostname'], $db['username'], $db['password']);
    
    
    //does it work? :o
    if($conn)
    {
        echo "works";
    }
    else 
    {
        echo "fails";
    }
    ?>
  16. #24
  17. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2008
    Posts
    241
    Rep Power
    11
    Its failing to connect and I am getting this error:

    Failed to connect to the database: SQLSTATE[HY000] [2002] No connection could be made because the target machine actively refused it.

    Thoughts? The target machine is my PC
  18. #25
  19. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2008
    Posts
    241
    Rep Power
    11
    Changed the HOST to this: $host = "127.0.0.1:2200";

    Now getting another error...but think I am getting closer

    ERROR:
    Failed to connect to the database: SQLSTATE[28000] [1045] Access denied for user 'jkappy'@'localhost' (using password: YES)

    IM not using password YES? hmmmmm whats causing this?
  20. #26
  21. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2008
    Posts
    241
    Rep Power
    11
    Went in and created a new user....everything works..

    THANKS FOR YOUR TIME AND HELP AND PATIENCE...

    very very appreciated.
  22. #27
  23. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2008
    Posts
    241
    Rep Power
    11
    Originally Posted by kicken
    The SQLSRV api can be accessed through a PDO driver, you just have to load the appropriate dll extension. Once loaded you'd construct the PDO object as:
    Code:
    new PDO('sqlsrv:SERVER='.$host.';DATABASE='.$database, $user, $pass);
    WHERE do I get this correct dll...not really sure about this and do not want to mess anything up....I have a version working with MySQL but would like to get anther working with SQL Server
    Thanks
  24. #28
  25. Wiser? Not exactly.
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    May 2001
    Location
    Bonita Springs, FL
    Posts
    5,905
    Rep Power
    3969
    Start here: http://www.microsoft.com/en-us/downl....aspx?id=20098

    The dlls are contained in the .exe file and will be extracted when you run it.

    Before you can use them you'll need to install the 2012 native client. Details and a link to it are on the above page.

    Comments on this post

    • jaykappy agrees
    Recycle your old CD's, don't just trash them



    If I helped you out, show some love with some reputation, or tip with Bitcoins to 1N645HfYf63UbcvxajLKiSKpYHAq2Zxud
  26. #29
  27. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2008
    Posts
    241
    Rep Power
    11
    Thanks Kickin....and EVERYONE who commented on this post...know it was a little loaded but have things up and running...just have to get the SQL Server dlls in place and test this..but pretty confident it will all work out.

    THANKS AGAIN...your help and patience is greatly appreciated.
Page 2 of 2 First 12
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo