Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2012
    Posts
    19

    Unanswered: Help in removing error

    PHP Code:
    <?php
            
    //Post variables from step 1 and then check whether connect or not.
            
    $host_post=$_POST['host-s1'];
            
    $user_post=$_POST['user-s1'];
            
    $pass_post=$_POST['pass-s1'];
            
    $admin_post=$_POST['admin-s1'];
            
    $apass_post=$_POST['apass-s1'];
            
            
    //Checking mysql Connection if it corrects or not.
            
            
    $conn=mysql_connect($host_post,$user_post,$pass_post);
            if(!
    $conn){
            
    $status=0;
            echo 
    "Your connection details is not correct Check that";
            echo 
    "<br>";
            echo 
    "";
            }
            else {
            
    $status=1;
            echo 
    "Connection Established you can press continue.";
            }
            
    ?>
            <br>
            <br>
            <br><br>
            <br><br><br><br><br><br>
            <?php 
            
    if($status==0){
            echo 
    "Press back button";
            }
            else if(
    $status==1){
            echo 
    "<div style='float:right'>";
            echo 
    "<form action='' method='post'>";
            echo 
    "<input type='button' value='Continue' />";
            echo 
    "</form></div>";
            }
    ?>

    Warning: mysql_connect(): php_network_getaddresses: getaddrinfo failed: No such host is known. in C:\wamp\www\website1\install\index2.php on line 67
    Call Stack
    # Time Memory Function Location
    1 0.0008 148408 {main}( ) ..\index2.php:0
    2 0.0100 156712 mysql_connect ( ) ..\index2.php:67

    ( ! ) Warning: mysql_connect(): php_network_getaddresses: getaddrinfo failed: No such host is known. in C:\wamp\www\website1\install\index2.php on line 67
    Call Stack
    # Time Memory Function Location
    1 0.0008 148408 {main}( ) ..\index2.php:0
    2 0.0100 156712 mysql_connect ( ) ..\index2.php:67



    I get this error i want if someone enter wrong user of database connection in the form it don't give error of mysql or php error just give me my error and that is either back button on error and next button on successful connection

  2. #2
    Join Date
    Jan 2012
    Posts
    19
    does

    error_reporting(0);

    works fix ?

    same like wordpress have no error showing like some error in line 3 if database host is not defined.

    it gives error like warning: mysql_connect(): etc

    so i use error_reporting(0);

    your suggestion will be appreciable.

  3. #3
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    use the 'or die' construct to give you the MySQLERR_NO
    http://php.net/manual/en/function.die.php

    PHP: mysql_errno - Manual
    PHP: mysql_error - Manual

    PHP Code:
     $dbr=@mysql_select_db(DATABASE,$cnn) or die ("MyScript. MyErrornumber - Failed to  dowhatever:".mysql_errno().": ".mysql_error()); 
    upiu may also need to set an appropriate error reporting level
    http://php.net/manual/en/function.error-reporting.php
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

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