Jump to content

Recommended Posts

Hi ..

 

i have a question

how do i set a var so it displays via an echo

$logo = '<img src="Images/tvguide/sabc1.jpg">';
echo '<div class="hd2"><center><font color=#666666><strong>' .$logo. '</strong></font></center></div><br>';

i tried that but it dont work

 

Try putting the code in without all the formatting. Then you'll no whether its the formatting thats annoying it.

 

Do this:

$logo = '<img src="Images/tvguide/sabc1.jpg">';
echo $logo;

 

Link to comment
https://forums.phpfreaks.com/topic/183164-quick-question/#findComment-966847
Share on other sites

i am sorry for my question let me paste the whole code and u can tell me why it wont display

<?php


$ShowBookmark = "False";
include 'Include/Header.php';

if($_GET['channel'] == True) {          
           GetGuide();
       }else {
             Show_Form();     	
} 

function Show_Form() {
      $thedate = date('l dS F Y');
      echo '<div class="hd2"><font color=#666666><strong><center>Tv Guide</center></strong></font></div><br>';
      echo '<center><font face="Verdana" size="2" color="#3366ff"><u>' .$thedate. '</center></u></font>';
      echo '<table id="" border="0" style="font-size:9pt;width:100%;">';
      echo '<tr style="font-color:#85859c;"><td style="width:10px;"><img src="Images/tvguide/sabc1-icon.gif"></td><td>';
      echo '<font face="Verdana" size="2"><b><a href="TvGuide.php?channel=sabc1">Sabc 1</b></font></a><br>';
      echo '</td></tr>';
      echo '<tr style="font-color:#85859c;"><td style="width:10px;"><img src="Images/tvguide/sabc2-icon.gif"></td><td>';
      echo '<font face="Verdana" size="2"><b><a href="TvGuide.php?channel=sabc2">Sabc 2</b></font></a><br>';		
      echo '</td></tr>';
      echo '<tr style="font-color:#85859c;"><td style="width:10px;"><img src="Images/tvguide/sabc3-icon.gif"></td><td>';
      echo '<font face="Verdana" size="2"><b><a href="TvGuide.php?channel=sabc3">Sabc 3</b></font></a><br>';
      echo '</td></tr>';
      echo '<tr style="font-color:#85859c;"><td style="width:10px;"><img src="Images/tvguide/etv-icon.jpg"></td><td>';
      echo '<font face="Verdana" size="2"><b><a href="TvGuide.php?channel=ETV">Etv</b></font></a><br>';		
      echo '</td></tr>';
      echo '<tr style="font-color:#85859c;"><td style="width:10px;"><img src="Images/tvguide/mnet-icon.jpg"></td><td>';
      echo '<font face="Verdana" size="2"><b><a href="TvGuide.php?channel=Mnet">Mnet</b></font></a><br><br>';			
      echo '</td></tr>';
      echo '</table>';
      echo '<center><font face="Verdana" size="2">' .$GLOBALS["Advert03"]. '</font></center>';
      echo '<table id="" border="0" style="font-size:9pt;width:100%;">';
      echo '<tr style="font-color:#85859c;"><td style="width:10px;"><img src="Images/Logos/Logo_Back.gif"></td><td>';
      echo '<font face="Verdana" size="2"><b><a href="index.php">Back</b></font></a><br>';
      echo '</td></tr>';
      echo '</table>';
      echo '<hr>';

      include 'Include/Footer.php';
      Show_Buttons("True", "index.php?Cmd=100","True");
}
  

function GetGuide() { 
$url = "http://mysite.com";
$RawData = @file_get_contents($url) or die('Could not access file: $url');
$Table = ExData($RawData,'<div style="font-size:12px; padding-top:15px; padding-left:9px">',"</div>");
        if($_GET['channel'] == "Mnet"){ 
        $getMyDataFrom = $Table[1]; 
} 
if($_GET['channel'] == "sabc1"){ 
       $getMyDataFrom = $Table[2];
$logo = '<img src="Images/tvguide/sabc1.jpg">';
}
       if($_GET['channel'] == "sabc2"){ 
       $getMyDataFrom = $Table[3];
} 
      if($_GET['channel'] == "sabc3"){ 
      $getMyDataFrom = $Table[4];
}
      if($_GET['channel'] == "ETV"){ 
      $getMyDataFrom = $Table[5];
}
      $FGuide = $getMyDataFrom;

$i=2; 
$upper = 60;

while ($i <= $upper) {
    $FGuide = str_replace($i, '<font face="Verdana" color="red" size="2">' . $i . '</font>', $FGuide);
    $i++;
}
    $FGuide = str_replace('0', '<font face="Verdana" color="red" size="2">0</font>', $FGuide);
    $FGuide = str_replace(1, '<font face="Verdana" color="red" size="2">1</font>', $FGuide);
    $FGuide = str_replace(':', '<font face="Verdana" color="green" size="2">:</font>', $FGuide);
    $FGuide = str_replace('(R)', '<font face="Verdana" color="#660099" size="2">(R)</font>', $FGuide);
    $FGuide = str_replace('(English)', '<font face="Verdana" color="#00cc00" size="2">(English)</font>', $FGuide);

return $FGuide;	
}

function ExData($text, $openingMarker, $closingMarker) {    
   $openingMarkerLength = strlen($openingMarker);    
   $closingMarkerLength = strlen($closingMarker);     
   $result = array();    
   $position = 0;    
   while (($position = strpos($text, $openingMarker, $position)) !== false) {      
      $position += $openingMarkerLength;      
     if (($closingMarkerPosition = strpos($text, $closingMarker, $position)) !== false) {       
        $result[] = substr($text, $position, $closingMarkerPosition - $position);        
        $position = $closingMarkerPosition + $closingMarkerLength;      
     }    
  }  
  return $result; 
}
echo '<div class="hd2"><center><font color=#666666><strong>' .$logo. '</strong></font></center></div><br>';
   $thedate = date('l dS F Y');
   echo '<center><font face="Verdana" size="2" color="#3366ff"><u>' .$thedate. '</center></u></font>';
?>
   <br><font face="Verdana" size="2"><?php echo GetGuide(); ?></font><br>
   <center><font face="Verdana" size="2"><?php echo $GLOBALS["Advert03"]; ?></font></center>
   <table id="" border="0" style="font-size:9pt;width:100%;">
   <tr style="font-color:#85859c;"><td style="width:10px;"><img src="Images/Logos/Logo_Back.gif"></td><td>
   <font face="Verdana" size="2"><b><a href="TvGuide.php">Back</b></font></a><br>
   </td></tr>
   </table>
   <hr>

<?php include 'Include/Footer.php'; Log_Hit("TvGuide"); ?>

now the logo shoulod display if they pick sabc 1 but it dont

Link to comment
https://forums.phpfreaks.com/topic/183164-quick-question/#findComment-966902
Share on other sites

A) You should be learning php, developing php code, and debugging php code on a system with error_reporting set to E_ALL and display_errors set to ON in your master php.ini so that php will help you. (Confirm the actual settings using a phpinfo() statement in case the php.ini that you are changing is not the one that php is using.) You will save a ton of time.  There would have been an undefined error message in your main code concerning $logo that would have alerted you to the fact that it does not exist in your main code because you are setting it inside of a function and it only exists inside of that function.

 

B) The two lines of code you posted in the first post, that you then expected everyone to be able to tell you why it did not work IS DEFINITELY NOT the actual code that does not work. Posting lines of code out of context, in this case way way out of context, just wastes everyone's time and almost always prevents getting a solution.

 

C) The point of functions are that they (optionally) accept input parameters, perform a (one) useful operation that your application needs, and returns the result that they produce. The purpose of your GetGuide() function is to produce and return $FGuide. The code in the GetGuide() function that is testing $_GET['channel'] for the purpose of setting $logo has nothing to do with producing and returning $FGuide and the code setting $logo should either be part of your main application code (right before where $logo is used) or it should be put into its' own function.

Link to comment
https://forums.phpfreaks.com/topic/183164-quick-question/#findComment-966990
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.