Jump to content

Philip

Staff Alumni
  • Posts

    4,665
  • Joined

  • Last visited

  • Days Won

    20

Everything posted by Philip

  1. You'd need to create a custom PHP script that the cron runs. This would need to keep track of where the last cron job left off (thus where it should start) and then contain the loop. I'd just setup the cron via cPanel.
  2. header("Location:...");? Sorry - misread part of your question. When they visit the login page, you could have the link like: login.php?redirect=members - Then pull the redirect page by $_GET['redirect'] and act accordingly.
  3. A cron would work, maybe not the best solution but it would work.
  4. zomg NINJA!
  5. Without specifics of what you'd like to do to your data, it is hard to give the best solution for your needs. If you do keep looping it the way you are, you need to make sure to give your server some breathing time every couple of thousand rows.
  6. Well, for your example this one query would do the trick: INSERT INTO otherTable SELECT (num1/2) as num1, (num2+5) as num2, (num3*10) as num3 FROM firstTable num1 num2 num3 56 23 54 123 486 123 48 34 123 6456 321 6 65 1 23 564 123 123 46 89 654 456 231 564 489 65 2389 8956 56 23 Then after the query, the second table: num1 num2 num3 28 28 540 62 491 1230 24 39 1230 3228 326 60 33 6 230 282 128 1230 23 94 6540 228 236 5640 245 70 23890 4478 61 230
  7. His computer probably melted itself after clicking "Post"
  8. @AwptiK: Actually, echo "$variable" is okay, as double quotes (") will parse variables. Single quotes (') will not and will treat anything in them as a string. @Garethp: which quotes are you referring to? @OP: What is it doing? Does it show the thank you page, but doesn't send the email?
  9. It's all about word of mouth about the price to quality of your services & presentation of yourself. I've done some work for local clients, and when someone asked about their website, they have always referred them to me. Personally, I prefer working for local clients because the communication piece is so much easier, I mean if I have a question or presentation I don't have to worry about any time zone changes, I can swing by their office, etc. I know of a few people that have posted on here, proved that they have quality work, and were offered a couple of jobs.
  10. some people enjoy the breeze
  11. http://www.php.net/manual/en/outcontrol.configuration.php
  12. I spot some problems with your php, but it shouldn't break it: if($_POST[detail_descrip]) { $_SESSION[add_out][detail_descrip] = $_POST[detail_descrip]; } You need session_start() and make sure to use quotes around the key names (unless you defined a constant with that name). Otherwise it'll throw a notice. <?php session_start(); if($_POST['detail_descrip']) { $_SESSION['add_out']['detail_descrip'] = $_POST['detail_descrip']; }
  13. Or place a <?php tag inside of the tags. <?php echo $test; # colored... ?>
  14. your text OR http://google.com your text OR http://google.com
  15. <?php $con = mysql_connect("localhost", "Username", "Password") or die('Could not connect: ' . mysql_error()); mysql_select_db("DB_Name", $con); $sql = " SELECT title, poster, text, time, date FROM `news` LIMIT 0, 30 "; $result = mysql_query($sql) or die (mysql_error()); $results = array(); // initialize the array while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { // create a new element in the results array, and set the mysql row to it $results[] = $row; } // now we need to loop through each of the array elements. foreach($results as $row) { // you can call the value like $row['name'] $text = stripslashes($row['text']); $title = stripslashes($row['title']); $text = wordwrap($text, 15, "<br/>\n"); echo "<font size='4'><b>$title</b></font><br>"; echo "Posted by {$row['poster']} "; echo "on {$row['date']} at {$row['time']}<br>"; echo "$text"; } ?> See the comments in the code
  16. Very true
  17. Each time you loop through your results, you're overwriting the variable's value. You should either use an array and save the results, or print from the loop itself.
  18. At a quick glance it looks like your column names (some, not all) are reserved words. You should encase them in backticks (`) http://dev.mysql.com/doc/refman/5.1/en/reserved-words.html
  19. You could use eval (and the following code takes into consideration the difference between comparison & arithmetic operators.) <pre><?php function evaluate($value1, $operator, $value2) { if(in_array($operator, array('+','-','*','/','%'))) $t = 'return '.$value1.$operator.$value2.';'; else $t = 'if('.$value1.$operator.$value2.') {return true;} else {return false;}'; return eval($t); } var_dump(evaluate(3, ">", 1)); var_dump(evaluate(3, "==", 1)); var_dump(evaluate(3, "+", 1)); var_dump(evaluate(3, "-", 1)); var_dump(evaluate(3, "/", 1)); var_dump(evaluate(3, "%", 1)); ?></pre> Outputs: I'll be happy to add comments if you'd like. (edit for adding case examples)
  20. It should automatically convert the space to an underscore.... at least with my tests it does. If you do a print_r($_POST); it will show the key name.
  21. Okay - if($value == $name){ Again, $value will be a mysql resource, not the value from the database. You need to call mysql_fetch_assoc to get the name... or just use the number of rows returned to see what you should do. if($player['points'] == 0){//Check if player has zero points thus spectating. $name = $player['name']; //var for the players name // put the value in the query - and you can limit the number of results since you're just checking to see if that name exists $value = mysql_query("SELECT name FROM idlers WHERE name='".mysql_real_escape_string($name)."' LIMIT 1"); // get the number of rows returned $num_rows = mysql_num_rows($value); echo "Got name from DB"."<br>"; echo $player['points']."<br>"; echo $player['name']."<br>"; echo $value."<br>"; // If the number of rows returned is greater than 0 - the name is in use. if($num_rows > 0 ){ //Check if name already has entry $ptime = mysql_query("SELECT lasttime FROM idlers WHERE name='".mysql_real_escape_string($name)."' LIMIT 1"); echo "Get previous time"."<br>"; //Retreives the last max idle time $connection = $player['connected']; $time = substr($connection, 0, 1);//Converts time in min $time = $time * 60; $time2 = substr($connection, 3, 4); $time = $time.$time2; //Retreives total idle time so far. $ttime = mysql_query("SELECT totaltime FROM idlers WHERE name='".mysql_real_escape_string($name)."' LIMIT 1"); echo "Get total time"."<br>"; if ($ptime <= $time){//Check if last idle is larger than current idle. //If true they are continuing their current idle //Add Current time - Counted time to Previous Total $ttime .= $time - $ptime; } else{ //Add current time to total time. $ttime .= $time; } //Update totaltime MYSQL_QUERY("UPDATE idlers SET time=".$ttime." WHERE name=".$name) ; //Sets new max idle time to current idle time MYSQL_QUERY("UPDATE idlers SET lasttime=".$time." WHERE name=".$name); } else{//Create a new table entry with the correct data. echo "Creating new entry"."<br>"; $time = substr($player['connected'], 0, 1) * 60;//Converts time in min $time .= substr($player['connected'], 3, 4); $name = $player['name']; $ttime = $time; $ptime = (int)$time; $result=MYSQL_QUERY("INSERT INTO idlers (totaltime, time, name, lasttime) VALUES ('$ttime','$time','$name','$ptime')"); echo "Created new entry"."<br>"; } } Now, looking at the rest of your code, you're not using mysql_fetch_assoc/array - so $ptime and $ttime are both going to be resources not values to compare.
  22. Unless you created your own version of the function mysql_query, you're not using it properly. It looks like you're trying to use mysql_query as a (s)printf, or prepared statement. You're also trying to pull the value of the mysql_query (which will return a resource, not a value) when you do echo $value."<br>"; Change: $value = MYSQL_QUERY("SELECT name FROM idlers WHERE name='%s'", mysql_real_escape_string($name)); to: // put the value in the query - and you can limit the number of results since you're just checking to see if that name exists $value = mysql_query("SELECT name FROM idlers WHERE name='".mysql_real_escape_string($name)."' LIMIT 1"); // get the number of rows returned $num_rows = mysql_num_rows($value); // show number echo $num_rows;
  23. It is because when PHP reads the code, it sees it like this: someFunction()$var = 'blahh'; when it should be: someFunction();$var = 'blahh'; Remember, a semicolon means end of that line.
  24. Please post the full error, with a few lines before/after the specified line in the error.
  25. Ohhh i7, nice! Do you like it? I thought I posted my specs, but I guess not... so..... AMD Phenomx4 9850BE ASUS MVP Deluxe CoolerMaster 850WT (don't know exact model off the top of my head) 4x Patriot DDR2-8500 2GB sticks (8GB total) GeForce 8800GTX (768MB) Cheap 250GB WD hdd I pulled from my last pc - I have a 1TB that has Win7 on it, but I think I'm going to wipe that because I never use 7beta Windows Vista Business SP1 1x 21" LCD, 1x19" LCD
×
×
  • 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.