Current location: Hot Scripts Forums » Programming Languages » PHP » Help with a simple script


Help with a simple script

Reply
  #1 (permalink)  
Old 10-02-09, 08:41 PM
earthone earthone is offline
Newbie Coder
 
Join Date: Jul 2009
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Help with a simple script

We are trying to write a very basic script what it should do is call a section of text when we pull a url so when we use

Code:
http://oursite.org/folder/member.php?text=this
it should display the correct text section.

Can anyone tell us what we are doing wrong and how to fix it.

Thank you.

PHP Code:

<?php

if (!$text) {die('No text selected');}
elseif(
$text='this') {echo '<div class="topbar">This Text goes here</div>'; }
elseif(
$text='that') {echo '<div class="topbar">That Text goes here</div>'; }
?>
Reply With Quote
  #2 (permalink)  
Old 10-02-09, 10:09 PM
End User's Avatar
End User End User is offline
Level II Curmudgeon
 
Join Date: Dec 2004
Posts: 3,027
Thanks: 14
Thanked 35 Times in 33 Posts
You probably need to explicitly extract the "text" variable:
PHP Code:

$text $_GET['text'];
if (!
$text) {die('No text selected');}
elseif(
$text==]'this') {echo '<div class="topbar">This Text goes here</div>'; }
elseif(
$text=='that') {echo '<div class="topbar">That Text goes here</div>'; } 
Also notice that you need two equal signs to test a variable, otherwise you're actually assigning the word 'this' or 'that' to the variable $text.
__________________
I don't live on the edge, but sometimes I go there to visit.
-------------------------------------------------------------------------
Sanitize Your Data | Oracle Date & Substring Functions | Code Snippet Library | [url=http://www.codmb.com/Call Of Duty[/url]

Last edited by End User; 10-02-09 at 10:12 PM.
Reply With Quote
  #3 (permalink)  
Old 10-02-09, 10:22 PM
earthone earthone is offline
Newbie Coder
 
Join Date: Jul 2009
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Cool it worked there was only one problem you put ] in there after the first text most likely an accident but thank you very much.
Reply With Quote
  #4 (permalink)  
Old 10-02-09, 10:25 PM
earthone earthone is offline
Newbie Coder
 
Join Date: Jul 2009
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Im not sure how to or if Im suppose to but this question has been answered and is completed
Reply With Quote
  #5 (permalink)  
Old 10-02-09, 10:28 PM
wirehopper's Avatar
wirehopper wirehopper is offline
-
 
Join Date: Feb 2006
Posts: 2,515
Thanks: 20
Thanked 109 Times in 106 Posts
PHP Code:

elseif($text==]'this'
<-- remove the [

Different approach:

PHP Code:

if (isset($_GET['text']))  /* Check to see if text was sent */

{
  
$sText=strtolower($_GET['text']);  /* Lowercase to ensure comparison on next line works */
  
if (in_array($sText,array('this','that')))  /* Ensure the value is this or that */
    
echo '<div class="topbar">'.$_GET['text'].'</div>'/* Display the original value */
  
else
    die (
'Not this or that');
}
else
  die(
'No text'); 
Reply With Quote
  #6 (permalink)  
Old 10-03-09, 05:58 PM
End User's Avatar
End User End User is offline
Level II Curmudgeon
 
Join Date: Dec 2004
Posts: 3,027
Thanks: 14
Thanked 35 Times in 33 Posts
Quote:
Originally Posted by earthone View Post
Im not sure how to or if Im suppose to but this question has been answered and is completed
If you want you can click the "Thanks" button. Otherwise they won't pay me and my family will starve and we'll end up living by the side of the freeway in a leaky cardboard box and then I'll have to go back to robbing banks, or even worse, working for Microsoft (and you wouldn't want THAT on your conscience, would you?).
__________________
I don't live on the edge, but sometimes I go there to visit.
-------------------------------------------------------------------------
Sanitize Your Data | Oracle Date & Substring Functions | Code Snippet Library | [url=http://www.codmb.com/Call Of Duty[/url]
Reply With Quote
The Following 2 Users Say Thank You to End User For This Useful Post:
Jcbones (10-03-09), wirehopper (10-03-09)
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Raffle/Lottery Script (Very profitable!), Coded it myself. Voltaire General Advertisements 6 03-16-09 07:15 AM
Very simple script ! phpfreek Script Requests 6 11-29-06 01:19 PM
CSS Border Width Question. nova912 CSS 6 09-07-06 09:13 AM
Need a simple auction script installed caver911 Job Offers & Assistance 1 08-03-05 02:11 PM
Need help with this keyword script - i'm sure it's simple! dudeman248 JavaScript 2 05-19-04 05:11 PM


All times are GMT -5. The time now is 08:00 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.