+ Reply to Thread
Results 1 to 4 of 4

Thread: Simple Php Connect

  1. #1
    Kenbob is offline x10Hosting Member Kenbob is an unknown quantity at this point
    Join Date
    Oct 2007
    Posts
    18

    Simple Php Connect

    took this straight from
    http://www.w3schools.com/php/php_mysql_connect.asp

    In the following example we store the connection in a variable ($con) for later use in the script. The "die" part will be executed if the connection fails:

    <?php
    $con = mysql_connect("localhost","peter","abc123");
    if (!$con)
    {
    die('Could not connect: ' . mysql_error());
    }// some code

    This is bogus code --- when you run it it says
    Parse error: syntax error, unexpected T_STRING in /home/kenbob/public_html/form/db_create_table.php on line 9

    It does not DIE and print off the script code "could not connect"

    Does this site use a different PHP verison?
    Last edited by Kenbob; 11-26-2007 at 09:15 PM.

  2. #2
    Slothie's Avatar
    Slothie is offline Lord Of The Keys Slothie is an unknown quantity at this point
    Join Date
    Sep 2007
    Location
    Singapore
    Posts
    1,432

    Re: Simple Php Connect

    Look again closely and you'll see you misquoted your mysql_connect statement.

    Easiest 70 points you'll make on x10

    Feel free to add my reputation by clicking on the if you found my post helpful to you :P


    If I am not responding to your PMs, that means I am ignoring you. Take a hint.



    09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0


  3. #3
    Kenbob is offline x10Hosting Member Kenbob is an unknown quantity at this point
    Join Date
    Oct 2007
    Posts
    18

    Re: Simple Php Connect

    I had the other quote in there ====== anyone help!
    Edit:
    took this straight from
    http://www.w3schools.com/php/php_mysql_connect.asp

    In the following example we store the connection in a variable ($con) for later use in the script. The "die" part will be executed if the connection fails:

    <?php
    $con = mysql_connect("localhost","peter","abc123");
    if (!$con)
    {
    die('Could not connect: ' . mysql_error());
    }// some code

    This is bogus code --- when you run it it says
    Parse error: syntax error, unexpected T_STRING in /home/kenbob/public_html/form/db_create_table.php on line 9

    It does not DIE and print off the script code "could not connect"

    Does this site use a different PHP verison?
    Last edited by Kenbob; 11-26-2007 at 09:12 PM. Reason: Automerged Doublepost

  4. #4
    Slothie's Avatar
    Slothie is offline Lord Of The Keys Slothie is an unknown quantity at this point
    Join Date
    Sep 2007
    Location
    Singapore
    Posts
    1,432

    Re: Simple Php Connect

    Nothing is wrong with it, I use similar code on almost all my sites.

    Easiest 70 points you'll make on x10

    Feel free to add my reputation by clicking on the if you found my post helpful to you :P


    If I am not responding to your PMs, that means I am ignoring you. Take a hint.



    09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0


+ Reply to Thread

Similar Threads

  1. [PHP] PHP For Starters
    By Complex in forum Tutorials
    Replies: 24
    Last Post: 06-14-2008, 11:40 PM
  2. Unstand PHP?
    By o0slowpaul0o in forum Tutorials
    Replies: 8
    Last Post: 01-07-2008, 09:16 PM
  3. Sigo con problemas con phpbb2
    By reciecho in forum Soporte
    Replies: 7
    Last Post: 10-20-2007, 06:28 PM
  4. "PHP Startup: Invalid Library" - Interesting error
    By javaguy78 in forum Free Hosting
    Replies: 5
    Last Post: 03-27-2007, 02:33 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers