[php] mySQL Connect?

Results 1 to 4 of 4
  1. #1
    Sorcerer Supreme Tony is offline
    Member +Rank
    Feb 2011 Join Date
    349Posts

    [php] mySQL Connect?

    Best way to go?

    PHP Code:
    mysql_connect($mysql_host$mysql_user$mysql_pass) or die("<center><font size=+4><bold>mCMS - MySQL Error</body></font></center><br /><center>Unable to connect to your MySQL Connection Information</center>");
    mysql_select_db($mysql_data) or die("<center><font size=+4><bold>mCMS - MySQL Error</body></font></center><br /><center>Unable to connect to database '" $mysql_data "'</center>"); 
    Last edited by rice; 26-09-11 at 07:33 AM.


  2. #2
    :-) s-p-n is offline
    DeveloperRank
    Jun 2007 Join Date
    Next DoorLocation
    2,097Posts

    Re: mySQL Connect?

    Not really.. This for a custom CMS? (got that from err-message)

    I prefer the MySQL improved extension over the ancient one.

    Font tags are deprecated..
    Center tags are deprecated..
    never seen a <bold> tag, are standards-compliant browsers missing something or are you?

    Also you can benefit from using a framework and/or OOP for this.

    That's all I've got to say.

    Edit:
    Whoops, forgot to mention that you shouldn't give information about the database, such as it's name or any field names, in error messages when publishing for production-use. So you should have a switch somewhere in your app for development / production environments, and build error handlers and exceptions around that idea.
    Last edited by s-p-n; 24-09-11 at 04:45 PM.

  3. #3
    Sorcerer Supreme Tony is offline
    Member +Rank
    Feb 2011 Join Date
    349Posts

    Re: mySQL Connect?

    Yes, this is from a custom cms.

  4. #4
    Grand Master Ron is offline
    Grand MasterRank
    Apr 2005 Join Date
    Location
    8,988Posts

    Re: [php] mySQL Connect?

    PHP Code:
    <?php
    $mysqli_connect
    ($host$user$pass$db) or die('Error connecting to db');
    ?>
    Just about all of the visual text tags you're using are deprecated. Use CSS.



Advertisement