Jump to content

wildteen88

Staff Alumni
  • Posts

    10,480
  • Joined

  • Last visited

    Never

Everything posted by wildteen88

  1. When doing comparison checks with superglobal arrays always use isset like so: [code] if ( isset( $_GET['Submit'] ) && $_GET['Submit'] == 'Submit'){[/code] That then stops the notice error apearing if Submit is not set.
  2. include and require only include files, It doesnt include functions. This is how you use the functions: [code]<?php include 'filename.php'; // OR require 'filename.php'; ?>[/code]
  3. Could you post your code here please so we can see what you are doing. PHP shouldn't shouldn't "halt" when you place <?php in a variable.
  4. Okay. Seems all this boils down one thing! You have register globals on. If you get a result from this then you have register globals on! test.php [code]<?php session_start(); session_register("hello"); $hello = "Hello world"; ?> <a href="test2.php">Test session</a>[/code] test2.php [code]<?php session_start(); echo $hello; ?>[/code] Also make sure your browser(s) accepts cookies! Do you get a result this time?
  5. [!--quoteo(post=376885:date=May 25 2006, 05:00 AM:name=DapperDanMan)--][div class=\'quotetop\']QUOTE(DapperDanMan @ May 25 2006, 05:00 AM) [snapback]376885[/snapback][/div][div class=\'quotemain\'][!--quotec--] Okay, I admit up front, I am new to php. But I swear I see some mistakes in the code? I have always seen the include function with '(' and ')' around the included file. Is this something you don't need? Also, I have always placed my "session_start()" at the very top of the code. Now, the manual says if you are doing sessions with cookies it has to be this way, but could this be another problem perhaps? Please enlighten me, because I am very curious about these two things that I see. Thank you, DapperDanMan [/quote] when using inlcude or require you dont have to use the parentheses () around the file you are including, either of the following will work: [code]include("filename.php"); include 'filename.php'; include "filename.php";[/code] You can place session_start() whereever you want, BUT you must now have any output (text/html) to the browser before the use of session start(). For example this will cause an error: [code]<html> ... html here ... <body> <?php session_start(); //rest of PHP here [/code] But this wont: [code]<?php session_start(); ?><html> ... html here ... <body> <?php //rest of PHP here [/code]
  6. if you want your line breaks to be preserved use nl2br, ie: [code]$comment = nl2br(htmlspecialchars($_POST[comment]));[/code] nlsbr converts new line characters (\r or \n) to a html line break (< br / >)
  7. You forgot to put a closing '[b])[/b]' bracket on this line: [code]if (!mysql_query($sql,$con)[/code] if you add an ) at the end of that line it should sort out your error.
  8. Ok first check that the MySQL service is running. You can do this by going to Start > Control Panel > Administrative Tools > Services Now scoll down the list of services until you reach MySQL. Now click on the MySQL row and now check that the status column states [b]Started[/b]. If it doesn't right click on MySQL and click Start from the menu. Windows will now attempt to start the MySQL service. If MySQL is started you should be able to connect to the MySQL server.
  9. To php.ini? You cant have multiple copies of a php.ini file! PHP will only use the master php.ini and not secound php.ini file! But any way. The first line doesnt even go into a php.ini as its an Apache only command. The php_flag magic_quotes_gpc on and php_flag register_globals on can be changed to the following though: [code]magic_quotes_gpc = on register_globals = on[/code]
  10. Your version of PHP5 most probably has a setting called [b]register_long_arrays[/b] turned off in the php.ini which means your $HTTP_*_VAR's are not being recognised/populated by PHP. Instead you'll want to strip HTTP and _VAR from your variable names so: $HTTP_POST_VAR becomes $_POST $HTTP_GET_VAR becomes $_GET $HTTP_COOKIE_VAR becomes $_COOKIE $HTTP_SESSION_VAR becomes $_SESSION $HTTP_SERVER_VAR becomes $_SERVER etc. Your script should now work with PHP5 and 4 too when the changes are made. You should really use the newer superglobal arrays rather than the old depereciated ones.
  11. Actually save your css file with a php file extension now make sure you put the following code as the very firstline in your css file: [code]<?php header("Content-type: text/css"); ?> /*rest of css here*/[/code] Now you can use PHP code in your style sheet but the stylesheet must be saved with a php file extension and not a css file extension!
  12. You'll want to do this instead: [code]//check whether game id is set in the session/post variables first if(isset($_SESSION['game_id']) || isset($_POST['game_id'])) {     if ($_SERVER['REQUEST_METHOD']=='POST' && isset($_POST['game_id']) && trim($_POST['game_id'])!='')     {         //just included the strip_tags() to clean posted entry         //you might    want to add some more         $game_id = strip_tags($_POST['game_id']);     }     else     {         $game_id = $_SESSION['game_id'];     } } else {     //kill the script no game is selected     die("You have not selected a game! Please go back and select a game"); }[/code]
  13. Umm, OK create a new file called test.php and put the following into it [code]<?php session_start(); $_SESSION['test'] = "Hello world"; ?> <a href="test2.php">Test session</a>[/code] Now create a file called test2.php and put the following in it: [code]<?php session_start(); echo $_SESSION['test']; ?>[/code] Upload both files.And run test.php and click the [b]Test session[/b] link. It should take you to test2.php and hello world should be displayed.
  14. Either you have misread the book, or the book as you said is a pile of crap! [img src=\"style_emoticons/[#EMO_DIR#]/wink.gif\" style=\"vertical-align:middle\" emoid=\":wink:\" border=\"0\" alt=\"wink.gif\" /] I always use $_POST, $_GET and $_COOKIE rather than $_REQUEST.
  15. If you havn't got any replies then its most likey no one understands your question or doesn't know what to do. Also the snippet of code you have posted doesnt help much with your question at all.
  16. No the $_REQUEST variable only stores $_GET, $_POST and $_COOKIE data. Sessions are stored in their own seperate variable $_SESSION
  17. You are registering your sessions incorrectly. Scrap the sessin_register functions out and use this: [b]$_SESSION['login_name'] = $login_name;[/b] Then on your other page use: [b]print $_SESSION['login_name'];[/b] to get the login_name session. Also your script wont output anythink as you was not assigning yout login_name session with nothing. So when you went to the next page nothing was outputted as the login_name session didn't have any assigned to it.
  18. Any forum has those features, but not in the "out of the box" condition. Some of those features will require a modification/plugin to be made in order for those features to be available. I know IPB (Invision Power Board) has the first three features listed apart from the photo album, but you have to pay for IPB. But phpBB which is a free open source forum has most of those features in modifications. Another forum is myBB and Simple Machines. Hope that helps.
  19. You don't put anythink in your html file! You put the html in the PHP file! Then run the php file, you should see the output of you php script in the browser.
  20. I uploaded it with the same file name so prehaps a refesh/cache clear will bring the new image through. If not doest matter
  21. Yes the sesion data is stored in a private folder usually the tmp folder. However if the browser is closed and the user didn't logout when they left. When they come back to your site in a new browser window PHP will issue a new session to that user. You cannot delete the session files yourself unless you have access to the folder in which they are stored in.
  22. I thought that might be the case. However I would recommend you to add the PHP folder to the Windows PATH variable saves having to move files around the place and keeps all PHP related files contained in the PHP folder.
  23. Looks like you may have missread the tutorial. Look on this page [a href=\"http://www.sitepoint.com/article/users-php-sessions-mysql/3\" target=\"_blank\"]here[/a] at the first block of PHP code. Notice they have defined their own function called dbConnect in db.php If you copy the code they have used for db.php into your db.php all should be fine. About the session error make sure you have place your code in the correct place and that you have followed the tutorial correctly too by reading through the tutorial again. Chances are you may have made a mistake somewhere along the line.
  24. Yeah I was lookingt at you code earlier when you posted it but I got confused looking at it as its a complete mess really and I couldn't find my way through it. But as you have point that block of code above I can see your problem which is here: [code] $url = $_SERVER['SERVER_NAME'];[/code] Notice you are setting up $url with the value of $_SERVER['NAME']. This is why you input form always displays you web address in the input field. What you should do is this, change the following:[code] $url = $_SERVER['SERVER_NAME']; $root = $url.$_SERVER['PHP_SELF']; $root = str_replace("index.php","",$root); $root = "http://".$root;[/code] to the following: [code]$root = $_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF']; $root = str_replace("index.php", "", $root); $root = "http://" . $root;[/code]
  25. Umm, dbConnect is a non-existant defined function within PHP. But is more likely to be a user definied function instead. From looking at your code dbConnect isn't needed at all. So remove it from your code and you should be fine. Unless its defined in common.php as thats another file you are including.
×
×
  • 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.