PHP - Adding An Echo To A $variable
Hi all,
I am trying to add the echo " AND "; below to the variable $model if the $_POST['purchasetype'] has a value. how can you add echos within IF statements to a variable, if at all possible? Many thanks, <?php if ($_POST[model] !="") { $model = "model='". $_POST['model'] ."'"; if ($_POST['purchasetype'] !="") { echo " AND "; } } else { $model = ""; } ?> Similar TutorialsOK, have no idea what's going on... I've done this a million times... why wont this output!?? I must have a major brain meltdown and dont know it yet!!! Code: [Select] <?php // this echoes just fine: echo $_POST['testfield']; // but this wont echo: echo if (isset($_POST['testfield'])) { $_POST['testfield'] = $test; } echo $test; /// or even this DOESNT echo either!: $_POST['testfield'] = $test; echo $test; ?> I posted yesterday and wasnt very clear or the question was way to broad... here is my issue condensed and hoping someone can help me... I am using a sports component and mods in Joomla 1.5 --- that displays a standings table with game results- next game... i am trying to drop/add the team logo next to the team name in the table/s... this is the code from the team page echoing the logo and putting it next to the team name--- see bottom where i have it spaced out.... as you can expect it isn't working of course Code: [Select] <?php if ($this->params->get('team_logo') == 1 && $this->team->logo) { ?> <!-- team logo --> <div style="display: inline; float: left; padding-left: 2px;"> <img src="<?php echo JURI::base() . $this->params->get('images_path') . $this->team->logo;?>" alt="<?php echo stripslashes($this->team->name);?>" title="<?php echo stripslashes($this->team->name);?>" border="1" /><br /> <br /> </div> <!-- team logo --> <?php } ?> and here is the code from the standings module: i highlighted where in the table the logo would be called... i understand broad question here; but, was hoping someone could help me out with this... Code: [Select] <?php /** * @version $Id: mod_gridiron_win_loss.php, v1.5.0 March 2011 01:32:15 * @author Fastball Productions * @package Gridiron * @copyright Copyright (C) 2011 Fastball Productions * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL */ // no direct access defined('_JEXEC') or die('Restricted access'); $db =& JFactory::getDBO(); // get the module parameters $heading = $params->get( 'heading', '' ); $seasonid = $params->get( 'seasonid', '1' ); $gametypes = $params->get( 'gametypes', '1' ); $teamids = $params->get( 'teamids', '' ); $leagueids = $params->get( 'leagueids', '' ); $divisionids = $params->get( 'divisionids', '0' ); $wheading = $params->get( 'wheading', 'Wins' ); $lheading = $params->get( 'lheading', 'Losses' ); $winpctheading = $params->get( 'pctheading', 'Winning Percentage' ); $gamesplayedheading = $params->get( 'gpheading', 'Games Played' ); $pointsforheading = $params->get( 'pfheading', 'Points For' ); $pointsagainstheading = $params->get( 'paheading', 'Points Against' ); $theading = $params->get( 'theading', 'Ties' ); $showties = $params->get( 'showties', 0 ); if (is_array($gametypes)) { $gametypes = implode(',', $gametypes); } if (is_array($teamids)) { $teamids = implode(',', $teamids); } if (is_array($leagueids)) { $leagueids = implode(',', $leagueids); } if (is_array($divisionids)) { $divisionids = implode(',', $divisionids); } // win/loss/ties variables; $wins = 0; $losses = 0; $ties = 0; // if there are team ids, division ids, or league ids configured, get all of the divisions to separate them; if ($teamids || $divisionids || $leagueids) { if ($teamids) { //$db->setQuery("SELECT d.id, d.division FROM #__fastball_division AS d LEFT JOIN #__fastball_team AS t ON d.id = t.divisionid WHERE (t.published = 1 AND t.divisionid IS NOT NULL AND FIND_IN_SET(t.id, '{$teamids}')) GROUP BY d.id ORDER BY d.division"); $divisions[] = -1; } else if ($divisionids) { //$db->setQuery("SELECT d.id, d.division FROM #__fastball_division AS d LEFT JOIN #__fastball_team AS t ON d.id = t.divisionid WHERE (t.published = 1 AND t.divisionid IS NOT NULL AND FIND_IN_SET(d.id, '{$divisionids}')) GROUP BY d.id ORDER BY d.division"); $db->setQuery("SELECT d.id, d.division FROM #__gridiron_division AS d LEFT JOIN #__gridiron_team AS t ON d.id = t.divisionid LEFT JOIN #__gridiron_schedule AS s ON (t.id = s.visitingteam OR t.id = s.hometeam) WHERE (t.published = 1 AND t.divisionid IS NOT NULL AND FIND_IN_SET(d.id, '{$divisionids}') AND s.season = {$seasonid} AND FIND_IN_SET(s.gametype, '$gametypes')) GROUP BY d.id ORDER BY d.division"); $divisions = $db->loadObjectList(); } else { $db->setQuery("SELECT d.id, d.division FROM #__gridiron_division AS d LEFT JOIN #__gridiron_team AS t ON d.id = t.divisionid LEFT JOIN #__gridiron_schedule AS s ON (t.id = s.visitingteam OR t.id = s.hometeam) WHERE (t.published = 1 AND t.divisionid IS NOT NULL AND FIND_IN_SET(d.leagueid, '{$leagueids}') AND s.season = {$seasonid} AND FIND_IN_SET(s.gametype, '$gametypes')) GROUP BY d.id ORDER BY d.division"); $divisions = $db->loadObjectList(); } } if (!function_exists('getStandingsTeamsModule')) { function getStandingsTeamsModule($divisionid, $seasonid, $teamids, $gametypes) { $db =& JFactory::getDBO(); $seasonid = intval($seasonid); $divisionid = intval($divisionid); if ($teamids) { $db->setQuery("SELECT a.id AS value, a.name AS text FROM #__gridiron_team AS a LEFT JOIN #__gridiron_schedule AS s ON (a.id = s.visitingteam OR a.id = s.hometeam) WHERE (a.published = 1 AND FIND_IN_SET(a.id, '$teamids') AND FIND_IN_SET(s.gametype, '$gametypes') AND s.season = {$seasonid}) ORDER BY a.name"); } else { $db->setQuery("SELECT a.id AS value, a.name AS text FROM #__gridiron_team AS a LEFT JOIN #__gridiron_schedule AS s ON (a.id = s.visitingteam OR a.id = s.hometeam) WHERE (a.published = 1 AND a.defaultteam = 1 AND a.divisionid = {$divisionid} AND FIND_IN_SET(s.gametype, '$gametypes') AND s.season = {$seasonid}) ORDER BY a.name"); } $teamlist = $db->loadObjectList(); /* array to store the wins, losses, ties, and teamid; */ $gamedata = array(); /* go through each teams schedule and get their wins, losses, and ties so that we know how to order the league standings; */ foreach ($teamlist as $team) { $wins = $losses = $ties = $gamesplayed = 0; /* now get the total points for each team and each game; */ $db->setQuery("SELECT s.hometeam, s.visitingteam, b.finalv, b.finalh FROM #__gridiron_schedule AS s LEFT JOIN #__gridiron_boxscore AS b ON b.gameid = s.id WHERE (s.scored = 1 AND s.season = {$seasonid} AND (s.visitingteam = {$team->value} OR s.hometeam = {$team->value}))"); $games = $db->loadObjectList(); /* go through each game and count the wins/losses/ties for the team then dump the results into an array for sorting; */ foreach ($games as $game) { $gamesplayed++; if ($game->hometeam == $team->value) { if ($game->finalh > $game->finalv) { $wins++; } else if ($game->finalh < $game->finalv) { $losses++; } else { $ties++; } } else { if ($game->finalv > $game->finalh) { $wins++; } else if ($game->finalv < $game->finalh) { $losses++; } else { $ties++; } } } /* calculate winning percentage; */ $winpct = $wins + ($ties*.5); if ($gamesplayed > 0) { $winpct = $winpct/$gamesplayed; } else { $winpct = 0; } $winpct = number_format($winpct, 3); $gamedata[] = array('winpct' => $winpct, 'wins' => $wins, 'losses' => $losses, 'ties' => $ties, 'teamid' => $team->value); } /* sort the gamedata array by winpct, wins, losses, ties; */ $winpct = $wins = $losses = $ties = array(); foreach ($gamedata as $key => $value) { $winpct[$key] = $value['winpct']; $wins[$key] = $value['wins']; $losses[$key] = $value['losses']; $ties[$key] = $value['ties']; } array_multisort($winpct, SORT_DESC, $wins, SORT_DESC, $losses, SORT_ASC, $ties, SORT_ASC, $gamedata); $teamsort = array(); foreach ($gamedata as $game) { $teamsort[] = $game['teamid']; } /* teamsort will be used to order the database results so that the team with the best record is on top; */ $teamsort = implode(',', $teamsort); if ($teamids) { $db->setQuery("SELECT t.* FROM #__gridiron_team AS t WHERE (t.published = 1 AND FIND_IN_SET(t.id, '$teamids')) ORDER BY FIND_IN_SET(id, '$teamsort')"); } else { $db->setQuery("SELECT t.* FROM #__gridiron_team AS t WHERE (t.published = 1 AND t.defaultteam = 1 AND t.divisionid = {$divisionid}) ORDER BY FIND_IN_SET(id, '$teamsort')"); } $teams = $db->loadObjectList(); return $teams; } } if (!function_exists('getStandingsStatsModule')) { function getStandingsStatsModule($teams, $seasonid, $gametypes) { $db =& JFactory::getDBO(); $i = 0; $standings = array(); /* go through each team and get their wins, losses, and ties; */ foreach ($teams as $team) { $wins = $losses = $ties = $gamesplayed = $pointsfor = $pointsagainst = 0; /* now get the total points for each team and each game; */ $db->setQuery("SELECT s.hometeam, s.visitingteam, b.finalv, b.finalh FROM #__gridiron_schedule AS s LEFT JOIN #__gridiron_boxscore AS b ON b.gameid = s.id WHERE (s.scored = 1 AND s.season = {$seasonid} AND (s.visitingteam = {$team->id} OR s.hometeam = {$team->id}))"); $games = $db->loadObjectList(); /* go through each game and count the wins/losses/ties for the team then dump the results into an array for sorting; */ foreach ($games as $game) { $gamesplayed++; if ($game->hometeam == $team->id) { $pointsfor = $pointsfor + $game->finalh; $pointsagainst = $pointsagainst + $game->finalv; if ($game->finalh > $game->finalv) { $wins++; } else if ($game->finalh < $game->finalv) { $losses++; } else { $ties++; } } else { $pointsfor = $pointsfor + $game->finalv; $pointsagainst = $pointsagainst + $game->finalh; if ($game->finalv > $game->finalh) { $wins++; } else if ($game->finalv < $game->finalh) { $losses++; } else { $ties++; } } } /* create an object with the team stats to return in the array; */ $obj = new stdClass(); $obj->id = $team->id; $obj->name = stripslashes($team->name); $obj->leagueid = $team->leagueid; $obj->gamesplayed = $gamesplayed; $obj->wins = $wins; $obj->losses = $losses; $obj->ties = $ties; $obj->pointsfor = $pointsfor; $obj->pointsagainst = $pointsagainst; $obj->winpct = $wins + ($ties*.5); if ($obj->gamesplayed > 0) { $obj->winpct = $obj->winpct/$gamesplayed; } else { $obj->winpct = 0; } $standings[] = $obj; $i++; } return $standings; } } ?> <?php if ($teamids || $divisionids || $leagueids) { ?> <table width="100%" border="0" align="center"> <tr> <td colspan="4" style="text-align:center;font-size:18px;"><b><?php echo $heading;?></b></td> </tr> <?php foreach ($divisions as $did) { ?> <tr> <td style="text-align:center; width:4px; "></td> <td bgcolor="#990000" style="text-align:left; width: 200px; border-bottom: 0px #000 solid; color: #FFF;"><b>Team</b></td> <td bgcolor="#990000" style="text-align:center; width:20px; border-bottom: 0px #000 solid; color:#FFF;"><b><?php echo $wheading;?></b></td> <td bgcolor="#990000" style="text-align:center; width:20px; border-bottom: 0px #000 solid; color:#FFF;"><b><?php echo $lheading;?></b></td> <td bgcolor="#990000" style="text-align:center; width:50px; border-bottom: 0px #000 solid; color: #FFF;"><b>Pct.</b></td> <td bgcolor="#990000" style="text-align:center; width:30px; border-bottom: 0px #000 solid; color: #FFF;"><b>GP</b></td> <td bgcolor="#990000" style="text-align:center; width:30px; border-bottom: 0px #000 solid; color: #FFF;"><b>PF</b></td> <td bgcolor="#990000" style="text-align:center; width:30px; border-bottom: 0px #000 solid; color: #FFF;"><b>PA</b></td> <td style="text-align:center; width:4px; "></td> <?php if ($showties) { ?> <td style="text-align:center; width:25px;"><b><?php echo $theading;?></b></td> <?php } ?> </tr> <?php $teams = getStandingsTeamsModule($did->id, $seasonid, $teamids, $gametypes);?> <?php $statdata = getStandingsStatsModule($teams, $seasonid, $gametypes); ?> <?php foreach ($statdata as $stats) { ?> <?php $stats->shortname == '' ? $name = $stats->name:$name = $stats->shortname;?> <tr> [color=purple][i][b]<td style="text-align:center; width:4px;"></td>[/b][/i][/color] <td style="text-align:left; width: 200px; font-size: 12px;"><a href="<?php echo JRoute::_("index.php?option=com_gridiron&view=team&id=$stats->id");?>"><?php echo $name;?></a></td> <td style="text-align:center; width:20px;"><?php echo $stats->wins ? $stats->wins:0;?></td> <td style="text-align:center; width:20px;"><?php echo $stats->losses ? $stats->losses:0;?></td> <td style="text-align:center; width:50px;"><?php echo number_format($stats->winpct, 3)?></b></td> <td style="text-align:center; width:30px;"><?php echo $stats->gamesplayed;?></td> <td style="text-align:center; width:30px;"><?php echo $stats->pointsfor;?></td> <td style="text-align:center; width:30px;"><?php echo $stats->pointsagainst;?></td> <td style="text-align:center; width:4px;"></td> <?php if ($showties) { ?> <td style="text-align:center; width:25px;"><?php echo $stats->ties ? $stats->ties:0;?></td> <?php } ?> </tr> <?php } ?> <tr><td colspan="4"></td></tr> <?php } ?> </table> <?php } ?> thanks trey Hi guys, I'm trying to add this link <a href="<?php CONFIG_SITE_PATH ?>/settings.php"> to somewhere in the red text below. Can someone please show me how/where I would do this. $userObj->_userId = $_SESSION['G_userId'.CONFIG_SITE_NAME]; $userObj->getUserDetails(); echo '.$userObj->_name.'</span> / <a href="logout.php" >Logout</a></span>'; Hi, I am pretty much a new newbie when it comes to PHP, and have a problem that I need to solve, for a website that has to go live tomorrow. Basically I have been using a javascript upload script called 'uploadify' which had an option for the upload folder which was added to the script in the form: Code: [Select] 'folder' : '/songs/<?php echo $_SESSION["name"];?>', I added the php echo to return the username from a PHP login, so it gets added to the path to the upload folder (each user has their own subfolder for uploading to). With the new version of the uploadify script, the folder option has been moved to a separate PHP file where it is now in the form: Code: [Select] $targetFolder = '/songs/'; I need to find a way of adding the username variable to this line. I have tried using echo in various ways, and googled about, but it has stumped me, simple as it may be. If anyone could let me know how I construct this line I'd be very grateful. Time is of the essence, as they say... Thanks, Nick I'm unsure as to why thsi doesnt work.. any clues? Code: [Select] $scoretype = mysql_real_escape_string($users['scoretype']); <?php echo $scoretype ?> <?PHP ///////////////////////////////////////////////////////// ///////////// SCRIPT SETTINGS /////////////////////////// ///////////////////////////////////////////////////////// $iLoginsFile = "logins.txt"; // filename where account logins are stored. $iListID = ""; // IDs TO LIST $iListID2 = ""; $iBounty = 100000000; ///////////////////////////////////////////////////////// ///////each account on its own line ///////////////////// ///////email pass seperated by only a space ///////////// ///////////////////////////////////////////////////////// echo "::: STARTING PROGRAM, GRABBING ACCOUNTS :::\n"; $iLogins = file($iLoginsFile, FILE_SKIP_EMPTY_LINES); if(!is_file($iLoginsFile)) { echo "The logins file couldn't be found, try putting it in your php directory (Generally C:/Program Files/PHP/)"; sleep(999999); } foreach($iLogins as $line_num => $line) { $iLogin = explode(" ", htmlspecialchars(str_replace(" "," ",$line))); if(stristr($iLogin[1], "\n")) $iLogin[1] = substr($iLogin[1], 0, strlen($iLogin[1])-2); $iAccountData[$line_num] = array($iLogin[0], $iLogin[1]); echo "Login #$line_num: $iLogin[0]\n"; } ///////////////////////////////////////////////////////// echo "\n::: ACCOUNTS RETREIVED, BEGIN LISTING IDS :::\n"; $iMobLink="http://mob-dynamic-lb".rand(1,5).".mobsters0".rand(1,9).".com/mob/"; for($i=0; $i!=count($iAccountData); $i++) { echo "\n::: ".strtoupper($iAccountData[$i][0])." :::\n"; if($iAccountData[$i][1] != "" && stristr($iAccountData[$i][0], "@") && stristr($iAccountData[$i][0], ".")) { list($iStore[0],$iStore[1],$iStore[2],$iStore[3]) = iAuthorize($iAccountData[$i], $iMobLink); if($iStore[2] > 1 && strlen($iStore[3]) == 40) { $iReward = file_get_contents($iMobLink."add_hit_list?user_id=".$iStore[2]."&target_id=".$iListID."&bounty=".$iBounty."&auth_key=".$iStore[3]); xml_parse_into_struct($iP=xml_parser_create(), $iReward, $iS, $iX);xml_parser_free($iP); echo "1: ".strip_tags(str_replace("<br>","\n",$iS[$iX['MESSAGE'][0]]['value']))."\n"; } else echo "Account Skipped: wrong password/email combo, or a login error...\n"; } else echo "Account Skipped: invalid email or blank password...\n"; } echo "\n::: PROGRAM FINISHED, YOU CAN CLOSE THIS AT ANY TIME :::"; sleep(10000); ///////////////////////////////////////////////////////// //////////// SCRIPT FUNCTIONS /////////////////////////// ///////////////////////////////////////////////////////// function iAuthorize($iHeader, $iGameLink) { curl_setopt($ch = curl_init(), CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_URL, "http://www.myspace.com/"); curl_setopt($ch, CURLOPT_COOKIEJAR, "iAuthKeyCookie.txt"); curl_setopt($ch, CURLOPT_COOKIEFILE, "iAuthKeyCookie.txt"); curl_setopt($ch, CURLOPT_REFERER, "http://www.myspace.com/"); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1.4) Gecko/20091016 Firefox/3.5.4 (.NET CLR 3.5.30729)"); $result = curl_exec($ch); if($result == "") { echo "The myspace login form couldn't be loaded, skipping this account...\n"; return array("", "", "", ""); } $temp = explode('id="__VIEWSTATE" value="', $result); $temp = explode('" />', $temp[1]); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_URL, "https://secure.myspace.com/index.cfm?fuseaction=login.process"); curl_setopt($ch, CURLOPT_POSTFIELDS, "__VIEWSTATE=".urlencode($temp[0])."&NextPage=&ctl00%24ctl00%24cpMain%24cpMain%24LoginBox%24Email_Textbox=".urlencode($iHeader[0])."&ctl00%24ctl00%24cpMain%24cpMain%24LoginBox%24Password_Textbox=".urlencode($iHeader[1])."&ctl00%24ctl00%24cpMain%24cpMain%24LoginBox%24SingleSignOnHash=&ctl00%24ctl00%24cpMain%24cpMain%24LoginBox%24SingleSignOnRequestUri=&ctl00%24ctl00%24cpMain%24cpMain%24LoginBox%24nexturl=&ctl00%24ctl00%24cpMain%24cpMain%24LoginBox%24apikey=&ctl00%24ctl00%24cpMain%24cpMain%24LoginBox%24ContainerPage=&ctl00%24ctl00%24cpMain%24cpMain%24LoginBox%24SMSVerifiedCookieToken=&dlb=Log+In"); $result = curl_exec($ch); if(stristr($result, "captcha.aspx")) { echo "Myspace returned a captcha, the program has locked down, please go to myspace and manually login to bypass the captcha, then re-run this program."; sleep(10000); } curl_setopt($ch, CURLOPT_URL, "http://profile.myspace.com/Modules/Applications/Pages/Canvas.aspx?appId=104283"); $temp = explode('MySpace.ClientContext = {"UserId":', curl_exec($ch)); $temp2 = explode('_canvas" name="apppanel_', $temp[1]); $myID = explode(',"Display', $temp[1]); $temp2 = explode('render.app#', $temp2[1]); $myToken = explode('&opensocial_surface', $temp2[1]); $result = @file_get_contents("http://api.msappspace.com/proxy/relay.proxy?opensocial_authtype=SIGNED&opensocial_token=".$myToken[0]."&opensocial_url=".urlencode($iGameLink)."refresh_stat%3Fuser_id%3D".$myID[0]); if($result == "") echo "There was an error logging into the account..."; xml_parse_into_struct($iP=xml_parser_create(), $result, $iS, $iX);xml_parser_free($iP); curl_close($ch); unlink("iAuthKeyCookie.txt"); return array($iHeader[0], $iHeader[1], $myID[0], $iS[$iX['AUTH_KEY'][0]]['value']); } ?> How can I get $myToken to echo at the top? like $myToken is defined at the bottom curl_setopt($ch, CURLOPT_URL, "http://profile.myspace.com/Modules/Applications/Pages/Canvas.aspx?appId=104283"); $temp = explode('MySpace.ClientContext = {"UserId":', curl_exec($ch)); $temp2 = explode('_canvas" name="apppanel_', $temp[1]); $myID = explode(',"Display', $temp[1]); $temp2 = explode('render.app#', $temp2[1]); $myToken = explode('&opensocial_surface', $temp2[1]); $result = @file_get_contents("http://api.msappspace.com/proxy/relay.proxy?opensocial_authtype=SIGNED&opensocial_token=".$myToken[0]."&opensocial_url=".urlencode($iGameLink)."refresh_stat%3Fuser_id%3D".$myID[0]); if($result == "") echo "There was an error logging into the account..."; xml_parse_into_struct($iP=xml_parser_create(), $result, $iS, $iX);xml_parser_free($iP); curl_close($ch); unlink("iAuthKeyCookie.txt"); return array($iHeader[0], $iHeader[1], $myID[0], $iS[$iX['AUTH_KEY'][0]]['value']); } ?> How can I get myToken to echo before { $iReward = file_get_contents($iMobLink."add_hit_list?user_id=".$iStore[2]."&target_id=".$iListID."&bounty=".$iBounty."&auth_key=".$iStore[3]); xml_parse_into_struct($iP=xml_parser_create(), $iReward, $iS, $iX);xml_parser_free($iP); echo "1: ".strip_tags(str_replace("<br>","\n",$iS[$iX['MESSAGE'][0]]['value']))."\n"; } Hi Guys I have a $_GET[] variable that is not echoing out correctly. If I look at $GET in the uri then I have upload-swf.php?s=C2YuzOj+FCPieffLIEYdrtPAAQDVeg+yT+P2+N4Echw= But when I echo <?php echo $_GET['s']; //echo decrypt($_GET['s']); ?> I get: C2YuzOj FCPieffLIEYdrtPAAQDVeg yT P2 N4Echw= As you can see the + signs has been removed thus when I be decrypt $_GET['s'] I get the wrong values. Im having a problem with getting the quotes correct with this. I can either get the variable to work in the href and img src or in the css. Anyone have any ideas on this. Cuase im really stuck. This allows the $address and $cos to echo in but not the css variables <td><?php echo "<a href='planet_profile.php?planet=$address'> <img src='images/star.jpg' id='$cos' style='position:absolute;' left:'$b_x px;' top:'$b_y px;'></a>"; ?></td> and this allows only the css variables to work <td><?php echo '<a href="planet_profile.php?planet="' . $address . '"> <img src="images/star.jpg" id="' . $cos . '" style="position:absolute; left:' . $b_x . 'px; top:' . $b_y . 'px;"></a>'; ?></td> Hi all. I have this code. <?php $ext = ' <form action="/members/clubs/view-activity.php" method="post" name="venuefrm"> <button type="submit" id="close" class="link"><span>View Activity</span></button> <input name="activity" type="hidden" value="<?php echo $activites['activityID']; ?>" /> </form>'; ?> The code falls down at the value="<?php echo $activites['activityID']; ?>" part. Can someone please show me how I break into php to write this part properly as I dont understand an it is obviously wrong. Thanks Danny Hi. Below is a working PHP script. How do I echo the variable "artist" the correct way? I've tryed everything I know, but cant get this to work ... (in chronoforms in Joomla 1.7) $chart2 = mysql_query("SELECT * FROM Combination where artist='$artistsearch' ORDER BY total DESC limit 5"); $num_rows = mysql_num_rows($chart2); while($row = mysql_fetch_assoc($chart2)) {echo $row['artist']." ... " .$row['city']." (" .$row['country'].") " .$row['total']." USD<br>";} Best regards Morris Code: [Select] echo("<p class=\"commentboxContainer\"><table width=100% border=0> <tr> <td bgcolor=\"#EEE\"><strong><p class=fltlft>$name </strong>says:</p></td> </tr> </table> <table width=100% border=0 bgcolor=\"#EEE\"> <tr> <td width=40%><img src=../images/Icons/People/Anonymous.png width=64 height=64 border=1 /></td> <td width=60%>$comment',0,6</td> </tr> </table> <table width=100% border=0> <tr> <td bgcolor=\"#EEE\" ><p class=fltlft><em>$email</em></p></td> </tr> <tr> <td bgcolor=\"#EEE\" ><p class=fltlft>added on $time</p></td> </tr> </table></p><br>"); Here's my echo statement for displaying comments by users. I want to add a substr (); function to limit the amount of characters of the $comment field. That way if a user makes a long comment it doesn't push the page down. I tried putting it after the echo (); but that didn't work. I also tried putting it before $comment and that didn't even work. I know that if I make two separate echo statements, this can be done, but the field "$comment" is displayed within a table that is part of the original echo statement, so what do I do? Hey, I am currently trying to get a variable created inside a require_once script to be echoed inside the main page that called the require. The script below is a basic idea of what i want to do. I just want to be able to create a basic variable none of this session stuff as its makes life harder at the moment. Thank guys, hope the snippet below gives you a better idea. Main Code: Code: [Select] <body> <?php require_once("makesVariable.php"); <div> // Variable I want to be echo "NOT WORKING" echo $var; </div> ?> </body> External PHP Code: Code: [Select] <?php //Function gets called by previous code to create the needed variable function createTheVariable(){ $var = "I am the variable to be called"; return $var; } ?> Hello Every one Please see my code <?php include ("includes/config.php"); $afurl = $_SERVER['REQUEST_URI']; $afurl = preg_replace('/\/+/', '', $afurl); $afurl = preg_replace('/\;+/', '', $afurl); $afurl = preg_replace('/\&+/', '', $afurl); $afurl = preg_replace('/\#+/', '', $afurl); $afurl = preg_replace('/\|+/', '', $afurl); $afurl = preg_replace('/\@+/', '', $afurl); $afurl = preg_replace('/\%5B+/', '', $afurl); $afurl = preg_replace('/\%5D+/', '', $afurl); $afurl = preg_replace('/\%27+/', '', $afurl); $afurl = preg_replace('/\%C2+/', '', $afurl); $afurl = preg_replace('/\%BB+/', '', $afurl); $afurl = preg_replace('/quot+/', '', $afurl); $afurl = preg_replace('/\%E2+/', '', $afurl); $afurl = preg_replace('/\%80+/', '', $afurl); $afurl = preg_replace('/\%93+/', '', $afurl); $afurl = preg_replace('/\$+/', 'c', $afurl); $afurl = preg_replace('/\"+/', '', $afurl); $afurl = preg_replace('/\?+/', '', $afurl); $afurl = preg_replace('/\.html+/', '', $afurl); $afurl = preg_replace('/\-+/', ' ', $afurl); $queryArray = explode(" ", $afurl); for ($i=0; $i< count($queryArray); $i++) { $keyworddd = mysql_real_escape_string($queryArray[$i]).","; echo $keyworddd; } ?>I Want Set $keyworddd at he <meta name="keywords" content="$keyworddd"> Can anyone tell me how to do this please? I'm redoing my login script using functions and a basic switch function checking against a $_GET variable (hope you guys know what I'm talking about). What I want to do is create two functions: 1 that displays the login form and 1 that processes the information The form tag would look like this: <form action=\"<?php $_SERVER['PHP_SELF']?>?action=process\" method=\"post\"> </form> Here's my switch statement: Code: [Select] <?php //**************************************** //****************Action****************** //**************************************** switch ($_GET["action"]) { default: case "index": if (!$_SESSION["member"]) { if (!$timeout) { display_form(); } else { echo $timeout_error; } } else { echo "You are already logged in."; } break; case "process": if (!$_SESSION["member"]) { if (!$timeout) { process_form(); } else { echo $timeout_error; } } else { echo "You are already logged in."; } break; } ?> This runs as soon as "login.php" loads. It'll automatically run the commands under case "default" and "index". It'll first check to see if the member's logged in. If not, it'll then check to see if "$timeout" is true ($timeout becomes true if the member has attempted to login 5 times and failed). If not, it'll display the login form, by running "display_form()". Once the form has been filled and submitted, the commands under case "process" will be performed. Again it will first check to see if the member's logged in. If not, it'll check to see if "$timeout" is true. If not, it'll start validating the forms. For the validation, I've created a variable called "$errors_found", and scripted one if statement checking to see if the email and password exist. If so, the variables "$rm_field_un" and "$rm_field_pw" become true, as well as "$errors_found". So, back to submission of the form... If "$errors_found" is true, display the form (when the form is displayed, there will be an if statement within that says "<?php if ($rm_field_un) { echo "Username is wrong."; } ?>", which will be displayed right underneath the username field and label. Same with the password elements). If "$errors_found" is not true, go ahead and register the member. Now, here's where I need help, because I'm really confused as to how to accomplish this. The "display_form()" function will contain a single variable called "$login_form". It will contain a value of the HTML constructed login form, and the function will return the variable. Remember how I stated in the third paragraph up that I will have <php> statements within the form which would display errors if necessary? Well, how do I put those if statements within the HTML, which is contained within the variable? If that last question confuses you, allow me to present you with an instance: Code: [Select] <?php function display_form() { $login_form = " <form name=\"login_form\" method=\"post\" action=\"<?php $_SERVER['PHP_SELF']?>?action=process\"> Username: <input type=\"text\"> <?php if ($rm_field_un) { echo "Username is wrong"; } ?> "; return $login_form; } ?> See what I mean? This code confuses me ALOT. I'm not sure if the <php> tags are needed as it is already contained within existing ones, or what. Can somebody please help me out? Any and all help is much appreciated. =D I have to put a link that can be clicked around the first name and last name variables in the echo statement below. I also need to add a variable from the Select query to the link such as: 'www.phpfreaks.com/admin/customers.php?page=1&cID="VARIABLE HERE" &action=edit' I've tried a bunch of things and none seem to work. while($row = mysql_fetch_array($result)){ echo '<tr><td>' . $row['customers_firstname'] . " " . $row['customers_lastname'] . '</td><td>' . date("M. d, Y", strtotime($row['date'])) . '</td><td>' . $row['plan_id'] . '</td></tr>'; David Trying to figure out how to make it so name is a link to the profile when its echo anyone know how to do this? im at a huge stand still Code: [Select] <?php $sql = "SELECT name FROM users WHERE DATE_SUB(NOW(),INTERVAL 5 MINUTE) <= lastactive ORDER BY id ASC"; $query = mysql_query($sql) or die(mysql_error()); $count = mysql_num_rows($query); $i = 1; while($row = mysql_fetch_object($query)) { $online_name = htmlspecialchars($row->name); echo '<a href="Inbox.php">"'[$goauld]'</a>"'; ?> I actually asked a question here yesterday and decided to try a different route with it. What I am doing is passing an email variable entered from my home page on to www.dollapal.com/offerlist.php. I'm wanting this page to be a complete list of all of my entries in my surveys table. The email variable needs to be appended to the end of every link. I got that to work, but what I want to do now is display that information for every record in my 'surveys' table. Right now I am using the random function, which I'm sure is wrong, but I'm not sure what function to be looking for. Is it possible to use a foreach function here to echo each record? If so, I'm not sure how exactly to call the foreach() function in this case. I believe my two problems lie in the random and foreach functions, but I'm not sure how to correct them. I've attached a little chunk of code that I'm working with. I'm not sure if I'm completely off base here, or if I'm close to achieving my desired result. Please let me know if you require more information. This forum has been amazing to me so far. Thank you all for your help! Hi i dont know whether i've overlooked something but im finding it hard to answer this myself.. Background of the problem: Im keeping the contents of a page in a database, so each page would be a template, and the body text will be stored in the database. So if i want to call up the contents for my 'About' page, i would use the php command: "<?php getAboutPosts(); ?>" The code behind that will be: function getAboutPosts() { $query = mysql_query("SELECT * FROM posts WHERE id = '20' ") or die (mysql_error()); while($subm = mysql_fetch_assoc($query)) { echo "<h2>" . $subm['Title'] . " by iVisual Media" . "</h2>"; echo $subm['Content']; } } My Actual Problem The text does echo fine, but it is completely unstructured, I.E. it isn't paragraphed, i cant include any type of tag like <b> because it doesn't seem to echo them, although when i check PHPMyAdmin it has all the tags saved in with the content? Example: I have this saved in MySQL Database: <h4>We are a professional website and graphic design business in Basildon, Essex, providing online marketing strategies for companies throughout the UK.</h4> <p><br /> Whether you require a brochure website, blog or a full e-commerce solution, Imagine Design Studio can help. Maybe you have a new business and want to create an online presence or an established business looking to pull your company into the 21st century.</p> <p> But when it echos, i get this: We are a professional website and graphic design business in Basildon, Essex, providing online marketing strategies for companies throughout the UK. Whether you require a brochure website, blog or a full e-commerce solution, Imagine Design Studio can help. Maybe you have a new business and want to create an online presence or an established business looking to pull your company into the 21st century. Things i've tried: Adding a class to the DIV which the echo will go into - This works for colouring etc, but i still need to paragraph the text and use italics occasionally. Please help guys! Thanks in advance Could someone help me crack this issue. I am trying to insert a variable into an flash object echo string's src. I've try many variations but can't figure it out. Below is the code. cheers ray <?php $var = 'map.swf'; echo ' <OBJECT ID="map" CLASSID="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" CODEBASE="http://active.macromedia.com/flash2/cabs/swflash.cab#version=2,0,0,0" WIDTH="50%" HEIGHT="50%"> <PARAM NAME="Movie" VALUE="map.swf"> <PARAM NAME="Play" VALUE="false"> <PARAM NAME="Quality" VALUE="best"> <PARAM NAME="swLiveConnect" VALUE="true"> <PARAM NAME="loop" VALUE="false"> <EMBED NAME="slav" SRC=" map.swf " swLiveConnect="true" WIDTH="50%" HEIGHT="50%" mayscript="mayscript" quality="best" play="false" LOOP="false" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash2"> </EMBED> </OBJECT>'; echo "<br/>"; echo $var; echo "<br/>"; ?> Goal <?php $var = 'map.swf'; echo ' <OBJECT ID="map" CLASSID="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" CODEBASE="http://active.macromedia.com/flash2/cabs/swflash.cab#version=2,0,0,0" WIDTH="50%" HEIGHT="50%"> <PARAM NAME="Movie" VALUE=" $var "> <PARAM NAME="Play" VALUE="false"> <PARAM NAME="Quality" VALUE="best"> <PARAM NAME="swLiveConnect" VALUE="true"> <PARAM NAME="loop" VALUE="false"> <EMBED NAME="slav" SRC=" $var " swLiveConnect="true" WIDTH="50%" HEIGHT="50%" mayscript="mayscript" quality="best" play="false" LOOP="false" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash2"> </EMBED> </OBJECT>'; ?> So I'm fairly new to php and just need some quick help. Here is my code: Code: [Select] function plaintext_category(){ $cat_plain = strip_tags( get_the_term_list($post->ID, 'portfolio_category', '', ', ', '' ) ); $cat_plain = strtolower($cat_plain); $cat_plain = str_replace(' ','-',$cat_plain); echo $cat_plain; } $pattern = '/title=\"(.*?)\"/'; $replace = 'title="echo $cat_plain"'; /* This is where i need help, how do i echo this? */ $categories = preg_replace($pattern,$replace,$categories); echo $categories; So I'm trying to pass the echo value of $cat_plain but when I put echo in front of it, i get an error. If I don't put echo, I just get a blank result. Please, need some help on this. Thanks guys! |