SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    Apache Expert i_like_php's Avatar
    Join Date
    Nov 2001
    Location
    Dallas, Texas
    Posts
    1,342
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Using The If Statement

    ok what i am trying to accomplish here seems fairly easy, but i've never done this. so what i am hoping to do is, redirect a page to another using the if statement in php.

    for example let's say i have a page called database.php and i would like for it to point to another file, whenever mysql is down to something like nodatabase.php.

    the issue i am having how can i get the if statement clause to know when mysql goes down, to redirect it to another page, without having to use .htaccess.


    if == (mysql_connect($d_host,$dbuser,$dbpass);

    } else {
    $ = 'show nodatabase.php instead';
    }

    i hope i didn't confuse anybody but thanks in advance.
    i love php

  2. #2
    SitePoint Wizard silver trophy Jelena's Avatar
    Join Date
    Feb 2005
    Location
    Universum, 3rd Corner
    Posts
    3,000
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $link mysql_connect('localhost''mysql_user''mysql_password');
    if (!
    $link) {
       
    header("Location: nodatabase.php");

    -- Jelena --


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •