Suzanne M Posted July 29, 2011 Share Posted July 29, 2011 I want to create a Jackpot game where the positive & negative numbers are randomly generated. I have written my code in Dreamweaver but I don't see the output of my PHP code. Instead of code I see the PHP symbol. I also want to know how to combine multiple functionalities in PHP. I want to create a table, store game credit, generate a random number etc. This is my current code. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Jackpot</title> </head> <body> <?php include "header.php"; ?> <table width="100%" cellpadding="0" cellspacing="0" align="center"> <tr valign="top"> <td width="100%" height="59" align="left" valign="top"><table width="100%" cellpadding="0" cellspacing="0" align="center"> <tr valign="top"> <td align="left" valign="top" bgcolor="#FFFFFF"><?php include "menu.php"; ?></td> <td width="100%" align="left" valign="top"><p align="center">Jackpot</p></td> </tr> </table> <p align="center"> </p></td> </tr> </table> <?php include "footer.php";?> <?php $random_number = rand(-1000,1000); echo "<p> You struck a Jackpot of </p>"; echo $random_number; ?> <form action="Jackpot.php" method="post"> fingerValue: <input type="text" name="fingerValue" /> <input type="submit" /> </form> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/243212-how-to-build-a-php-based-game-website/ Share on other sites More sharing options...
Eiolon Posted July 29, 2011 Share Posted July 29, 2011 Are you running a web server with PHP installed? Sounds like your server isn't parsing the PHP code. Quote Link to comment https://forums.phpfreaks.com/topic/243212-how-to-build-a-php-based-game-website/#findComment-1249169 Share on other sites More sharing options...
Maq Posted July 29, 2011 Share Posted July 29, 2011 Does your file have a .php extension? Quote Link to comment https://forums.phpfreaks.com/topic/243212-how-to-build-a-php-based-game-website/#findComment-1249187 Share on other sites More sharing options...
Suzanne M Posted July 30, 2011 Author Share Posted July 30, 2011 @Eiolon: I am using the Dreamweaver software to execute my PHP code, no output comes. All I see is the PHP symbol. @Maq: My file does have a PHP extension. Can someone tell me how to put multiple things in one PHP program eg. generating a random number, capturing form info etc. Quote Link to comment https://forums.phpfreaks.com/topic/243212-how-to-build-a-php-based-game-website/#findComment-1249349 Share on other sites More sharing options...
Halldor Posted July 30, 2011 Share Posted July 30, 2011 I don't know how Dreamweaver works, but it sounds like you didn't install a webserver to host your code. You can use WAMP or easyPHP if running windows. Try to run your code from the browser then, through your newly installed host. I don't get your second question. Quote Link to comment https://forums.phpfreaks.com/topic/243212-how-to-build-a-php-based-game-website/#findComment-1249353 Share on other sites More sharing options...
pranshu82202 Posted July 30, 2011 Share Posted July 30, 2011 Dreamweaver does not show the php code in the design (or split) window... You need to some program like xampp And then Proceed with the following steps.. 1. Download xampp (free) and extraxt the contents to root C:/ 2. Open xampp folder and open xampp-control.exe 3. Start apachae and myaql serveics and they shuld turn green. 4. Now go to your browser and type http://localhost and see wether its opening xampp window. 5. If its working then save your .php file in the following directory : C:\xampp\htdocs 6. Now again go to your browse and type in your address bar : http://localhost/abc.php (here abc.php is the name of your file) And it will work if your php code is fine... And your second problem : You can put as many php tag as you can.. For ex. <html> <body> .... <?php // Any Code ?> Your HTML Code <?php //Your Second code ?> </body> </html> HOPE IT HELPS ... Happy CODING Quote Link to comment https://forums.phpfreaks.com/topic/243212-how-to-build-a-php-based-game-website/#findComment-1249358 Share on other sites More sharing options...
hyster Posted July 30, 2011 Share Posted July 30, 2011 Dreamweaver does not show the php code in the design (or split) window... You need to some program like xampp dreamweaver can display php inside the preview if u config dreamweaver to do so (as long as u have a webhost installed on ur pc) Quote Link to comment https://forums.phpfreaks.com/topic/243212-how-to-build-a-php-based-game-website/#findComment-1249365 Share on other sites More sharing options...
ignace Posted July 30, 2011 Share Posted July 30, 2011 I am using the Dreamweaver software to execute my PHP code, no output comes. All I see is the PHP symbol. That's because Dreamweaver doesn't parse your PHP code. You need to have a webserver installed like XAMPP and have your files hosted in it's htdocs directory (unless you know, which I doubt, how to re-configure Apache to point to the current location of your directory). You can then see the output, if you are lucky formatted like you did in Dreamweaver since DW is a WYSIWYAG: What You See Is What You Almost Get, if you navigate your browser to either: http://localhost:80/ or http://localhost:8080/ localhost (the reserved 127.0.0.1 ip address) is not a website like www.google.com it's a loopback address or in other words it points back to your computer with a certain protcol (http) and a port (80) this will trigger your local XAMPP installation as it's listening on one of these ports with a http protocol handler (Apache). Quote Link to comment https://forums.phpfreaks.com/topic/243212-how-to-build-a-php-based-game-website/#findComment-1249382 Share on other sites More sharing options...
Suzanne M Posted July 30, 2011 Author Share Posted July 30, 2011 Thanx frenz for all your help. @pranshu82202:I have used PHP tags before but what the problem is, now I have only used a table to display the header Jackpot. Remaining things are outside the table. I don't think I need the table but how do I place the remaining things in the table? Everyone: Basically I am developing a mini game. In this game, the gamer has some credit value. The gamer provides some credit for this game. The game generates random positive and negative values. These generated values are added to the gamer's credit. Now my qn is how do I update the gamer's credit? This is a real-time game. Quote Link to comment https://forums.phpfreaks.com/topic/243212-how-to-build-a-php-based-game-website/#findComment-1249389 Share on other sites More sharing options...
Halldor Posted July 30, 2011 Share Posted July 30, 2011 Thanx frenz for all your help. @pranshu82202:I have used PHP tags before but what the problem is, now I have only used a table to display the header Jackpot. Remaining things are outside the table. I don't think I need the table but how do I place the remaining things in the table? Everyone: Basically I am developing a mini game. In this game, the gamer has some credit value. The gamer provides some credit for this game. The game generates random positive and negative values. These generated values are added to the gamer's credit. Now my qn is how do I update the gamer's credit? This is a real-time game. You should either take a look at sessions, cookies or databases. Quote Link to comment https://forums.phpfreaks.com/topic/243212-how-to-build-a-php-based-game-website/#findComment-1249444 Share on other sites More sharing options...
Suzanne M Posted July 30, 2011 Author Share Posted July 30, 2011 I created a mySQL database using XAMP but I don't know what all to put in a database associated with a game that generates random numbers. I have to update user credit though so do I require 3 fields? Username, Credit, Random Value Generated. Quote Link to comment https://forums.phpfreaks.com/topic/243212-how-to-build-a-php-based-game-website/#findComment-1249480 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.