Jump to content

jcbones

Staff Alumni
  • Posts

    2,653
  • Joined

  • Last visited

  • Days Won

    8

Everything posted by jcbones

  1. Auto-increments wouldn't work, as it will just be inserted since the value would be incremented. At this point, the easiest thing to do, is change your first query. $check = mysql_query("SELECT week_id,game_id FROM schedule"); //to $check = mysql_query("SELECT week_id FROM schedule WHERE week_id = '$week' AND game_id = '$game'"); //next change your if statement to: if(mysql_num_rows($check) > 0) Should fix you up.
  2. Did you try it? Just copy paste it into a file, name it with a php extension and see it work. The only thing it will not do, is keep counting after the countdown expires. If you think you would like something like this, I would see about modifying it for you.
  3. echo the query, and paste it into myAdmin or whatever you use. See if it works.
  4. What error did mysql_select_db() return? BTW $extract = mysql_query($rs); //should be: $extract = mysql_fetch_assoc($rs); //because mysql_query returns a resource result, and the fetch functions return array's
  5. First try wrapping your email function in an if statement, this will tell you if an error occurred with the function. if(!mail($to, $subject, $body, $headers)) { trigger_error('Mail Function Failed'); } Next: Are you on a shared host? Does your host allow emails from accounts not hosted on their server. Most shared host does not. Which means that your FROM header must have an account that resides on the SMTP server.
  6. Do you have de-bugging turned on in your db class? Does it even have de-bugging?
  7. Is week_id your primary key? If so, you could just run the query like: $sql = "INSERT INTO schedule (week_id,game_id,date,H_team,A_team) VALUES('$week','$game','$date','$hometeam','$awayteam') ON DUPLICATE KEY UPDATE game_id = VALUES(game_id), date = VALUES(date), H_team = VALUES(H_team), A_team = VALUES(A_team)"; mysql_query($sql) or trigger_error($sql . ' has encountered an error: <br />' . mysql_error()); Then you wouldn't need if statements, nor would you need your first query. This will insert the data unless it encounters a duplicate primary key. If it encouters the duplicate key, it will update the row with the new data. UN-TESTED1
  8. Use Javascript
  9. Here is a PHP/Javascript countdown. After the countdown expires, it resets on the next page load. Modification would be required (shouldn't be hard). <?php session_start(); $timestamp = time(); $diff = 30; //<-Time of countdown in seconds. ie. 3600 = 1 hr. or 86400 = 1 day. //MODIFICATION BELOW THIS LINE IS NOT REQUIRED. $hld_diff = $diff; if(isset($_SESSION['ts'])) { $slice = ($timestamp - $_SESSION['ts']); $diff = $diff - $slice; } if(!isset($_SESSION['ts']) || $diff > $hld_diff || $diff < 0) { $diff = $hld_diff; $_SESSION['ts'] = $timestamp; } //Below is demonstration of output. Seconds could be passed to Javascript. $diff; //$diff holds seconds less than 3600 (1 hour); $hours = floor($diff / 3600) . ' : '; $diff = $diff % 3600; $minutes = floor($diff / 60) . ' : '; $diff = $diff % 60; $seconds = $diff; ?> <div id="strclock">Clock Here!</div> <script type="text/javascript"> var hour = <?php echo floor($hours); ?>; var min = <?php echo floor($minutes); ?>; var sec = <?php echo floor($seconds); ?> function countdown() { if(sec <= 0 && min > 0) { sec = 59; min -= 1; } else if(min <= 0 && sec <= 0) { min = 0; sec = 0; } else { sec -= 1; } if(min <= 0 && hour > 0) { min = 59; hour -= 1; } var pat = /^[0-9]{1}$/; sec = (pat.test(sec) == true) ? '0'+sec : sec; min = (pat.test(min) == true) ? '0'+min : min; hour = (pat.test(hour) == true) ? '0'+hour : hour; document.getElementById('strclock').innerHTML = hour+":"+min+":"+sec; setTimeout("countdown()",1000); } countdown(); </script>
  10. Start Here Then Go here Of course, when you get stuck, post the code that is troubling you.
  11. You can add the comma's back in using number_format().
  12. PHP doesn't allow mysql_query() to perform multiple queries (ironically, it says so at the top of the page in the manual). However, it will handle JOIN queries quite well.
  13. NO, MySQL is not PHP. They use MySQL. MySQL Date/Time functions
  14. Have you tried sending the post data to a full url, and not just a relative file? example: //instead of xhr.open("POST", "send_post.php", true); //try xhr.open("POST", "http://mysite.com/full/path/to/send_post.php", true);
  15. Here is your file, as you posted it, commented the way it is written, there are a few glaring problems with the logic of it. <?php $name8 = file_get_contents("test/special8name.txt"); //retrieve file as string date_default_timezone_set ( "America/New_York" ); //set timezone to Eastern. $gethour = date("H"); //get 24 hour clock "hour". $getminutes = $gettimedate["minutes"]; //there is not an array called $gettimedate set. $gettimedate = date(); //date must have a string format, cannot pass without argument. $hourmin = $gethour . $getminutes; //contantenate the hour and minutes(minutes will be 0, as it will return false on an array index.) $currentday = date("l", time()); //return full text day of week, do not need second argument, as date() returns current timestamp. $currentdate = date("M j, Y"); //3 letter month, 1-31 no leading 0's, 4 number year, on current timestamp. if ($hourmin < 1500 && $currentday <> "Saturday" && $currentday <> "Sunday") { //if hour + minutes is less than 1500, and current dayis greater than/less than Saturday, and currentday is greater than/less than Sunday. echo "<span class=\"namesred\">$name8 </span>"; //echo the file contents in class of namesred. } else if ( $hourmin > 1500 && $hourmin < 2300 && $currentday <> "Saturday" && $currentday <> "Sunday") { //if hour + minutes is greater than 1500, and hour +minutes is less than 2300, and currentday is greater than/less than Saturday, and currentday is greater than/less than Sunday. echo "<span class=\"namesblue\">$name8 </span>"; //echo the file contents in class namesblue } else if ( $currentday == "Saturday" or $currentday == "Sunday") { //if currentday is equal to Saturday, or currentday is equal to Sunday echo "<span class=\"namesblue\">$name8 </span>"; //echo file contents in class namesblue. } ?> Compare the logic to this. <?php $name8 = file_get_contents("test/special8name.txt"); //retrieve file as string date_default_timezone_set ( "America/New_York" ); //set timezone to Eastern. $hourmin = date("Hi"); //get 24 hour clock "hour" and 'minutes'. $currentday = date("l"); //return full text day of week $currentdate = date("M j, Y"); //3 letter month, 1-31 no leading 0's, 4 number year, on current timestamp. if ($hourmin < 1500 && $currentday != "Saturday" && $currentday != "Sunday") { //if hour + minutes is less than 1500, and current day is not Saturday, and currentday not Sunday. $class = 'namesred'; //set class name } else if ( $hourmin > 1500 && $hourmin < 2300 && $currentday != "Saturday" && $currentday != "Sunday") { //if hour + minutes is greater than 1500, and hour +minutes is less than 2300, and currentday is not Saturday, and currentday is not Sunday. $class = 'namesblue'; //set class name } else if ( $currentday == "Saturday" || $currentday == "Sunday") { //if currentday is equal to Saturday, or currentday is equal to Sunday $class = 'namesblue'; //set class name } echo "<span class=\"$class\">$name8 </span>"; //echo file contents, with correct class name. ?>
  16. You are looking for the full path, and not just the current page. Try: if(__FILE__ === '/blah/game/index.php')
  17. This: $price = explode('-',$_GET['price']); $query = "SELECT * FROM productfeed WHERE price between '$price' and '$price' LIMIT 0, 10"; Should be $price = explode('-',$_GET['price']); $query = "SELECT * FROM productfeed WHERE price between '$price[0]' and '$price[1]' LIMIT 0, 10";
  18. Try something like: (Pik's suggestion) foreach($_SESSION['post_data_array'] AS $seat) { $rowId = substr($seat, 0, 1); $columnId = substr($seat, 1); echo $rowId . $columnId . ", "; $sql[] = "('$book_id', '$rowId', '$columnId')"; } $sql125 = "INSERT INTO booked_seats(booking_id, row_id, column_id) values " . implode(',',$sql);
  19. Are there JS errors? Have you de-bugged it, (I usually use alert's to debug JS)? I bet you will find out that you are not getting the text from the text area. var post_text = document.getElementById('pp').value;
  20. You should try copying CV's code a little better. This: $price = explode($_GET['price']); Should be:
  21. Develop locally on your Windows Machine
  22. Are you saying that you wish to find employees, who's id's do NOT exist in CLID table?
  23. This is a simple problem. You are recounting your array, on each loop. So you will never get more than 3 returned values. On top of this, you are removing the array keys, but you aren't re-ordering the keys. So, at times your array keys would look like $qwe[0], $qwe[2], $qwe[4]. Now if the rand() function returned 3, you would get an un-defined index, because the key no longer exist in the array. Simple fix, is to run it through array_values, to re-order the keys. <?php $qwe = array('a','b','c','d','e'); for($i=0; $i<sizeof($qwe); $i++) { $asd = rand(0, sizeof($qwe)-1); $qwe = array_values($qwe); echo $qwe[$asd]; unset($qwe[$asd]); } ?>
  24. $first is undefined. So you don't actually have a filename for you XML 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.