www.webdeveloper.com
Results 1 to 5 of 5

Thread: code validator

  1. #1
    Join Date
    Mar 2006
    Location
    Canada
    Posts
    1,197

    code validator

    Hi

    Is there a program or web site that I exsistes to validate php scrpiting

    I have the below code that woorks on my test serber php version 5

    but does not work with my web server provider

    PHP Code:
    <?
    /* Check User Script */
    session_start();  // Start Session

    include ('config/db.php');
    // Conver to simple variables
    $username trim($_POST['username']);
    $password trim($_POST['password']);

    if((!
    $username) || (!$password))
    {
        
    $errorMsgR .= '<div style="width:200px" id= "formmessage">';
        
    $errorMsgR .= "Enter all login information!";
        
    $errorMsgR .= '</div>';
        include (
    'index.php');
        exit();
    }

    // Convert password to md5 hash
    $password md5($password);

    // check if the user info validates the db
    $sql mysql_query("SELECT * FROM users WHERE username='$username' AND password='$password' AND activated='1'");

    $login_check mysql_num_rows($sql);

    if(
    $login_check 0)
    {
        while(
    $row mysql_fetch_array($sql))
        {
        
    $last_login=$row['last_login'];
        
            foreach( 
    $row AS $key => $val )
            {
            $
    $key stripslashes$val );
        }
            
    // Register some session variables!
        
          
    $_SESSION['username'] = $username;
          
    $_SESSION['first_name'] = $first_name;
          
    $_SESSION['last_name'] = $last_name;
          
    $_SESSION['DOB'] = $DOB;
          
    $_SESSION['street_address'] = $street_address;
          
    $_SESSION['post_office_box'] = $post_office_box;
          
    $_SESSION['city'] = $city;
          
    $_SESSION['province'] = $province;
          
    $_SESSION['postal'] = $postal;
          
    $_SESSION['home_phone'] = $home_phone;
          
    $_SESSION['email_address'] = $email_address;
          
    $_SESSION['spousefirstname'] = $spousefirstname;
          
    $_SESSION['spouselastname'] = $spouselastname;
          
    $_SESSION['spousedob'] = $spousedob;
          
    $_SESSION['spousesex'] = $spousesex;
          
    $_SESSION['user_id'] = $user_id;
          
            
    header("Location: Home.php");

     
    $Updatesql mysql_query("SELECT new_login FROM users WHERE username = '$username'") or die(mysql_error());
     
            while(
    $r mysql_fetch_array($Updatesql))
            {
    mysql_query("UPDATE users SET last_login = '$r[new_login]', new_login = now() WHERE username = '$username'") or die(mysql_error());
    }

        }

            else 
            {
        
    $errorMsgR .= '<div style="width:200px" id= "formmessage">';
        
    $errorMsgR .= "You could not be logged in! Either the username and password do not match or you have not validated your membership!<br />Please try again!<br />";
        
        
    $errorMsgR .= '</div>';
        include (
    'index.php');
    }
    ?>
    Kevin

  2. #2
    Join Date
    Oct 2005
    Location
    Gold Coast, Australia
    Posts
    2,115
    To validate the syntax of a PHP file use the php_check_syntax() function. However, are you even sure your web server provider supports PHP?

  3. #3
    Join Date
    Apr 2005
    Location
    Bathurst, NSW, Australia
    Posts
    3,357
    Any errors?

    What version of PHP do they have installed?
    The answer to all these questions is Google.
    Give your thread a useful title | Webdeveloper.com Acceptable Use Policy
    Something wrong with your code? Validate first! |

    No Australian Net Censorship! The Australian government is wanting to follow in China's footsteps and "provide" nationwide Internet censorship, don't let them!

  4. #4
    Join Date
    Mar 2006
    Location
    Canada
    Posts
    1,197
    My my test server uses php 5.1.6 and my webserver users 4.1(web service is provides through hosting service.

    how would I use this php_check_syntax()
    Kevin

  5. #5
    Join Date
    Oct 2005
    Location
    Gold Coast, Australia
    Posts
    2,115
    Your PHP versions do not support the php_check_syntax() function, try placing the above code at the top of the erroneous PHP script. It will set the error_reporting directive to report all errors that the PHP parser encounters. For best results, remove all instances of the silence operator (@) as it will suppress the relative error message.
    PHP Code:
    // place this code at the top of the relative script
    error_reporting(E_ALL); 

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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
  •  
HTML5 Development Center



Recent Articles