Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 06-25-2005, 07:20 PM Easy php question
Extreme Talker

Posts: 171
Trades: 0
I was trying to put html in php echo. I did it perfectly before but i lost the finished script. I put the html in bold.


<?php

define('IN_PHPBB', false);
$phpbb_root_path = '/home/somplan/public_html/forums/';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);

//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);
//
// End session management
//


if ( $userdata['session_logged_in'] ) {
$username = $userdata['username'];
echo ("Welcome $username <a href="http://forums.somplanet.com/logout.php>Log Out</a>"); } else {
echo('
This is where i put the html for the Login Forum
');
}
?>
mohamoud is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-25-2005, 07:48 PM
The_Anomaly's Avatar
Extreme Talker

Posts: 216
Location: Boston, Ma
Trades: 0
Code:
echo ("Welcome $username <a href="http://forums.somplanet.com/logout.php>Log Out</a>");
that line i'm almost 100% sure is wrong, i just started php myself but try this out.

Code:
echo "Welcome $username <a href="http://forums.someplanet.com/logout.php>Log Out</a>";
i'm pretty sure the echo will not work if you put () around what your trying to display.
The_Anomaly is offline
Reply With Quote
View Public Profile
 
Old 06-25-2005, 07:51 PM
Unknown.

Posts: 1,693
Trades: 0
If your going to use " inside a echo you must add a backslash before it.. so it becomes \" or just use ' instead...

The correct code..
PHP Code:
<?php

define
('IN_PHPBB'false);
$phpbb_root_path '/home/somplan/public_html/forums/';
include(
$phpbb_root_path 'extension.inc');
include(
$phpbb_root_path 'common.'.$phpEx);

//
// Start session management
//
$userdata session_pagestart($user_ipPAGE_INDEX);
init_userprefs($userdata);
//
// End session management
//


if ( $userdata['session_logged_in'] ) {
$username $userdata['username'];
echo 
"Welcome $username <a href=\"http://forums.somplanet.com/logout.php\">Log Out</a>"; } else {
echo 
"This is where i put the html for the Login Forum";
}
?>
Dark-Skys99 is offline
Reply With Quote
View Public Profile
 
Old 06-25-2005, 08:05 PM
Anacrusis's Avatar
Defies a Status

Posts: 2,099
Name: Adam
Location: Colchester CT
Trades: 0
It's ok to put parens () around the echo statement text. And as dark-Skys99 said, you need to put a \ before any double quotes within the echo statement.

I also noticed one thing, although it won't cause any PHP errors, it will make your link bad... your mssing a quote around the href url:
Code:
echo ("Welcome $username <a href=\"http://forums.somplanet.com/logout.php\">Log Out</a>");
Anacrusis is offline
Reply With Quote
View Public Profile
 
Old 06-25-2005, 08:45 PM
Extreme Talker

Posts: 171
Trades: 0
I am get a error saying:
Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in /home/somplan/public_html/test/test1.php on line 21

The final code is :
PHP Code:
<?php

define
('IN_PHPBB'false);
$phpbb_root_path '/home/somplan/public_html/forums/';
include(
$phpbb_root_path 'extension.inc');
include(
$phpbb_root_path 'common.'.$phpEx);

//
// Start session management
//
$userdata session_pagestart($user_ipPAGE_INDEX);
init_userprefs($userdata);
//
// End session management
//


if ( $userdata['session_logged_in'] ) {
$username $userdata['username'];
echo 
"Welcome $username <a href=\"http://forums.somplanet.com/logout.php\">Log Out</a>"; } else {
echo 
"<form action="http://www.somplanet.com/forums/login.php" method="post" target="_top">
<table style="border-collapse: collapse;" bordercolor="#000000" cellspacing="0" cellpadding="5" width="230" border="0">
<
tbody>
<
tr>
<
td valign="top" width="100%">
<
div>
<
center><font face="Arial" size="4">Forum Login</font></center>
<
font face="Verdana" size="2">
Username:</font
<
input style="border-right: #4682b4 1px solid; border-top: #4682b4 1px solid; font-size: 11px; background: #fff; vertical-align: middle; border-left: #4682b4 1px solid; color: #000000; border-bottom: #4682b4 1px solid; font-family: Trebuchet MS;" type="text" maxlength="40" size="25" value="" name="username"> </div></td></tr>
<
tr>
<
td valign="top" width="100%">
<
div><font face="Verdana" size="2">Password:</font
<
input style="border-right: #4682b4 1px solid; border-top: #4682b4 1px solid; font-size: 11px; background: #fff; vertical-align: middle; border-left: #4682b4 1px solid; color: #000000; border-bottom: #4682b4 1px solid; font-family: Trebuchet MS;" type="password" maxlength="32" size="25" value="" name="password"> </div></td></tr>
<
tr>
<
td valign="top" width="100%">
<
div>
<
div align="center">
<
input type="hidden" value="" name="redirect"
<
input style="border-right: #4682b4 1px solid; border-top: #4682b4 1px solid; font-size: 11px; background: #fff; vertical-align: middle; border-left: #4682b4 1px solid; color: #000000; border-bottom: #4682b4 1px solid; font-family: Trebuchet MS;" class="mainoption" type="submit" value="Log in" name="login"></div></div></td></tr></tbody></table>
</
form>";
}
?>
mohamoud is offline
Reply With Quote
View Public Profile
 
Old 06-25-2005, 08:53 PM
Unknown.

Posts: 1,693
Trades: 0
Quote:
Originally Posted by Dark-Skys99
If your going to use " inside a echo you must add a backslash before it.. so it becomes \" or just use ' instead...
This should work..
PHP Code:
<?php

define
('IN_PHPBB'false);
$phpbb_root_path '/home/somplan/public_html/forums/';
include(
$phpbb_root_path 'extension.inc');
include(
$phpbb_root_path 'common.'.$phpEx);

//
// Start session management
//
$userdata session_pagestart($user_ipPAGE_INDEX);
init_userprefs($userdata);
//
// End session management
//


if ( $userdata['session_logged_in'] ) {
$username $userdata['username'];
echo 
"Welcome $username <a href=\"http://forums.somplanet.com/logout.php\">Log Out</a>"; } else {
echo 
"<form action=\"http://www.somplanet.com/forums/login.php\" method=\"post\" target=\"_top\">
<table style=\"border-collapse: collapse;\" bordercolor=\"#000000\" cellspacing=\"0\" cellpadding=\"5\" width=\"230\" border=\"0\">
<tbody>
<tr>
<td valign=\"top\" width=\"100%\">
<div>
<center><font face=\"Arial\" size=\"4\">Forum Login</font></center>
<font face=\"Verdana\" size=\"2\">
Username:</font>
<input style=\"border-right: #4682b4 1px solid; border-top: #4682b4 1px solid; font-size: 11px; background: #fff; vertical-align: middle; border-left: #4682b4 1px solid; color: #000000; border-bottom: #4682b4 1px solid; font-family: Trebuchet MS;\" type=\"text\" maxlength=\"40\" size=\"25\" value=\"\" name=\"username\"> </div></td></tr>
<tr>
<td valign=\"top\" width=\"100%\">
<div><font face=\"Verdana\" size=\"2\">Password:</font>
<input style=\"border-right: #4682b4 1px solid; border-top: #4682b4 1px solid; font-size: 11px; background: #fff; vertical-align: middle; border-left: #4682b4 1px solid; color: #000000; border-bottom: #4682b4 1px solid; font-family: Trebuchet MS;\" type=\"password\" maxlength=\"32\" size=\"25\" value=\"\" name=\"password\"> </div></td></tr>
<tr>
<td valign=\"top\" width=\"100%\">
<div>
<div align=\"center\">
<input type=\"hidden\" value=\"\" name=\"redirect\">
<input style=\"border-right: #4682b4 1px solid; border-top: #4682b4 1px solid; font-size: 11px; background: #fff; vertical-align: middle; border-left: #4682b4 1px solid; color: #000000; border-bottom: #4682b4 1px solid; font-family: Trebuchet MS;\" class=\"mainoption\" type=\"submit\" value=\"Log in\" name=\"login\"></div></div></td></tr></tbody></table>
</form>"
;
}
?>
Dark-Skys99 is offline
Reply With Quote
View Public Profile
 
Old 06-25-2005, 11:02 PM
metho's Avatar
Ultra Talker

Posts: 481
Location: Gold Coast - Brisbane QLD, Australia
Trades: 0
Instead of giving yourself a headache using escaped echo statements, just use opening and closing php tags where your desired html output is situated.

For e.g.

PHP Code:
<?php

define
('IN_PHPBB'false);
$phpbb_root_path '/home/somplan/public_html/forums/';
include(
$phpbb_root_path 'extension.inc');
include(
$phpbb_root_path 'common.' $phpEx);

//
// Start session management
//
$userdata session_pagestart($user_ipPAGE_INDEX);
init_userprefs($userdata);
//
// End session management

if ( $userdata['session_logged_in'] ) 

{

$username $userdata['username'];

?>

Welcome <?php echo $username?> <a href="http://forums.somplanet.com/logout.php">Log Out</a>

<?php

} else {

?>
<form action="http://www.somplanet.com/forums/login.php" method="post" target="_top">
<table style="border-collapse: collapse;" bordercolor="#000000" cellspacing="0" cellpadding="5" width="230" border="0">
<tbody>
<tr>
<td valign="top" width="100%">
<div>
<center><font face="Arial" size="4">Forum Login</font></center>
<font face="Verdana" size="2">
Username:</font>
<input style="border-right: #4682b4 1px solid; border-top: #4682b4 1px solid; font-size: 11px; background: #fff; vertical-align: middle; border-left: #4682b4 1px solid; color: #000000; border-bottom: #4682b4 1px solid; font-family: Trebuchet MS;" type="text" maxlength="40" size="25" value="" name="username"> </div></td></tr>
<tr>
<td valign="top" width="100%">
<div><font face="Verdana" size="2">Password:</font>
<input style="border-right: #4682b4 1px solid; border-top: #4682b4 1px solid; font-size: 11px; background: #fff; vertical-align: middle; border-left: #4682b4 1px solid; color: #000000; border-bottom: #4682b4 1px solid; font-family: Trebuchet MS;" type="password" maxlength="32" size="25" value="" name="password"> </div></td></tr>
<tr>
<td valign="top" width="100%">
<div>
<div align="center">
<input type="hidden" value="" name="redirect">
<input style="border-right: #4682b4 1px solid; border-top: #4682b4 1px solid; font-size: 11px; background: #fff; vertical-align: middle; border-left: #4682b4 1px solid; color: #000000; border-bottom: #4682b4 1px solid; font-family: Trebuchet MS;" class="mainoption" type="submit" value="Log in" name="login"></div></div></td></tr></tbody></table>
</form>
<?php

}

?>
__________________
I do
Please login or register to view this content. Registration is FREE
based.
Spend a lot of time in
Please login or register to view this content. Registration is FREE
.
And
Please login or register to view this content. Registration is FREE
chews up the rest.
metho is offline
Reply With Quote
View Public Profile Visit metho's homepage!
 
Reply     « Reply to Easy php question
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.25262 seconds with 12 queries