Jump to content

kalivos

Members
  • Posts

    88
  • Joined

  • Last visited

    Never

Everything posted by kalivos

  1. I'm guessing something is wrong with your query. I would try changing the line with a query to: $FIND = mysql_query("SELECT * FROM userdata WHERE uename != '0'") or die( echo "Mysql Error: ".mysql_error() );
  2. One common overlook is if the page is being included in another page. Remember that session_start must occur before ANY output to the browser (including HTML). Check for whitespacing before your opening PHP tag. -Kalivos
  3. You need session_start() at the top of every page that uses sessions. -Kalivos
  4. It's getting late and my brain isn't all there at this hour, but I'll give this a shot... Do you have the same issue if you convert the do-while to a while? $courses_sql = "SELECT * FROM courses"; $courses_query = mysql_query($courses_sql) or die(mysql_error()); <ul><?php while ($rsCourses = mysql_fetch_assoc($courses_query)){ ?> <li><a href="menu.php?courseID=<?php echo $rsCourses['courseID']; ?>"> <?php echo $rsCourses['cName']; ?> </a></li> <?php } mysql_data_seek($courses_query, 0); ?> <?php while ($rsCourses = mysql_fetch_assoc($courses_query)){ ?> <li><a href="menu.php?courseID=<?php echo $rsCourses['courseID']; ?>"> <?php echo $rsCourses['cName']; ?> </a></li> <?php } mysql_data_seek($courses_query, 0); ?></ul> </html> -Kalivos
  5. I understand your thinking, but I don't think that will work in the current format. Lets break this into two pieces: if(($flight->deptime - date('G:i')) <= 1 / 60 * 15) 1) $flight->deptime - date('G:i')) This will round to a whole hour. If it's 8:50 - 8:45, it will return 0 (8-. If it's 09:00-8:55, it will return 1(9-. This does not return 00:05. 2) 1 / 60 * 15 This is the same as .25 Because the first part will round to an hour, it will only pass this test if the first part < .25 Because it will be a whole number, it will need to be 0 or a negative value to pass this test. -Kalivos
  6. You might have more luck at the Invision Power Board forums. Additionally, you can try moving this to the 3rd party PHP Applications forum. -Kalivos
  7. I'm going to make an assumption here. I'm going to assume that $flight->deptime returns in the format of date('G:i'). I wasn't sure how PHP handled subtraction in that format, so I wrote a small script. <?php $depart = "10:30"; $now = date('G:i'); //02:45 at time of writing echo $depart - $now; ?> The above code displayed 8. This is because PHP stops at a non-numeric value. It seems like it only calculates 10-02. To get around this, you can try using strtotime() example: $to_time=strtotime("2010-05-26 10:30:00"); $from_time=strtotime("2010-05-26 02:45:00"); echo round(abs($to_time - $from_time) / 60,2) Hope that helps, -Kalivos
  8. I'm surprised you don't get an error message $_POST[$_SESSION['username']=$username; Also, are you trying to compare or set the value here? (Do you need two equal signs?) if (!isset($_SESSION['username']) ||$_SESSION['username']=$username) { Edit: Don't know how I missed it, but your query is wrong as well. $query = "INSERT INTO event(eventa) VALUES ('"$_SESSION ["username"]'")"; It should be $query = "INSERT INTO event(eventa) VALUES ('".$_SESSION ['username']."')"; Hope that helps, -Kalivos
  9. You might have to send out the request headers 'header'=> "Accept-language: en\r\n". "Content-type: application/x-www-form-urlencoded\r\n", For another implementation, you can visit http://www.jonasjohn.de/snippets/php/post-request.htm -Kalivos
  10. MATCH...AGAINST is slow on larger datasets. For a school project, I don't think it's going to matter. Just something to keep in mind for later. You said it's not working. Have you echoed the SQL statements to verify that it's the statement you were expecting? I assume that a database connection is being made prior in the script. Have you tried executing your SQL directly with the database? Does it return the results you were expecting? What does the PHP script return? Error? Whitepage? More information is needed. -Kalivos
  11. Like thorpe stated, the correct code should be: <?php //INDEX session_start(); include 'connect.php'; ?> <center> <h1>lets hope it connects..</h1> </center><br><br> <link rel="stylesheet" href="style.css" type="text/css"> <?php if (isset($_SESSION['player'])) { $player=$_SESSION['player']; $userstats="SELECT * from database where playername='$player'"; $userstats2=mysql_query($userstats) or die("Could not get user stats"); $userstats3=mysql_fetch_array($userstats2); print "it worked =) <br> <a href=\"fight.php\">Kill A Creature!</a><br>"; if($userstats3[dead]=='Yes') { print "You're dead.<br>"; } } else { print "Sorry, not logged in please <A href='login.php' target="content.php">Login</a><br>"; } ?> Please read for future reference: http://gulati.info/2010/01/many-ways-to-integrate-html-into-php/
  12. I don't think you fully understand what cs.punk is trying to say. A session can use cookies. When you call session_start(), a cookie is created for you and sent to the client. For all intensive purposes, you no longer interact with that cookie. Like cs.punk was saying, you use $_SESSION to interact with the data. Anything you would have placed into a cookie, you now place into the session. Hope that helps, -Kalivos
  13. Assuming you are using MySQL, the timestamp format can vary depending on the version you are running. If you are just starting this project, I would suggest switching to datetime. If you wish to stick with timestamp, you can try the following: $sql = "SELECT * FROM `news` WHERE tstamp >= '2010-".$month."-01' AND tstamp <= '2010-".$month."-30'; There are several enhancements that you will probably want to do: Verify $month is a number in the range of 1-12 Verify that it is padded with a leading zero to make it two characters long Instead of using "30" as the last day, make it dynamic to the last day of the month (maybe 31 or 28). Here's a link to the MySQL docs page: http://dev.mysql.com/doc/refman/5.1/en/timestamp.html Hope that helps, -Kalivos
  14. Try this... <?php $limit = 2; $query_count = "SELECT count(*) FROM teachersname"; $result_count = mysql_query($query_count); $totalrows = mysql_num_rows($result_count); $page = trim(addslashes(strip_tags($_GET['page']))); if($page == "" OR !is_numeric($page)) unset($page); if(empty($page)){ $page = 1; } $limitvalue = $page * $limit - $limit; $query = "SELECT * FROM teachersname WHERE " . $_GET['field'] . " LIKE '%" . $_GET['finda'] . "%' LIMIT $limitvalue, $limit"; // echo $query; $result = mysql_query($query) or die("Error: " . mysql_error()); if(mysql_num_rows($result) == 0){ echo("Nothing to Display!"); } //check if the user entered data in the form if (isset($_GET['finda'])) { //data has been entered so lets search the mofo echo "<h2>Results</h2><p>"; // sanitise the data $find = trim(strip_tags(strtoupper($_GET['finda']))); //connect to the db //mysql_connect("localhost", "root", "winn3rs") or die(mysql_error()); //mysql_select_db("laptop_loan_database") or die(mysql_error()); //Now we search for our search term, in the field the user specified // $query = "SELECT * FROM teachersname WHERE " . $_GET['field'] . " LIKE '%$find%'" ; $data = mysql_query($query); //And we display the results while($result = mysql_fetch_array( $data )) { echo"<table width=\"200\" border=\"0\" class=\"border_bottom\"> \n"; echo "<tr> \n"; echo "<td> </td> \n"; echo "</td> \n"; echo "</tr> \n"; echo "<tr> \n"; echo "<td>"; echo "<strong>Client Name</strong>"; echo "</td>"; echo "<td width=\"75\" style =\"text-align: left\""; ?> <em><a href="search_client_details.php?recordID=<?php echo $result['Client']; ?>"><?php echo $result['Client']; ?> </a></em> <?php echo " </td> \n"; echo "</tr> \n"; echo "<tr> \n"; echo "<td>"; echo "<strong>Department Code</strong>"; echo "</td>"; echo "<td>"; echo "<em>"; echo $result['DepartmentCode']; echo "</em>"; echo "</td>"; echo "</tr> \n"; echo "<tr> \n"; echo "<td> </td> \n"; echo "</td> \n"; echo "</tr> \n"; echo "</table> \n"; echo"<br>"; } } //This counts the number or results - and if there wasn't any it gives them a little message explaining that $anymatches=mysql_num_rows($data); if ($anymatches == 0) echo "Sorry, but we can not finda an entry to match your query<br><br>"; if($page > 1){ $pageprev = $page-1; echo("<a href=\"$PHP_SELF&page=$pageprev\">PREV" .$limit."</a> "); }else{ echo("PREV" . $limit." "); } $numofpages = $totalrows / $limit; for($i = 1; $i <= $numofpages; $i++){ if($i == $page){ echo($i." "); }else{ echo("<a href=\"$PHP_SELF?page=$i\">$i</a> "); } } /* I'm not sure what this is for.... if(($totalrows % $limit) != 0){ if($i == $page){ echo($i." "); }else{ echo("<a href=\"$PHP_SELF?page=$i\">$i</a> "); } } */ if(($totalrows - $limit * $page) > 0){ $pagenext = $page+1; echo("<a href=\"$PHP_SELF?page=$pagenext\">NEXT" .$limit."</a>"); }else{ echo("NEXT" . $limit); $pagenext = $page+2; echo("<a href=\"$PHP_SELF?page=$pagenext&field=" . $_GET['field'] . "&finda=" . $_GET['finda'] . "\">NEXT" .$limit."</a>"); } ?> I also want to note that using the $i++ in the for loop is ok ;-)
  15. Your code uses the "++" syntax. You need to step away from using that in this script. An example of what to change: $pagenext = ($page++)+1; to this... $pagenext = $page+2; Post your new code so we can look over the changes you have made. -Kalivos
  16. I'm guessing that the error_report logs to a file that doesn't exist....
  17. Whats the function "error_report" do?
  18. I didn't know you could make a variable with the name of "for".
  19. First of all, you aren't checking if $page is passed to the script. Add this to the top somewhere $page = trim(addslashes(strip_tags($_GET['page']))); if($page == "" OR !is_numeric($page)) unset($page); Secondly.... change all the ++ and -- that are affecting $page. IE: $pageprev = $page--; This first evaluates and assigns a new value to $page, then places that value into $pageprev. This will mess up the page number. Instead, use "+ 1" in place of "++" and "- 1" in place of "--". There are more typos in the script, but hopefully this should get you started. Hope it helps, -Kalivos
  20. you can always check the page refer. just remember that not all browsers send the refer The best way to avoid xss is by validating user input at all times, not just via a form.
  21. If I'm reading this correctly... the checkbox name should be cid.
  22. Javascript/Ajax is the way to go on this... Here's a link to a javascript progress bar: http://www.dynamicdrive.com/dynamicindex11/xpprogressbar.htm
  23. If your having the user upload a file and it's causing an error before the file is uploaded... you can't operate on the file yet. You can only operate on the file after it has been uploaded. You might consider changing the 2M limit on the form and possibly your php settings if needed. -Kalivos
  24. Because nl2br ADDS a HTML line break and doesn't replace it, try the following... Replace this: $bio = nl2br($p['guests']['bio']); With this: $bio = str_replace(array("\r\n", "\r", "\n"), "<br />", $p['guests']['bio']); -Kalivos
  25. ermm set the directory in unset unset($some_dir."/".$file);
×
×
  • 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.