Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New to the CF scene
    Join Date
    Jan 2013
    Posts
    5
    Thanks
    3
    Thanked 0 Times in 0 Posts

    No Compiler / Any Errors?

    I just read the thread on how to become a better PHP Programmer, and I currently do not have a compiler, nor does my web host have display errors on for PHP.

    When I add ini_set('display_errors', 1); with error_reporting(E_ALL);, I still get Error 500, which basically means there is something wrong with the server instead of the PHP errors. I tried overwritting PHP.ini, but that didn't work out either.

    That's why I'm in need of help again. I added some code onto this script and I need someone to check it out for any errors.

    Many thanks guys! Shouts to Fo for helping me earlier!

    PHP Code:
    <?php
    ini_set
    ('display_errors'1); 
    error_reporting(E_ALL);
    $whm_host "127.0.0.1";
    $whm_user "user";
    $whm_pass "pass";
    $whm_package "user_package";
    chdir('/home/csufhous/public_html/example.com/forums');
    define("IN_MYBB"1);
    require 
    './global.php';
    if((
    $mybb->user['postnum']) >= 30){
    function 
    getVar($name$def '') {
    if (isset(
    $_REQUEST[$name]))
    return 
    $_REQUEST[$name];
    else
    return 
    $def;
    }
    if (!isset(
    $user_domain)){
    $user_domain getVar('domain');
    }
    if (!isset(
    $user_name)){
    $user_name $mybb->user['username'];
    }
    if (!isset(
    $user_pass)){
    $user_pass getVar('password');
    }
    if (!isset(
    $user_plan)){
    $user_plan '$whm_package';
    }
    if (!isset(
    $user_email)){
    $user_email $mybb->user['email'];
    }
    if (!empty(
    $user_name)){
    $script "http://{$whm_user}:{$whm_pass}@{$whm_host}:2086/scripts/wwwacct";
    $params "?plan={$user_plan}&domain={$user_domain}&username={$user_name}&password={$user_pass}&contactemail={$user_email}";
    $result file_get_contents($script.$params);
    echo 
    'Your account has been created.';
    }
    else {
    $frm 
    <
    form method="post">
    <
    input name="domain" size="25"><br />
    <
    input name="password" size="25"><br />
    <
    input type="submit" value="Create Account">
    </
    form>
    echo 
    $frm;
    }
    }
    else{
    echo 
    'You have not met the requirements.';
    }
    ?>

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    You should also be able to find an error log somewhere within your home directory. I cannot recall if it typically goes above public_html or not. Looks to me that you probably have an fcgi build.
    This is syntactically incorrect:
    PHP Code:
    $frm 
    <
    form method="post">
    <
    input name="domain" size="25"><br />
    <
    input name="password" size="25"><br />
    <
    input type="submit" value="Create Account">
    </
    form>
    echo 
    $frm
    You can't assign a string without specifying it as a string. Simply put single quotes around that block and terminate it (the assignment is also optional):
    PHP Code:
    $frm '
    <form method="post">
    <input name="domain" size="25"><br />
    <input name="password" size="25"><br />
    <input type="submit" value="Create Account">
    </form>'
    ;
    echo 
    $frm
    The block with several if checks could be cleaned up by using ternary operations as well:
    PHP Code:
    $user_domain = isset($user_domain) ? $user_domain getVar('domain');
    $user_name = isset($user_name) ? $user_name $mybb->user['username']; 
    // etc. 
    That is optional of course, it simply cleans it up into one line.
    This probably won't work as desired: $user_plan = '$whm_package';. Single quotes are non-parsed in PHP, so $user_plan would be the literal string '$whm_package'. Remove the single quotes around the argument value, and it will parse the $whm_package variable instead.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • Users who have thanked Fou-Lu for this post:

    budprime (01-18-2013)

  • #3
    New to the CF scene
    Join Date
    Jan 2013
    Posts
    5
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Thanks again Fou! You're awesome! I'm definitely going to stay around here. This forums is awesome!

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    You should also download a local install webhost. WAMP and XAMP I see posted all the time, so I guess they're popular. It depends on your localmachine OS that dictates what you download. I can't help you configure it, but it looks like there are a lot of people here that can (I always download each item separately so I can mix and match as I see fit for testing).
    You'll want to get a good IDE as well. I use eclipse, but am considering changing since I'm unhappy with the approach zend took with the 5.4 implementation to the eclipse PDT, so I'm considering trying netbeans again (been years, didn't like it before). But I need an IDE with a debugger, so that's important. If you don't do a lot of debugging, lighter weight ones are Notepad++ for an example which offers syntax highlighting and (I believe?) code folding.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • Users who have thanked Fou-Lu for this post:

    budprime (01-18-2013)

  • #5
    New to the CF scene
    Join Date
    Jan 2013
    Posts
    5
    Thanks
    3
    Thanked 0 Times in 0 Posts
    I am getting...
    Code:
    Parse error: syntax error, unexpected $end in /home/csufhous/public_html/bowenhost.com/index.php on line 52
    And I am having a hard time finding the error. Can you help me out one last time?

    PHP Code:
    <?php
    ini_set
    ('display_errors'1); 
    error_reporting(E_ALL);
    $whm_host "127.0.0.1";
    $whm_user "user";
    $whm_pass "pass";
    $whm_package "user_package";
    chdir('/home/csufhous/public_html/example.com/forums');
    define("IN_MYBB"1);
    require 
    './global.php';
    if((
    $mybb->user['postnum']) >= 30){
    function 
    getVar($name$def '') {
    if (isset(
    $_REQUEST[$name]))
    return 
    $_REQUEST[$name];
    else
    return 
    $def;
    }
    if (!isset(
    $user_domain)){
    $user_domain getVar('domain');
    }
    if (!isset(
    $user_name)){
    $user_name $mybb->user['username'];
    }
    if (!isset(
    $user_pass)){
    $user_pass getVar('password');
    }
    if (!isset(
    $user_plan)){
    $user_plan $whm_package;
    }
    if (!isset(
    $user_email)){
    $user_email $mybb->user['email'];
    }
    if (!empty(
    $user_name)){
    $script "http://{$whm_user}:{$whm_pass}@{$whm_host}:2086/scripts/wwwacct";
    $params "?plan={$user_plan}&domain={$user_domain}&username={$user_name}&password={$user_pass}&contactemail={$user_email}";
    $result file_get_contents($script.$params);
    echo 
    'Your account has been created.';
    }
    else {
    $frm = <<<EOD
    <form method="post">
    <input name="domain" size="25"><br />
    <input name="password" size="25"><br />
    <input type="submit" value="Create Account">
    </form>
    echo $frm;
    }
    }
    else{
    echo 'You have not met the requirements.';
    }
    ?>

  • #6
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,237
    Thanks
    12
    Thanked 340 Times in 336 Posts
    that error usually means that your closing braces } do not match the opening braces {.
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer

  • #7
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,296
    Thanks
    57
    Thanked 525 Times in 512 Posts
    Blog Entries
    5
    Quote Originally Posted by budprime View Post
    I am getting...
    Code:
    Parse error: syntax error, unexpected $end in /home/csufhous/public_html/bowenhost.com/index.php on line 52
    And I am having a hard time finding the error. Can you help me out one last time?
    Quote Originally Posted by Dormilich View Post
    that error usually means that your closing braces } do not match the opening braces {.
    As Dormilich says, you need to check out your braces. Use an editor such as Notepad++ which has line numbers so that you can actually find 52 without counting. Also see the link in my signature about codingstyles which will demonstrate how to deal with mismatched braces using notepad++.
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!

  • #8
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    This particular issue is from your open heredoc. Terminate the heredoc before continuing with the processing instructions.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 


  •  

    Posting Permissions

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