Forum Moderators: coopster

Message Too Old, No Replies

Please Some Help

Please Some Help

         

DjZoC

6:59 pm on Feb 27, 2009 (gmt 0)

10+ Year Member



i try to i make to my website one php script ... and is looking like this

php link : index.php?x=20893

<?php
$x = $_REQUEST['x'];
$20893 = "SuperMan Movie(example..)"; // Title For Movie ->
$movie_title = $x;
?>

how i can make this script if x = 20893 to show $20893 to $movie_title
<?=$movie_title?> = SuperMan Movie(example..)

sorry for my bad english

DjZoC

7:48 pm on Feb 27, 2009 (gmt 0)

10+ Year Member



can someone help me with this think please

coopster

7:58 pm on Feb 27, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, DjZoC.

There are a number of ways to accomplish this task. Where is 20893 coming from? A database? An array? A string value that you are setting in your script?

DjZoC

8:16 pm on Feb 27, 2009 (gmt 0)

10+ Year Member



link movie :
<a href="http://www.website.com/play.php?x=20893">Movie1</a>

play.php php script

<?php
$x = $_REQUEST['x']; // Cod From Player ->
$20893 = "Movie1"; // Title For Movie ->
$20894 = "Movie2"; // Title For Movie ->
$20895 = "Movie3"; // Title For Movie ->

$movie_title = .... // Title Movie For Player ->
?>

<?php include("include/config.php"); ?>
<?php include("header.php"); ?>

<?=$movie_title?><br />

<object width="584" height="458">
<param name="movie" value="http://www.anotherweb.com" />
<param name="FlashVars" value="id=<?=$x?>" />
<embed src="http://www.anotherweb.com?id=<?=$x?>" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" quality="high" allowfullscreen="true" width="584" height="458" />
</object>
<?php include("footer.php"); ?>

how i can make $movie_title to read no of $_REQUEST['x'] ? so $movie_title to take this $20893 = "Movie1"; // Title For Movie ->

and to show someting like this :

Movie1<br />

<object width="584" height="458">
<param name="movie" value="http://www.anotherweb.com" />
<param name="FlashVars" value="id=20893" />
<embed src="http://www.anotherweb.com?id=20893" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" quality="high" allowfullscreen="true" width="584" height="458" />
</object>

i try to i show becouse i dont know how to explain more good ... im sorry

[edited by: DjZoC at 8:19 pm (utc) on Feb. 27, 2009]

coopster

8:59 pm on Feb 27, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



OK. Well, first off you need to know that variables [php.net] cannot start with a number. The following are invalid variable names:
$20893 = "Movie1"; // Title For Movie -> 
$20894 = "Movie2"; // Title For Movie ->
$20895 = "Movie3"; // Title For Movie ->

Here is how I might approach something the task at hand. Use an array with the movie number as the index, and let's go with a string in case it ever starts with zero for some reason.
<?php 
$titles = array(
'20893' => 'Movie1',
'20894' => 'Movie2',
'20895' => 'Movie3',
);
$x = $_REQUEST['x'];
$movie_title = isset [php.net]($titles[$x]) ? $titles[$x] : 'Unknown';
include 'include/config.php';
include 'header.php';
print htmlentities [php.net]($movie_title);
?>
<br />
object width="584" height="458">
...

You could use a switch control structure [php.net] too, but if you ever end up switching over to a database instead of hardcoding the movie titles into your script, the transition will be much easier.

DjZoC

6:41 am on Feb 28, 2009 (gmt 0)

10+ Year Member



thanks very more is working very good you help me very more man thank you !
one more think and i dont know how to do this ...

play.php script

<?php
$playertype = array(
'vd1' => 'video1',
'vd2' => 'video2',
);
$p = $_REQUEST['p']; // Player Type ->
$player = isset($playertype[$p]) ? $playertype[$p] : 'UnknownPlayer';
?>

how i can make if player = UnknownPlayer to redirect on index.php ? thanks for help man you are the best

DjZoC

5:24 am on Mar 1, 2009 (gmt 0)

10+ Year Member



can someone help me with this ? please

blang

5:58 am on Mar 1, 2009 (gmt 0)

10+ Year Member



If you want to redirect, change the ternary operator to a standard if...else block and call header() to change the page location, e.g.

if ( !isset($playertype[$p]) ) {
header("Location: [yoursite.com...]
} else {
// continue with the script
}

DjZoC

7:58 am on Mar 1, 2009 (gmt 0)

10+ Year Member



thank man !
thanks for help

[edited by: DjZoC at 8:00 am (utc) on Mar. 1, 2009]