Jump to content

help with Get_


the-botman

Recommended Posts

ok some how this is not working i am not sure what i am doing wrong here but what this does is when the user goes to Secret-Codes.php they get a menu and when they pick the phone they want to view it then displays it as expl www.bhawap.com/Secret-Codes?phone=Nokia but i some how am doing something wrong here is my code

<?php


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

if($_GET['phone'] == True) {          
           GetCodes();
       }else {
             Show_Form();     	
} 

function Show_Form() {
      $thedate = date('l dS F Y');
      echo '<div class="hd2"><font color=#666666><strong><center>Mobile Secret Codes</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/Logos/tools.gif"></td><td>';
      echo '<font face="Verdana" size="2"><b><a href="Secret-Codes.php?phone=BenQ">BenQ</b></font></a><br>';
      echo '</td></tr>';
      echo '<tr style="font-color:#85859c;"><td style="width:10px;"><img src="Images/Logos/tools.gif"></td><td>';
      echo '<font face="Verdana" size="2"><b><a href="Secret-Codes.php?phone=Nokia">Nokia</b></font></a><br>';		
      echo '</td></tr>';
      echo '<tr style="font-color:#85859c;"><td style="width:10px;"><img src="Images/Logos/tools.gif"></td><td>';
      echo '<font face="Verdana" size="2"><b><a href="Secret-Codes.php?phone=Lg">Lg</b></font></a><br>';
      echo '</td></tr>';
      echo '<tr style="font-color:#85859c;"><td style="width:10px;"><img src="Images/Logos/tools.gif"></td><td>';
      echo '<font face="Verdana" size="2"><b><a href="Secret-Codes.php?phone=Sharp">Sharp</b></font></a><br>';		
      echo '</td></tr>';
      echo '<tr style="font-color:#85859c;"><td style="width:10px;"><img src="Images/Logos/tools.gif"></td><td>';
      echo '<font face="Verdana" size="2"><b><a href="Secret-Codes.php?phone=Motorola">Motorola</b></font></a><br><br>';			
      echo '</td></tr>';
      echo '<tr style="font-color:#85859c;"><td style="width:10px;"><img src="Images/Logos/tools.gif"></td><td>';
      echo '<font face="Verdana" size="2"><b><a href="Secret-Codes.php?phone=Samsung">Samsung</b></font></a><br>';
      echo '</td></tr>';
      echo '<tr style="font-color:#85859c;"><td style="width:10px;"><img src="Images/Logos/tools.gif"></td><td>';
      echo '<font face="Verdana" size="2"><b><a href="Secret-Codes.php?phone=Sony-erricson">Sony-erricson</b></font></a><br>';		
      echo '</td></tr>';
      echo '<tr style="font-color:#85859c;"><td style="width:10px;"><img src="Images/Logos/tools.gif"></td><td>';
      echo '<font face="Verdana" size="2"><b><a href="Secret-Codes.php?phone=Sagem">Sagem</b></font></a><br><br>';			
      echo '</td></tr>';
      echo '</table>';
      echo '<center><font face="Verdana" size="2"><?php echo $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 GetCodes() { 		
if($_GET['phone'] == "Sagem"){ 
       $getMyDataFrom = phone-codes/sagem.txt
}
if($_GET['phone'] == "Lg"){ 
       $getMyDataFrom = phone-codes/lg.txt
}
if($_GET['phone'] == "Motorola"){ 
       $getMyDataFrom = phone-codes/motorola.txt
}
if($_GET['phone'] == "Nokia"){ 
       $getMyDataFrom = phone-codes/nokia.txt
}
if($_GET['phone'] == "Samsung"){ 
       $getMyDataFrom = phone-codes/samsung.txt
}
if($_GET['phone'] == "Sharp"){ 
       $getMyDataFrom = phone-codes/sharp.txt
}
if($_GET['phone'] == "Sony-erricson"){ 
       $getMyDataFrom = phone-codes/sony-erricson.txt
}
if($_GET['phone'] == "BenQ"){ 
       $getMyDataFrom = phone-codes/benq.txt
}

if(!isset($_GET['page'])){
   $page=0;
} else {
   $page=$_GET['page'];
}

$numsent=8; //number of sentences per page

$lines = file(' .$getMyDataFrom. ');
$startnum=$page*$numsent;
$endnum=$startnum+$numsent;
$numpartsinstring=count($lines); //counts number of lines in string

for($i=0;$i<$startnum;$i++){
   unset($lines [$i]); //kills parts before
}

for($j=$endnum;$j<$numpartsinstring;$j++){
  unset($lines [$j]); // kill parts after
}

$newstring=implode($lines,'<br>');
$i=0; 
$upper = 60;

while ($i <= $upper) {
    $newstring = str_replace($i, '<font face="Verdana" color="red">' . $i . '</font>', $newstring);
    $i++;
}
    $newstring = str_replace('#', '<font face="Verdana" color="red">#</font>', $newstring);
    $newstring = str_replace('-', '<font face="Verdana" color="red">-</font>', $newstring);
    $newstring = str_replace('*', '<font face="Verdana" color="red">*</font>', $newstring);

print '         <div class="hd2"><center><font color=#666666><strong>BenQ Secret codes</strong></font></center></div><br>'."\n";
print '<font face="Verdana" size="2">' .$newstring. '</font>';
print "<br><br>";
$numpages=ceil($numpartsinstring/$numsent);

for($i=1;$i<=$numpages;$i++){
  $actualstart=$i-1;
  if($actualstart!=$page)  {
    print "<A href='BenQ.php?page=$actualstart'>$i</a> ";
  }  else  {
     print "$i ";
  }
}
}
?>

	<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="secret-codes.php">Back</b></font></a><br>
	</td></tr>
</table>
<hr>
<?php
include 'Include/Footer.php'; 
Log_Hit("secret-codes"); 
?>

Link to comment
https://forums.phpfreaks.com/topic/183205-help-with-get_/
Share on other sites

Have you got error reporting turned on, you have a few errors.

 

Here....

 

echo '<center><font face="Verdana" size="2"><?php echo $GLOBALS["Advert03"]; ?></font></center>';

 

You have php tags and are using echo when your already within an echo statement.

 

Then further down you have quotes that make no sense at all.

 

$lines = file(' .$getMyDataFrom. ');

Link to comment
https://forums.phpfreaks.com/topic/183205-help-with-get_/#findComment-966877
Share on other sites

ok i fixed the first bug and made it

echo '<center><font face="Verdana" size="2">' .$GLOBALS["Advert03"]. '</font></center>';

 

then that statment down used to be

$lines = file(' phone-codes/sony-erricson.txt');

but the old way i had 1 page for each phone now i am trying to join all and make 1 page do the work of 10 so i tried it that way

Link to comment
https://forums.phpfreaks.com/topic/183205-help-with-get_/#findComment-966883
Share on other sites

here is an expl of 1 of the 100% working pages

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

if(!isset($_GET['page'])){
   $page=0;
} else {
   $page=$_GET['page'];
}

$numsent=8; //number of sentences per page

$lines = file('phone-codes/sagem.txt');
$startnum=$page*$numsent;
$endnum=$startnum+$numsent;
$numpartsinstring=count($lines); //counts number of lines in string

for($i=0;$i<$startnum;$i++){
   unset($lines [$i]); //kills parts before
}

for($j=$endnum;$j<$numpartsinstring;$j++){
  unset($lines [$j]); // kill parts after
}

$newstring=implode($lines,'<br>');
$i=0; 
$upper = 60;

while ($i <= $upper) {
    $newstring = str_replace($i, '<font face="Verdana" color="red">' . $i . '</font>', $newstring);
    $i++;
}
    $newstring = str_replace('#', '<font face="Verdana" color="red">#</font>', $newstring);
    $newstring = str_replace('-', '<font face="Verdana" color="red">-</font>', $newstring);
    $newstring = str_replace('*', '<font face="Verdana" color="red">*</font>', $newstring);

print '         <div class="hd2"><center><font color=#666666><strong>Sagem Secret codes</strong></font></center></div><br>'."\n";
print '<font face="Verdana" size="2">' .$newstring. '</font>';
print "<br><br>";
$numpages=ceil($numpartsinstring/$numsent);

for($i=1;$i<=$numpages;$i++){
  $actualstart=$i-1;
  if($actualstart!=$page)  {
    print "<A href='Sagem.php?page=$actualstart'>$i</a> ";
  }  else  {
     print "$i ";
  }
}
?>

	<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="secret-codes.php">Back</b></font></a><br>
	</td></tr>
</table>
<hr>
<?php
include 'Include/Footer.php'; 
Log_Hit("secret-codes"); 
?>

so i tried to make all from this

Link to comment
https://forums.phpfreaks.com/topic/183205-help-with-get_/#findComment-966899
Share on other sites

ok this is my new code it now displays the first page but i get errors

<?php
error_reporting(E_ALL); 
ini_set("display_errors", 1); 


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

if($_GET['phone'] == True) {    
           $getMyDataFrom = 'phone-codes/'.$_GET['phone'].'.txt';      
           GetCodes(); }
           else {
             Show_Form();     	
} 
function Show_Form() {
      $thedate = date('l dS F Y');
      echo '<div class="hd2"><font color=#666666><strong><center>Mobile Secret Codes</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/Logos/tools.gif"></td><td>';
      echo '<font face="Verdana" size="2"><b><a href="Secret-Codes.php?phone=benq">BenQ</b></font></a><br>';
      echo '</td></tr>';
      echo '<tr style="font-color:#85859c;"><td style="width:10px;"><img src="Images/Logos/tools.gif"></td><td>';
      echo '<font face="Verdana" size="2"><b><a href="Secret-Codes.php?phone=Nokia">Nokia</b></font></a><br>';		
      echo '</td></tr>';
      echo '<tr style="font-color:#85859c;"><td style="width:10px;"><img src="Images/Logos/tools.gif"></td><td>';
      echo '<font face="Verdana" size="2"><b><a href="Secret-Codes.php?phone=Lg">Lg</b></font></a><br>';
      echo '</td></tr>';
      echo '<tr style="font-color:#85859c;"><td style="width:10px;"><img src="Images/Logos/tools.gif"></td><td>';
      echo '<font face="Verdana" size="2"><b><a href="Secret-Codes.php?phone=Sharp">Sharp</b></font></a><br>';		
      echo '</td></tr>';
      echo '<tr style="font-color:#85859c;"><td style="width:10px;"><img src="Images/Logos/tools.gif"></td><td>';
      echo '<font face="Verdana" size="2"><b><a href="Secret-Codes.php?phone=Motorola">Motorola</b></font></a><br><br>';			
      echo '</td></tr>';
      echo '<tr style="font-color:#85859c;"><td style="width:10px;"><img src="Images/Logos/tools.gif"></td><td>';
      echo '<font face="Verdana" size="2"><b><a href="Secret-Codes.php?phone=Samsung">Samsung</b></font></a><br>';
      echo '</td></tr>';
      echo '<tr style="font-color:#85859c;"><td style="width:10px;"><img src="Images/Logos/tools.gif"></td><td>';
      echo '<font face="Verdana" size="2"><b><a href="Secret-Codes.php?phone=Sony-erricson">Sony-erricson</b></font></a><br>';		
      echo '</td></tr>';
      echo '<tr style="font-color:#85859c;"><td style="width:10px;"><img src="Images/Logos/tools.gif"></td><td>';
      echo '<font face="Verdana" size="2"><b><a href="Secret-Codes.php?phone=Sagem">Sagem</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';
}

function GetCodes() { 	
if(!isset($_GET['page'])){
   $page=0;
} else {
   $page=$_GET['page'];
}

$numsent=8; //number of sentences per page

$lines = file($getMyDataFrom);
$startnum=$page*$numsent;
$endnum=$startnum+$numsent;
$numpartsinstring=count($lines); //counts number of lines in string

for($i=0;$i<$startnum;$i++){
   unset($lines [$i]); //kills parts before
}

for($j=$endnum;$j<$numpartsinstring;$j++){
  unset($lines [$j]); // kill parts after
}

$newstring=implode($lines,'<br>');
$i=0; 
$upper = 60;

while ($i <= $upper) {
    $newstring = str_replace($i, '<font face="Verdana" color="red">' . $i . '</font>', $newstring);
    $i++;
}
    $newstring = str_replace('#', '<font face="Verdana" color="red">#</font>', $newstring);
    $newstring = str_replace('-', '<font face="Verdana" color="red">-</font>', $newstring);
    $newstring = str_replace('*', '<font face="Verdana" color="red">*</font>', $newstring);

print '         <div class="hd2"><center><font color=#666666><strong>Mobile Secret codes</strong></font></center></div><br>'."\n";
print '<font face="Verdana" size="2">' .$newstring. '</font>';
print "<br><br>";
$numpages=ceil($numpartsinstring/$numsent);

for($i=1;$i<=$numpages;$i++){
  $actualstart=$i-1;
  if($actualstart!=$page)  {
    print "<A href='Secret-Codes.php?page=$actualstart'>$i</a> ";
  }  else  {
     print "$i ";
  }
}
}
?>

	<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="secret-codes.php">Back</b></font></a><br>
	</td></tr>
</table>
<hr>
<?php
include 'Include/Footer.php'; 
Log_Hit("secret-codes"); 
?>

the errors i get are  this is from the first page

 

Notice: Undefined index: phone in /var/www/vhosts/bhawap.com/httpdocs/Secret-Codes.php on line 9

 

and this is from any page i try and open

 

Notice: Undefined variable: getMyDataFrom in /var/www/vhosts/bhawap.com/httpdocs/Secret-Codes.php on line 64

 

Warning: file() [function.file]: Filename cannot be empty in /var/www/vhosts/bhawap.com/httpdocs/Secret-Codes.php on line 64

 

Warning: implode() [function.implode]: Invalid arguments passed in /var/www/vhosts/bhawap.com/httpdocs/Secret-Codes.php on line 77

Link to comment
https://forums.phpfreaks.com/topic/183205-help-with-get_/#findComment-967054
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.