Jump to content

mikesta707

Staff Alumni
  • Posts

    2,965
  • Joined

  • Last visited

Everything posted by mikesta707

  1. your getting that issue because when i navigate to the page, I dont send any get variables. You use $_GET['page'] many times even though you never check to see if its set. If I navigate to "http://nero.exofire.net/auxtest/look_intro.php?page=taco" then that error disappears (The rest stay there, but I'll get to those in a minute) Now, how to fix this? Well, generally, when dealing with $_POST and $_GET, before you start using them, you need to check that they are set first. You may expect that the $_GET variables will be set in most instances, but there is always a way to get to a page expecting $_GET or $_POST, but not send them. PHP provides a very useful function called isset() that we will use. if (isset($_GET['page'])){ //do something with it, } Now, it may be annoying to do that everywhere you use $_GET['page'], so instead we can do something like if (isset($_GET['page'])){ $page = $_GET['page'];//dont forget to sanitize! } else { $page = ;//some default value } and if we stick that at the top of the page, we can replace all instances of $_GET['page'] with $page. this is generally better design anyways, because you dont want to have to sanitize $_GET['page'] every time you use it. and in case you missed the comment, don't forget to sanitize user input Now, for the other error messages. Those are rather easy to fix. They aren't actually errors, in that they are causing your page not to work. They actually work as you expect. They are notices. The problem is from places like this: switch($page) { case cwords: echo 'cwords'; break; case cnerds: echo 'cnerds'; break; case cshop: echo 'cshop'; break; case cshopus: echo 'cshopus'; break; case cshopuk: echo 'cshopuk'; break; case lwords: echo 'lwords'; break; case lnerds: echo 'lnerds'; break; case lshop: echo 'lshop'; break; case lshopus: echo 'lshopus'; break; case lshopuk: echo 'lshopuk'; break; case bwords: echo 'bwords'; break; case bnerds: echo 'bnerds'; break; case bshop: echo 'bshop'; break; case bshopus: echo 'bshopus'; break; case bshopuk: echo 'bshopuk'; break; case combine: echo 'combine'; break; default: echo 'customers'; break; } specifically these spots case bwords ... In php, when you write a literal string (like "hello" or "good bye") without without delimiting it with quotes, or heredoc, than PHP assumes you are using a constant. like this define("MYCONST", "CONSTVAL"); echo MYCONST;// echos CONSTVAL However, if you do something like echo hello; and there is no constant "hello" defined, PHP assumes you meant something like echo 'hello'; and act accordingly. thats why the error messages read to get rid of those messages, simply delimite those guys with double or single quotes switch($page) { case 'cwords': echo 'cwords'; break; case 'cnerds': echo 'cnerds'; break; case 'cshop': echo 'cshop'; break; case 'cshopus': echo 'cshopus'; break; case 'cshopuk': echo 'cshopuk'; break; case 'lwords': echo 'lwords'; break; case 'lnerds': echo 'lnerds'; break; ... }
  2. can you post your code, and perhaps a sample of the XML (just the part with the quotes and “) file. it does sound like an encoding issue, but it would help to see the code and file
  3. your overwitting your $string variable so it only ends up with the last thing you assign it. $string1 = $_POST['user_name']; $string2 = $_POST['user_id']; echo clean($string1); echo clean($string2); also, the code you posted wouldnt cause a function redeclared error
  4. sounds like your looking for include() if ($var == 'on'){ //whatever } else { include("error.php"); }
  5. echo "<table><tr>" foreach($answers as $value){ if (in_array($value, $wrong)){ $class = "wrong"; } else { $class = "correct"; } echo "<td class=\"$class\">$value</td>"; } echo "</tr></table>"; edit: meh beaten before i could post, but posting anyways
  6. that answered your question. remember google is your friend. first result from google search creating a database is as easy as running a single query
  7. the point of output buffering is to store any output from the script into a buffer. When output buffering is active, there is no output sent from the script. if you want to send the output when using output buffering, try using ob_end_flush() check out ob_start() for more information
  8. ahh yes, I see. Well why not store the session array into a variable in your script, like $sessions = $_SESSION; that way you can use $sessions instead
  9. exactly what information do you want to print out. Since no one here made this script, it will be hard to tell you what to store into variables. what information are you looking for? where on the page is it?
  10. Why not just use cookies?
  11. try using urlencode() on the information you are passing in the URL. for example, if your link looks like $link = "index.php?id=ak--bj"; try [/code] $link = "index.php?id=".urlencode("ak--bj"); [/code]
  12. a progress bar with PHP alone is not possible, since when you upload something to a page, it goes through the whole upload first before loading the new page. However, there are solutions using ajax/php combinations. a quick google search found this: http://bluga.net/projects/uploadProgressMeter/ among other things. I can't validate how useful that may be (didnt try it), but a little research via google will probably provide something usefull
  13. something i spotted quickly if ($IDLength = 4) { there you are doing assignment, you are assigning $IDLength with the value of 4 (which returns true so the if statement runs good. what you are looking for is comparison if ($IDLength == 4) {
  14. that is the worst formatted code i've ever seen. but if you want to make an image a link you put <a> tags around it. for exmple <a href="mylink.php"><img src="myimg.jpg" /></a> this is an HTML problem by the way, not a PHP problem
  15. try echoing $doACTION before the if statements to see what it has. If its empty, try doing a print_r on $_REQUEST. if that doesn't work for some reason, try using $_POST instead of $_REQUEST (since your forms send the data through $_POST)
  16. using a data base would probably be alot easier. instead of looping through a file, simply do a query or 2 and your done. off topic: btw your quote i think it goes
  17. <?php echo $row['f'.$f.'_name']; ?>
  18. the problem is here if ($doACTION = 'full_strength') you are doing an assignment there, and because you assign $doACTION to a non empty string, the assignment returns a value that equates to true. You want to do a comparison (==). if ($doACTION == 'full_strength') same idea with the subsequent if statements btw, if you want to check if something is set, instead of doing something like $var = $_REQUEST['var'] if (!$var) ... you can do if (isset($_REQUEST['var'])){ $var = $_REQUEST['var']; }
  19. hard to help without seeing code, but have you tried session_destroy()?
  20. ($pos === true) as i said before, that doesn't work. ($pos !== false) will though (verified this through testing) using regex would work too, but since you are only checking for the word and to be in a string, using regex seems unecessary. However, if your only looking for the word "and", then oni-kuns regex would work, although theoretically, changing the needle from "and" to " and " (just padding it with spaces) would work. $pos = stripos($type,' and '); but that wouldn't match the word and before a period (like "blaah blah and. blah blah") In that case regex would be useful
  21. this if ($username != $user) { if ($password != $pass) { print' <form method="POST" action="'. $_SERVER['PHP_SELF'] . '"> Login:<br/> <input type="text" name="username" size="14"><br/> Password:<br/> <input type="password" name="password" size="14"><br/> <input type="submit" value="Jungti" name="B1"> <input type="reset" value="Valyti" name="B2"> </form>'; } } can be simplified to if ($password != $pass && $username != $user) { print' <form method="POST" action="'. $_SERVER['PHP_SELF'] . '"> Login:<br/> <input type="text" name="username" size="14"><br/> Password:<br/> <input type="password" name="password" size="14"><br/> <input type="submit" value="Jungti" name="B1"> <input type="reset" value="Valyti" name="B2"> </form>'; }
  22. you also probably want your if to be if ($orderby==prospect_id) im assuming you want to do a comparison there, not an assignment
  23. the following <?php $type = "stuff with and in it"; $pos = strpos($type,'and'); if($pos !== false){ echo "checked=\"true\""; } ?> works perfectly for me. try stripos() instead of strpos if you want to make the search case insensitive
  24. mikesta707

    $_GET

    Ahh i must have misunderstood, I figured he was asking about sanitizing $_GET values, not hiding them. Everything makes sense now
  25. what does your query look like. what does your table look like? I assume each message has a to and from column. You could simply check in the query that id=$_GET['id'] AND user=$username where $username is the currently logged in user (perhaps you store this value in a session when they log in? well if you don't adding that functionality is trivial)
×
×
  • 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.