Jump to content

Jeremysr

Members
  • Posts

    199
  • Joined

  • Last visited

    Never

Everything posted by Jeremysr

  1. Maybe reading it this way will help you understand it? $data['blue'] = 90; $data['white'] = 40; $data['red'] = 20; $options['width'] = 300; $options['height'] = 40; $graph = lwtMiniHorizontalBarChart($data, $options); echo $graph;
  2. PHP has an XMLReader that can be used to easily read XML. I think that would be a much better choice for this.
  3. Table names are case-sensitive, so 'usersid' is different than 'usersID'. You'll have to access the value like this: $row['usersID']
  4. Change this: $team = $_GET['team']; To this: $team = $_POST['team'];
  5. It looks like there is no `usersid` column in your table. This is why writing out all your column names that you want to select is a good idea: $query=" SELECT usersid, username, date FROM $tbl_name limit $eu, $limit "; Now if the `usersid` column doesn't exist, you'll get an error saying so.
  6. In your while loop, build a string which you will be the body of your e-mail: while($r1 = mysql_fetch_assoc($sql1)) { $pin_id = $r1['pin_id']; $pin_number = $r1['pin_number']; $email_body .= "Pin ID: $pin_id Pin Number: $pin_number"; } @mail($mail_to, $email_subject, $email_body,$from); Something like that.
  7. You can't use variables defined outside of your function inside your function, like $connection. You have to make it global like this: function read(){ global $connection; global $idstatus; mysql_query("UPDATE table SET on = '1' WHERE id = $idstatus", $connection) or die("Error querying database. Please contact the webmaster about this issue."); header('Location: example.php'); } Also you should try to use as few globals as possible. Making your $connection global might be an exception, but you'll probably want to pass your $idstatus as an argument into the function.
  8. Apparently there is no case-insensitive flag for glob() so what I would do is this: $images = array_merge(glob($directory . "*.jpg"), glob($directory . "*.JPG"));
  9. 1. I can't read the code because it's all over the place... please indent properly. 2. Use regex to validate e-mail addresses, here is a function that will return 1 if it's valid or 0 if it isn't: function is_email_valid($email) { return preg_match('/\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b/i', $email); } This regex is from the homepage of http://regular-expressions.info .
  10. You could store the $_POST variables as $_SESSION variables on the first entry, and then stop using $_POST when refreshing. You'd put something like this at the top of your script: session_start(); if ($_POST) { $_SESSION['blah'] = $_POST['blah']; $_SESSION['bleh'] = $_POST['bleh']; // "Refresh" the page without POSTage. Your $_POST variables are safely stored in $_SESSION header('Location: this_page.php'); die; } $blah = $_SESSION['blah']; $bleh = $_SESSION['bleh']; // your script continues here...
  11. Jeremysr

    $dot%12

    Ok, the $dot is the number of dots that the script will display. The $opt tells the script if it's still in progress or whatever. The <META> tags will cause the page to refresh and will pass $opt and $dot in the URL: echo "<META HTTP-EQUIV=\"refresh\" content=\"10;URL=blastresult.php?jobid=$jobid&alignmentView=$alignmentView&opt=wait&dot=$dot\">"; It looks like for each page refresh, the value of $dot will be incremented by 1, which causes the nice effect of a row of twelve dots animating like this: $dot = 0: $dot = 1: . $dot = 2: .. $dot = 3: ... $dot = 4: .... $dot = 5: ..... $dot = 6: ...... $dot = 7: ....... $dot = 8: ........ $dot = 9: ......... $dot = 10: .......... $dot = 11: ........... $dot = 12: $dot = 13: . $dot = 14: .. So as $dot keeps incrementing, each page refresh will show one more dot, until it gets to 12, when the number of dots goes back to zero.
  12. Google it: http://google.com/search?q=mysql+tutorials You'll find all sorts of tutorials and documentation for MySQL. Yep, it is.
  13. It sounds like changing your MySQL query to only select "distinct" locations is what you want: $query="SELECT DISTINCT location FROM jb"; This will not give you any duplicate location fields.
  14. Jeremysr

    $dot%12

    If the URL is 'http://yoursite.com/result.php?dot=3' then $dot will have the value 3 (by getting it from $_GET['dot']). This way you could make a link to result.php and pass a number as the $dot value to it. The % is the modulus operator, as IchBin said. It returns the remainder of dividing the number on the left by the number on the right. It is useful for taking a number that could be a very large number and reduce it to a smaller range of values. For example: 0 % 12 == 0 1 % 12 == 1 2 % 12 == 2 ... 10 % 12 == 10 11 % 12 == 11 12 % 12 == 0 13 % 12 == 1 14 % 12 == 2 ... 22 % 12 == 10 23 % 12 == 11 24 % 12 == 0 As you can see, if the number on the left is less than the number on the right, the result is always the number on the left. So what that 'for' loop is doing is looping from the number zero to a number less than twelve, depending on what $dot is. It could be there to make sure that $dot is less than 12, but that wouldn't be a very good way of checking for that.
  15. I don't know too much either, but I know that it involves choosing two very large prime numbers and multiplying them together to get a very huge number. This very huge number will only have two factors, since the two numbers chosen were prime. Then something is done (mathematically) to the two factors to create a private and public key. These numbers are so huge that it would take billions of years for all the computers in the world to factor the number. (Or something like that... you get the idea.) I think the RSA algorithm is what I've been describing so you can learn more at that link.
  16. The only real optimization is that you only have to loop through the numbers 1 to the square root of the number you are factoring. If there was an easier way, many encryption algorithms would be broken since they depend on the fact that it is impossible for a computer to factor huge numbers in a short time. Here is a factoring function I wrote: function factor($x) { $factors = array(); $sqrt = sqrt($x); for ($i = 1; $i <= $sqrt; $i++) { if ($x % $i == 0) { array_push($factors, $i); array_push($factors, $x / $i); } } $factors = array_unique($factors); sort($factors); return $factors; }
  17. Change this: $query = mysql_query("UPDATE accounts SET accesslevel = 0 WHERE username = $account"); To this: $query = mysql_query("UPDATE accounts SET accesslevel = 0 WHERE username = '$account'"); Your query was causing an error, but you weren't checking if it was causing an error. You can check for an error by writing your mysql_query()'s like this: $query = mysql_query("UPDATE accounts SET accesslevel = 0 WHERE username = $account") or die(mysql_error()); Edit: and I'm guessing the reason mysql_affected_rows() wasn't zero was because of the SELECT query you did just before that. The UPDATE query had an error so it didn't change the number of affected rows from the last query.
  18. You're probably missing a closing brace somewhere. You need to indent your code better to catch this kind of error.
  19. The type int(5) only stores numbers. '03' is a string, not a number. It's a visual representation of the number three. To solve this, you can either change the type in the database to a varchar, or still store it as a number and convert it to a string with a leading zero after retrieving it from the database.
  20. You can change an integer to a string like this: $number = 3; $string = strval($number); // $string now equals "3".
  21. If I understand it correctly, you could do it like this: $start_date = mktime(0, 0, 0, 1, 11, 2008); $end_date = $start_date + (60*60*24); // Add one day $sql = "SELECT * FROM your_table WHERE the_date >= $start_date AND the_date <= $end_date";
  22. Whoops, should've tested my code. This is tested and works: $difference = ($target - $today); $months = floor($difference / 60 / 60 / 24 / 30); $days = ($difference / 60 / 60 / 24) % 30; $content = "$months months, $days days until";
  23. Assuming that a "month" is 30 days, you could do this: $difference = ($target - $today); $months = $difference / 60 / 60 / 24 / 30; $days = ($days / 60 / 60 / 24) % 30; $content = "$months months, $days days until ".$holiday;
  24. Variables are case-sensitive, make sure you put $newArray instead of $newarray.
  25. Try this regex: if (preg_match('/[^\x20-\x7e]/', $text) { // there are special characters in $text } The character class [^\x20-\x7e] matches all characters with ASCII codes less than 0x20 and greater than 0x7e.
×
×
  • 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.