CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   PHP (http://www.codingforums.com/forumdisplay.php?f=6)
-   -   No Compiler / Any Errors? (http://www.codingforums.com/showthread.php?t=286014)

budprime 01-18-2013 03:10 PM

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.';
}
?>


Fou-Lu 01-18-2013 03:30 PM

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.

budprime 01-18-2013 03:41 PM

Thanks again Fou! You're awesome! I'm definitely going to stay around here. This forums is awesome! :)

Fou-Lu 01-18-2013 04:02 PM

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.

budprime 01-18-2013 05:51 PM

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.';
}
?>


Dormilich 01-19-2013 09:11 AM

that error usually means that your closing braces } do not match the opening braces {.

tangoforce 01-19-2013 12:30 PM

Quote:

Originally Posted by budprime (Post 1307186)
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 (Post 1307307)
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++.

Fou-Lu 01-19-2013 04:33 PM

This particular issue is from your open heredoc. Terminate the heredoc before continuing with the processing instructions.


All times are GMT +1. The time now is 01:43 AM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.