Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-18-2013, 03:10 PM   PM User | #1
budprime
New to the CF scene

 
Join Date: Jan 2013
Posts: 5
Thanks: 3
Thanked 0 Times in 0 Posts
budprime is an unknown quantity at this point
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.';
}
?>
budprime is offline   Reply With Quote
Old 01-18-2013, 03:30 PM   PM User | #2
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,649
Thanks: 4
Thanked 2,450 Times in 2,419 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
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.
__________________
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php
Fou-Lu is offline   Reply With Quote
Users who have thanked Fou-Lu for this post:
budprime (01-18-2013)
Old 01-18-2013, 03:41 PM   PM User | #3
budprime
New to the CF scene

 
Join Date: Jan 2013
Posts: 5
Thanks: 3
Thanked 0 Times in 0 Posts
budprime is an unknown quantity at this point
Thanks again Fou! You're awesome! I'm definitely going to stay around here. This forums is awesome!
budprime is offline   Reply With Quote
Old 01-18-2013, 04:02 PM   PM User | #4
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,649
Thanks: 4
Thanked 2,450 Times in 2,419 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
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.
__________________
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php
Fou-Lu is offline   Reply With Quote
Users who have thanked Fou-Lu for this post:
budprime (01-18-2013)
Old 01-18-2013, 05:51 PM   PM User | #5
budprime
New to the CF scene

 
Join Date: Jan 2013
Posts: 5
Thanks: 3
Thanked 0 Times in 0 Posts
budprime is an unknown quantity at this point
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.';
}
?>
budprime is offline   Reply With Quote
Old 01-19-2013, 09:11 AM   PM User | #6
Dormilich
Senior Coder

 
Dormilich's Avatar
 
Join Date: Jan 2010
Location: Behind the Wall
Posts: 2,877
Thanks: 9
Thanked 291 Times in 287 Posts
Dormilich is on a distinguished road
that error usually means that your closing braces } do not match the opening braces {.
__________________
please post your code wrapped in [CODE] [/CODE] tags
Dormilich is offline   Reply With Quote
Old 01-19-2013, 12:30 PM   PM User | #7
tangoforce
Senior Coder

 
tangoforce's Avatar
 
Join Date: Feb 2011
Location: Your Monitor
Posts: 3,504
Thanks: 45
Thanked 439 Times in 428 Posts
tangoforce will become famous soon enoughtangoforce will become famous soon enough
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++.
__________________
Please wrap your code in [php] tags. It is a sticky topic and it HELPS us to HELP YOU!
TIP: Coding styles and $end errors :::::::::: TIP: Warning: Cannot modify header information - headers already sent :::::::::: TIP: Quotes / Parse error: syntax error, unexpected T_..
PHP Code:
//Please don't use this for your form processing:
if (isset($_POST['submit']))
//Internet explorer has a bug and does not always send the submit value. 
Explanation: The IE if(isset($_POST['submit'])) bug explained.
tangoforce is offline   Reply With Quote
Old 01-19-2013, 04:33 PM   PM User | #8
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,649
Thanks: 4
Thanked 2,450 Times in 2,419 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
This particular issue is from your open heredoc. Terminate the heredoc before continuing with the processing instructions.
__________________
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php
Fou-Lu is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:04 PM.


Advertisement
Log in to turn off these ads.