Jump to content

wildteen88

Staff Alumni
  • Posts

    10,480
  • Joined

  • Last visited

    Never

Everything posted by wildteen88

  1. What does the included file template.php contain? You can only position html. The browser will not even know the html is being included.
  2. Byusing virtual hosts if you're using Apache, if you have access to Apache's configuration Or if your site has a control panel such as cpanel/plesk you can setup subdomains from their.
  3. Position your css code? Your CSS should be in between the <head></head> tags wrapped in <style></style> tags.
  4. You can develop your script to work on IIS and Apache. However just make sure you don't use any server specific environment variables, such as with IIS you can retrieve the user login name from Windows. On Apache you can't do this. However I would ditch IIS and just concentrate on Apache. Apache is the most used server for hosting PHP sites over IIS. It is up to you though If you are going to install both IIS and Apache then be careful when installing Apache. Both Apache and IIS use the same port for listening for http requests (port 80). When you install Apache on windows you'll have to modify Apaches httpd.conf to listen on a different port.
  5. PHP has no control where content shows on a page. This is down to your HTML/CSS
  6. Search for mod_rewrite tutorials.
  7. No but you can do this: $fruit = array( 1 =>('apple'), 2=>('orange'), 3=>('banana'), 4=>('kiwi'), ); $key = 1; if(array_key_exists($key, $fruit)) { echo $fruit[$key]; } // alternative way: if(isset($fruit[$key])) { echo $fruit[$key]; }
  8. You'll probably want to use array_key_exists.
  9. This is a server configuration issue not a phpMyAdmin configuration issue.
  10. In order to run your php scripts on your Windows box you'll need to install what is called the AMP stack, which consists of Apache (server), MySQL (database) and PHP. However you may find it comfortable to use IIS for the server as your have developed ASP websites. But it would better to use Apache as this is will most like be the server install on the Linux box. There are a few packages ready available which will setup AMP on Windows. The two most popular being WAMP and XAMPP. However I prefer a manual install myself. Also it is better to have a local copy of AMP installed whilst creating your PHP. This bypasses the need to having to upload your files to the website, logging on to the net and then testing the script on the website. If its installed locally you can simple go to http://localhost to test your scripts.
  11. PHP5 and MySQL5 are available now for installation. However it depends on the host whether or not they provide PHP5/MySQL5 on their hosting packages. Many hosts do provide both PHP5 and PHP4 with their hosts packages this differs from host to host, most hosts get you to save your .php files as .php5 or provide a setting the site control panel/.htacces. However not that PHP4 has comes to the end of life most hosts should start to provide PHP5 by default. As for MySQL I am not sure. Now is openfreeway your application you have developed (with a group of others)? If it is the I suggest you/all developers to sit down and to recode most of it because at the moment there is a lot of (user input) variable soap. You appear to use a mix of superglobals ($_GET, $_POST vars etc), register_long_arrays ($HTTP_*_VARS) and the worst of the all register_globals all over the place. The latter two register_long_arrays and register_globals has since been depreciated and is to be removed as of PHP6. They are also displabled by default on PHP5. Now you should only support one type of user input variable, not a mix and definably not provide support for register_globals if you can help it.
  12. That wont work friojole if register_gloabls is not enabled! You'll be better of using: <?php if(isset($_GET['page'])) { switch($_GET['page']) { // url has ?page=forum case 'forum': // if url has the id present eg: ?page=forum&id=123 // then include another page if(isset($_GET['id']) && is_numeric($_GET['page'])) { include './site/whateverpageyouwant.php'; } // url does not provide the id, just include forum.php else { include './site/forum.php'; } break; // url has ?page=another_page // include another_page.php case 'another_page'; include './another_page.php'; break; // to add more more pages just do the same as above, eg: // url has ?page=one_more_page case 'one_more_page'; include './one_more_page.php'; break; // requested page is not found // display error default: die('<h1>404 Page not Found</h1>'); } } // page var not present display error else { die('<h1>404 Page not Found</h1>'); } ?>
  13. Yes you can, php is can run on Windows and linux just fine. The only thing you should not do whilst developing your scripts on Windows is to use Windows based file paths, eg: include "C:/path/to/file.php"; This will not work on linux. When including files do something like this instead: include $_SERVER['DOCUMENT_ROOT'] . 'path/to/file.php'; That way your script will be more portable. Also try to match the PHP settings on the Windows box to the same/as close to the Linux box setup by comparing the information phpinfo() generates.
  14. Use: RewriteCond %{REQUEST_URI} !(.*)/$ RewriteRule ^(.*)$ http://your-site.com/$1 [R=301,L] Make sure the above code is before: RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^(.*)$ $1.php
  15. No you wont be able to control what the user does in the address bar. This is where your validation/verification should come in. If you don't want users tampering with GET data then you'll have to find another method of sending data from page to page, such as cookies or sessions or go the long route and use POST (not recommended).
  16. Do you mean you want to redirect all users who try to go to external sites such as google.com they will get redirected to your internal server?
  17. It also the same as print, the following will give the same result as echo: print 'Sorry, do not have destination information for';
  18. I now see what your problem is. First make sure Apache is completely stopped. I presume you're on Windows XP - the following steps should work on Vista. To stop Apache from starting up automatically go to Start > Run and type in services.msc into the Run box. Click OK and the services window will open. Now in the list of services you should find the Apache service. Right click on the Service and click Properties. Press the Stop button if Apache is already running. When the service has stopped, look just above the Start Stop and Restart buttons you find the Startup Type pull down menu. It should be set to Automatic, if it is click the menu and choose Manual. Now click ok to all open dialog boxes. The Apache service will now not startup when Windows starts. NOTE: The following maybe different if your have Vista, I believe you can do this from Control Panel under the Network category. The following will work if you're using XP. You'll also want to consult your routers manual too. Now to get your laptop to reconnect to your router you'll need to re-setup the Wireless connection. You can do this within windows by using the Wireless Network Setup Wizard by going Start > All Programs > Accessories > Communications > Wireless Network Setup Wizard Run through the wizard to reconnect your laptop to your wireless network. You'll most probably need to provide your WEP or WAP/WAP2 key in order for your laptop to connect to the wireless. This would of been setup when you installed your router. Once your laptop is reconnected I will help you to reconfigure Apache to use a different IP Address.
  19. You can use any database server you like. All work just as good as MySQL. If you want to use MySQL then use MySQL if the client wants to use MSSQL then you'll have to adapt your script so it'll work with MS SQL.
  20. The php code is for the second part. Also I just looked at your HTML code and your HTML is invalid so that maybe why the code is not working. Use the following HTML code instead. <html> <head><title>Distance from Chicago!</title></head> <body> <h1>Welcome to the Distance Calculation Page.</h1> <p>The page that calculates the distances from Chicago!</p> <form action="http://localhost/julie/c5-e4a.php" method="post"> <p> <strong>Destination</strong>:<br /> <select name="destination" size="5"> <option value="Boston">Boston</option> <option value="Dallas">Dallas</option> <option value="Las Vegas">Las Vegas</option> <option value="Miami">Miami</option> <option value="Nashville">Nashville</option> <option value="Pittsburgh">Pittsburgh</option> <option value="San Francisco">San Francisco</option> <option value="Toronto">Toronto</option> </select> </p> <p>To see distance information for every city, click here <input type="checkbox" name="location" value="yes"></p> <input type="SUBMIT" value="Click To Submit"><input type = "RESET" value = "Reset" > </form> </body> </html> If the code still does not work (it has been tested and works for me) then make sure you set error_reporting to E_ALL and set display_errors to On within the php.ini. Save the php.ini and restart your server software (Apache or IIS or whatever server you're using). When developing PHP scripts error_reporting should be set to atleast E_ALL and display_errors turned on this makes it easier to debug code when nothing happens. Also can you post your PHP version too.
  21. That is the complete code yes. Why whats wrong?
  22. That is incorrect. for( $i = 0 ; $i <= 5 ; $i++ ) for(set $i to 1; if the condition is true (in your case if $i is less than or equal to 5); then increment $i and execute code in the braces)
  23. Use the following code, for display the distances: <?php $cities = array ( 'Boston' => 1551, 'Dallas' => 803, 'Las Vegas' => 1077, 'Miami' => 1108, 'Nashville' => 615, 'Pittsburgh' => 1069, 'San Francisco' => 1493, 'Toronto' => 1203 ); if(isset($_POST['location']) && $_POST['location'] == 'yes') { // use a foreach loop to loop through the cities array, rather than type out the same code for every city foreach($cities as $city_name => $city_distance) { $time = round( ($city_distance / 60), 2); $walktime = round( ($city_distance / 5), 2); print "<p>The distance between Chicago and <b>$city_name</b> is <b>$city_distance</b> miles.<br />"; print "Driving at 60 miles per hour it would take <b>$time</b> hours.<br />"; print "Walking at 5 miles per hour it would take <b>$walktime</b> hours.</p>"; } } elseif(isset($_POST['destination']) && isset($cities[$_POST['destination']])) { $city_name = $_POST['destination']; $city_distance = $cities[$city_name]; $time = round( ($city_distance / 60), 2); $walktime = round( ($city_distance / 5), 2); print "<p>The distance between Chicago and <b>$city_name</b> is <b>$city_distance</b> miles.<br />"; print "Driving at 60 miles per hour it would take <b>$time</b> hours.<br />"; print "Walking at 5 miles per hour it would take <b>$walktime</b> hours.</p>"; } else { echo 'Sorry, do not have destination information for'; } ?>
  24. PHP can be used with a whole range of different databases. In order for PHP to work with other databases you'll need to enable the correct extension/ODBC driver for the particular database you wish to use, which you can get from the manual. MS SQL manual
  25. Yes post the other part too. When you post your code wrap it in code tags ( )
×
×
  • 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.