PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
bobocheez
Forum Commoner
Posts: 25 Joined: Mon Oct 27, 2008 8:06 pm
Post
by bobocheez » Thu Oct 30, 2008 4:38 pm
Hi,
I have barely any knowledge of php/mysql, so if you don't like expalining things I dont suggest posting something
I have a social network script and throughout the script there are codes like this
Code: Select all
{REGISTRATION_CODE}
{EMAIL}
{USERNAME}
etc...
However, I tried to place the codes like the username one in other places(inside the users home section where they have to log in), well....i bet your saying duh idiot
I'm just basically wondering if I have to configure something in mysql - dont worry im not going to try to beg someone to do it, just hoping there is something a noob like me could do
(any other explanations are great too)
yacahuma
Forum Regular
Posts: 870 Joined: Sun Jul 01, 2007 7:11 am
Post
by yacahuma » Thu Oct 30, 2008 8:18 pm
not enough info
califdon
Jack of Zircons
Posts: 4484 Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA
Post
by califdon » Fri Oct 31, 2008 3:25 pm
With "barely any knowledge of php/mysql", I would say you are almost certain to render your system unworkable if you try to change anything. I'm not being sarcastic, and I'm actually sympathetic to your frustration. But the fact is that programming is highly complex and if you don't know how it works, even changing one comma or semicolon can totally prevent it from working.
bobocheez
Forum Commoner
Posts: 25 Joined: Mon Oct 27, 2008 8:06 pm
Post
by bobocheez » Fri Oct 31, 2008 5:06 pm
Na, its not getting to me.
I know the basics of php, but not enough to make something useful.
bmoyles0117
Forum Newbie
Posts: 22 Joined: Sun Nov 02, 2008 1:46 am
Post
by bmoyles0117 » Sun Nov 02, 2008 2:19 am
{} escapes PHP variable calls, the text within, is not identified by a variable assignment so you can assume two things. It is either being matched from a pattern match and replaced with a defined string. Or they have been previously declared as constants.
requinix
Spammer :|
Posts: 6617 Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA
Post
by requinix » Sun Nov 02, 2008 2:42 am
Public Service Announcement:
bmoyles0117 wrote: Or they have been previously declared as constants.
PHP only interprets them if the { is immediately followed by a $, so they don't work with constants (or function calls for that matter). So that leaves some sort of str_replace or preg_replace code at work.
Code: Select all
define("FOO", 3);
function three() { return "3"; }
// doesn't work
echo "1 + 2 = {FOO}";
echo "1 + 2 = {three()}";
// works
$foo = FOO; $three = "three";
echo "1 + 2 = {$foo}";
echo "1 + 2 = {$three()}"; // variable variables
s.dot
Tranquility In Moderation
Posts: 5001 Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana
Post
by s.dot » Sun Nov 02, 2008 2:44 am
The lines you have posted looks like template syntax to me. Where {USERNAME} is being replaced with a username value and so forth.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
pcoder
Forum Contributor
Posts: 230 Joined: Fri Nov 03, 2006 5:19 am
Post
by pcoder » Sun Nov 02, 2008 2:44 am
Try to explain your problem in more details.
bmoyles0117
Forum Newbie
Posts: 22 Joined: Sun Nov 02, 2008 1:46 am
Post
by bmoyles0117 » Sun Nov 02, 2008 3:14 am
ew.. my bad.. staying up too late tonight. haha good catch
tasairis wrote: Public Service Announcement:
bmoyles0117 wrote: Or they have been previously declared as constants.
PHP only interprets them if the { is immediately followed by a $, so they don't work with constants (or function calls for that matter). So that leaves some sort of str_replace or preg_replace code at work.
Code: Select all
define("FOO", 3);
function three() { return "3"; }
// doesn't work
echo "1 + 2 = {FOO}";
echo "1 + 2 = {three()}";
// works
$foo = FOO; $three = "three";
echo "1 + 2 = {$foo}";
echo "1 + 2 = {$three()}"; // variable variables
bobocheez
Forum Commoner
Posts: 25 Joined: Mon Oct 27, 2008 8:06 pm
Post
by bobocheez » Mon Nov 03, 2008 5:24 pm
basically i want to add
to the home.html
or get rid of the
sitename.com/
index.php? username
home.html
like your homepage on myspace
Code: Select all
<h1>Home</h1>
<table cellpadding="0" cellspacing="0"align="left">
<tr>
<td width="42"> </td>
<td>
<table border="0" cellpadding="0" cellspacing="10">
<tr>
<td valign="top" width="150">
<img src='[color=#FF0000]{IMAGE}[/color]'/><br />
<a href='index.php?page=view_photo_album&id=[color=#FF0000]{ALBUM_ID}[/color]'>Change Photo</a>
<div id="heading_1">
<h2>Profile/Settings</h2>
</div>
<div id="content_1">
<ol id="home">
<li><a href='[color=#FF0000]{PROFILE_URL}[/color]'>View Profile
</a></li>
<li><a href='index.php?page=create_profile'>Edit Profile</a></li>
<li><a href='index.php?page=account_info'>Account Settings</a></li>
<li><a href='index.php?page=privacy_settings'>Privacy Settings</a></li>
</ol>
</div>
<div id="heading_1">
<h2>My Photos/Videos</h2>
</div>
<div id="content_1">
<ol id="home">
<li><a href='index.php?page=view_my_photos'>Add/Edit Photos</a></li>
<li><a href='index.php?page=view_my_videos'>Add/Change Videos</a></li>
</ol>
</div>
<div id="heading_1">
<h2>Manage</h2>
</div>
<div id="content_1">
<ol id="home">
<li><a href='index.php?page=view_calendar'>Manage Calendar</a></li>
<li><a href='index.php?page=blog_home'>Manage Blog</a></li>
<li><a href='index.php?page=address_book'>Manage Address Book</a></li>
</ol>
</div>
<br/>
</td>
<td valign="top" width="350">
<div id="heading_3">
<h2>My Information</h2>
</div>
<div id="content_1">
Profile Views :[color=#FF0000]{PROFILE_VIEW}[/color]<br />
Last Login :[color=#FF0000]{LAST_LOGIN}[/color]<br />
[color=#FF0000]{PROFILE_URL}[/color] </div>
<br />
[color=#FF0000]{WEBBOX_COOLPEOPLE}[/color]
[color=#FF0000]{WEBBOX_FRIENDS}[/color]
</td>
<td width="150" valign="top">
<div id="heading_3">
<h2>My Mail</h2>
</div>
<div id="content_1">
<ol id="mail">
<li id="inbox"><a href='index.php?page=messages_inbox'>Inbox</a> ([color=#FF0000]{INBOX_QUANTITY}[/color])</li>
<li id="sent"><a href='index.php?page=sent_messages'>Sent</a> ([color=#FF0000]{SENT_QUANTITY}[/color])</li>
<li id="groups"><a href='index.php?page=group_invite_history'>Group Invites</a> ([color=#FF0000]{GROUP_INVITES_QUANTITY}[/color])</li>
<li id="friends"><a href='index.php?page=frnds_request'>Friend Requests</a> ([color=#FF0000]{FRIEND_REQUESTS_QUANTITY}[/color])</li>
</ol>
</div>
</td>
</tr>
</td>
</tr>
</table>
</td>
</tr>
</table>
home.php
this was inside an "engines" folder if that helps
Code: Select all
<?php
require_once 'smartway/lib/base_classes.lib';
require_once 'smartway/lib/table.lib';
require_once 'smartway/objects/profile.php';
require_once 'smartway/objects/message.php';
class home extends _page
{
function home(){
$application =& application();
$this->set_name('home');
$this->_need_login = 'member';
$this->section ='Home';
$this->translations = array('home');
} // index
function default_action()
{
$application =& application();
$sql =& sql();
$sql->connect($application->config("db_host"), $application->config('db_login'),
$application->config('db_pswd'),$application->config('db_name'));
$member_id = $application->member->id;
$query = "SELECT username,firstname,profile_views,last_login FROM sn_members WHERE id=$member_id";
$value = $sql->query($query);
$result = $sql->fetch(MYSQL_ASSOC,$value);
if(strtolower($application->_config["search_engine_friendly_url"])=="on")
{
$application->output["profile_url"] = $application->config('root_host') . $result["username"];
}
else
{
$application->output["profile_url"] = $application->config('root_host') . 'index.php?' . $result["username"];
}
$replace =& replace();
$result['firstname'] = $replace->replace_badwords($result['firstname']);
$application->output['date'] = date::date_format(time(),LONG_DATE_TIME);//use the date function
$application->output['name'] = $result['firstname'];
$application->output['profile_view'] = $result['profile_views'];
if($result['last_login']==0)
{
$application->output['last_login'] = "Never";
}
else
{
$application->output['last_login'] = date::date_format($result['last_login'],LONG_DATE_TIME);//use the date function
}
$p = new profile($member_id);
$p->load_profile_photos();
$album_id = $p->get_album_id();
if(($photo_src = $p->get_profile_main_photo_tn()) == '')
{
$photo_src = "photos/&no_pic..gif";
}
else
{
$photo_src = "photos/general/$photo_src";
}
$application->output['image'] = $photo_src;
$application->output['id'] = $member_id;
$application->output['album_id'] = $album_id;
$this->get_mailbox_info();
parent::default_action();
}
function get_mailbox_info()
{
$application =& application();
$mailbox = new mailbox($application->member->id,1);
$application->output = array_merge($application->output,$mailbox->get_output_inbox_quantities());
}
}
?>