Jump to content

mikesta707

Staff Alumni
  • Posts

    2,965
  • Joined

  • Last visited

Everything posted by mikesta707

  1. look into the stristr() function: http://us2.php.net/manual/en/function.stristr.php
  2. well if var1 is equal to var2 logic would dictate that var2 is equal to var1. thats like asking if 1 is equal to 1, is 1 equal to 1
  3. escaping the values : http://us.php.net/manual/en/function.mysql-escape-string.php the function is called mysql_escape_string(). use that to gaurd against sql injection. echoing the sql just means to echo the $sql variable to make sure it is doing what you want it to. like echo $sql;
  4. can you post the logged_in() method of you session class?
  5. Yes you can. Can you? I have ran into problems doing this. also if it deleted all the info (or rather overwrote it with empty values) perhaps your arrays have empty values. sorry for the incorrect information!
  6. I would do number 2 personally
  7. you can't use php arrays in mysql queries like that. try $sql1="UPDATE $tbl_name SET item='" . $item[$i] . "', price1='" . $price1[$i] . " ', price2='" . $price2[$i] . "' WHERE id='" . $id[$i]. "'"; I believe you can also surround them with {}, like so $sql1="UPDATE $tbl_name SET item='{$item[$i]}', price1='{$price1[$i]}', price2='{$price2[$i]}' WHERE id='{$id[$i]}'"; but about the latter, I am not sure about syntactily(sp?) so I would use the first example. hope that helps!
  8. you will probably want to look into some regex functions, like preg_replace. I'm not to good with regex (and there is another subforum dedicated to regex problems)
  9. there is a tutorial on this site. look up pagination. Also, if you can't do pagination, you may have trouble making an entire forum from scratch. good luck!
  10. Indeed they are. Just to test I ran the following script (basically yours with a foreach to output) <?php $myArray = array(); $myArray["key1"] = "value1"; $myArray[] = "value2"; $myArray[1] = "value3"; $myArray[] = "value4"; foreach($myArray as $key => $value){ echo $key . " => " . $value . "<br />"; } ?> and the output was as follows: key1 => value1 0 => value2 1 => value3 2 => value4 so again, yes you are correct
  11. ahhh, they are searches in different area. I thought you just had one search bar and you wanted the old results along with the new or something crazy like that. Well, like Kickstart said, the best way would be to use AJAX.
  12. well I assumed he knows how to do a simple mysql search. there is also a tutorial on that: http://www.phpfreaks.com/tutorial/simple-sql-search
  13. hmm, never tried to use a key as a null value before... but yes $var[] will stack the value onto the end of the array. For numeric arrays, the key will just be the largest key +1. For an associative array, if you have no numbers as keys, the key will be zero. if you have a number, it will be the next increment. for example, the following code: <?php $array = array("hi" => "too", "toad" => "pond", "goop" => "test", 0 => "ddd"); $array[] = "dd"; foreach($array as $key => $value){ echo $key . " => " . $value . "<br />"; } ?> would output: hi => too toad => pond goop => test 0 => ddd 1 => dd (which I did verify on my test server) and yes, you can use null as a key and call it via $array[null] (which I tested also) hope that helps!
  14. oops syntax error $sql = "UPDATE dreamteam SET points = '$player_points', UPDATE_FLAG = 'Y', name = '$player_name', team = '$player_team' WHERE id = '$player_id'";
  15. I don't quite understand why you would want to keep the old results for a new search. Or even append the data from the old search to the new search. If you must though, there are multiple things you can do. You can store the search term as a session/get variable and append that to the $search variable
  16. there is a tutorial on this site for it: http://www.phpfreaks.com/tutorial/basic-pagination hope that helps
  17. no thats not right at all. do $sql = "UPDATE dreamteam SET points = '$player_points', UPDATE_FLAG = 'Y', SET name = '$player_name', SET team = '$player_team' WHERE id = '$player_id'";
  18. dont use document.write. it sucks. Instead make make a span or div tag, and use javascript to effect the innerHTML of the elemt. Something like <html> <head> <script type="text/javascript"> function calc (){ text = document.getElementById("text"); selection = document.getElementsByName("typeofbet"); for(i=0; i<selection.length; i++){ if(selection[i].checked == true){ var selected = selection[i].value; } } if(selected == "qualifier"){ qualifier(); }else{ if(selected == "freesr"){ sr(); }else{ if(selected == "freesnr"){ snr(); } } } } function qualifier (){ //document.write('this is the qualifier!'); text.innerHTML = 'this is the qualifier!' } function sr(){ // document.write('this is the sr!'); text.innerHTML = 'this is the sr!' } function snr(){ // document.write('this is the snr!'); text.innerHTML = 'this is the snr!' } </script> </head> <body> <form name="calcform"> <p> <input type="radio" name="typeofbet" value="qualifier" onClick="return calc();"> qual <input type="radio" name="typeofbet" value="freesr" onClick="return calc();"> sn <input type="radio" name="typeofbet" value="freesnr" onClick="return calc();"> snr </p> <span id="text"></span> </form> </body> </html>
  19. I don't think anyone said anything about a switch statement lol. at least i didn't
  20. well firstly, you could greatly reduce the size of that if statement by putting all the ids you want to check in an array, and using the in array function like $array = array("17", "19", "20", etc...); if (in_array($id, $array)){ //do whatever } I don't really get your question though. Can you try to explain again?
  21. I would do it by iterating through an array of email's, and emailing each one, one by one. but i've never done a mass email system before so i don't know if this is the best way Oh mardoxx beat me to it
  22. I don't really know what your saying at all... but you clearly don't understand session variables if you are having trouble understanding what the problem is with your script (especially since we explained it) OR you don't understand english very well (as evident by your speech) and can't really understand what i'm saying. Either try reading a tutorial on session variables and mysql results, or try a different, non-english board. best of luck
  23. the logic is that the session var isn't set to anything, because what you are trying to set it to doesn't exist. I'm suprised you don't get a syntax error on your log in page. session_start(); require_once("connect.php"); if(!isset($_SESSION["username"])) { header('Location: login.php'); exit; } ?> this is perfectly fine, the problem lies in your login script: <?php // we must never forget to start the session session_start(); if (isset($_POST['username']) && isset($_POST['password'])) { $username = mysql_real_escape_string($_POST['username']); $password = mysql_real_escape_string($_POST['password']); require_once("connect.php"); // check if the user id and password combination exist in database $query = "SELECT username FROM members WHERE username = '$username' AND password = '$password'"; $row = mysql_query($query) or die ("Error - Couldn't login user."); if (mysql_num_rows($row) == 1) { // the user id and password match, // set the session $_SESSION[username] = $row[username]; // after login we move to the main page echo "Welcome $username! You've been successfully logged in."; exit(); } else // bad info. { echo "Error - Couldn't login user.<br /><br /> Please try again."; exit(); } } ?>
  24. Warning: copy(Resource id # [function.copy]: failed to open stream: No such file or directory in /var/www/vhosts/automobilesdmr.com/httpdocs/administration/head.php on line 109 that means the directory you are trying to write to doesn't exist Warning: imagejpeg() [function.imagejpeg]: Unable to open 'Resource id #8' for writing in /var/www/vhosts/automobilesdmr.com/httpdocs/administration/head.php on line 97 this i believe means you don't have to correct rights to write data to that file.
  25. if(!isset($_SESSION['my_session_variable'])){ die("YOU AINT LOGGED IN"); } include that on pages you want to protect
×
×
  • 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.