Jump to content

premiso

Members
  • Posts

    6,951
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by premiso

  1. That won't work. The times 12:33 + 10:45 would come out to 22:78. The script needs to account for times where the seconds and/or minutes would add up to more than 60 to add to the next higher increment Tested: function SumaHoras($time1, $time2) { list($hour1, $min1, $sec1) = explode(':', $time1); list($hour2, $min2, $sec2) = explode(':', $time2); $secs = ($sec1 + $sec2) % 60; $mins = ($min1 + $min2 + floor(($sec1+$sec2-$secs)/60)) % 60; $hours = ($hour1 + $hour2 + floor(($min1+$min2+floor(($sec1+$sec2-$secs)/60)-$mins)/60)); return sprintf("%s:%02s:%02s", $hours, $mins, $secs); } Nice, yea my mind isn't working today. Thanks for correcting that =)
  2. Ummm.... <?php if (!isset($_POST['submit']) || ($_POST['val1'] == "") || ($_POST['val2'] == "") || ($_POST['calc'] == "")) { header("Location: calculate_form.php"); exit; } if ($_POST['calc'] == "add") { $result = $_POST['val1'] + $_POST['val2']; } else if ($_POST['calc'] == "subtract") { $result = $_POST['val1'] - $_POST['val2']; } else if ($_POST['calc'] == "multiply") { $result = $_POST['val1'] * $_POST['val2']; } else if ($_POST['calc'] == "divide") { $result = $_POST['val1'] / $_POST['val2']; } echo 'My calculations returned: ' . $result; ?> That would be the proper way to do it. Is that giving you an error/notice? Chances are the book is just plain wrong. Programmers are not very good book writers.
  3. It is hard to determine that but: select artistName from artist where artistName LIKE 'es ' OR artistName LIKE ' es' Would/should work for just the ES, the % (wild) card is optional.
  4. Never even heard of it till now. have heard of it but don't know much about it - how woudl that work? http://www.w3schools.com/xsl/ Google is your friend.
  5. <?php if (!isset($_POST['submit']) || ($_POST['val1'] == "") || ($_POST['val2'] == "") || ($_POST['calc'] == "")) { header("Location: calculate_form.php"); exit; } if ($_POST['calc'] == "add") { $result = $_POST['val1'] + $_POST['val2']; } else if ($_POST['calc'] == "subtract") { $result = $_POST['val1'] - $_POST['val2']; } else if ($_POST['calc'] == "multiply") { $result = $_POST['val1'] * $_POST['val2']; } else if ($_POST['calc'] == "divide") { $result = $_POST['val1'] / $_POST['val2']; } ?> isset and using ' around array indexes should solve your woes.
  6. No. You can store them in an array by the id then do a key sort on that array. It will be 2 loops, but with flat files that is how it has to be done.
  7. return ($hour1 + $hour2) . ":" . ($min1 + $min2) + ceil(($sec1 + $sec2) / 60); Should work. Untested however.
  8. 1. No, I would actually make a constant out of it so you can define the subdirectory IE: $folder = ""; // optional used if your script is not in the root of the site. remember the ending slash define('DIR', $_SERVER['DOCUMENT_ROOT'] . "/" . $folder); define('DIR_INC', DIR . "includes/"); // your includes directory define('DIR_TEMP', DIR . "templates/"); // your templates directory Etc etc. Then you would call it like: <?php include_once('constants.php'); // so we have are variables include(DIR_INC.'header.php'); ?> 2. It is user preference. However you want to do it is the way you should do it. 3. You do not want to use that as it is a sign of poor programming. If you code everything right there is no need to add that extra step in there. Output code only when you are ready to output not just randomly.
  9. CRON job on UNIX or Scheduled task on Windows. Create a script that runs once a week and have it wipe the hit counter clean. If you want more help post some code....something cause right now your question is way too vague.
  10. It would be much easier to do it this way: echo " <tr> <td> <input name=\"cat_id[]\" type=\"hidden\" value=\"$category_id\"> <input name=\"cat_name[]\" type=\"text\" value=\"$category_name\" /> </td> </tr> "; foreach ($_POST['cat_id'] as $key => $id) { $query = "UPDATE ".$_POST['table']." SET category_name='".$_POST['cat_name'][$key]."' WHERE category_id='".$id."'"; $result = mysql_query($query) or die("Couldn't update category." . mysql_error()); } Although I am confused why you would pass the table name via post. That is a massive potential security flaw.
  11. google jQuery it is a framework that will make AJAX 100times simpler and I am sure there is code made to do what you want already.
  12. Aside from what flyhoney said, you did not change line 9 to be the new line that he wrote. mysql_query("DELETE FROM orders WHERE order_id=" . mysql_real_escape_string($_GET['order_id'])); That is what it should be, not the one you have.
  13. Show us the full code. And highlight line 9 in some way and use the [ code] and [ /code] tags (without the initial space).
  14. // Perform Query $result = mysql_query("SELECT * FROM hightrek", $connection); Will fix that error.
  15. <?php $domainCheck = "http://anotherdomain.com"; $codeToCheck = '<img src="http://www.my-domain.nl/images/29092008.jpg" width="60" height="60" />'; $html = file_get_contents($domainCheck); if (stristr($html, $codeToCheck) !== false) { echo 'Success, they have the code'; }else { echo 'Failed, no code found.'; } ?> Simple as that. Note the img code must be exactly like that or it will return false.
  16. Post line 48-68 for us to better help you. And a google of the error: http://the-stickman.com/web-development/php/php-505-fatal-error-only-variables-can-be-passed-by-reference/ That should explain what is happening better.
  17. $data = mysql_query("SELECT * FROM userdata WHERE username = '".$username."'") or die(mysql_error()); if (mysql_num_rows($data) < 1) echo $username . ' could not be found.';
  18. $fileDir = "http://www.xyz.local"; // supply a path name. Since you add an ending slash in the $fileString, do that. Also echo out the $fileString to make sure that path is being populated right. Some debugging would have caught that. ALso this line: $fileName = "index.php."; // supply a file name. Should be: $fileName = "index.php"; // supply a file name. No ending period. What is the end result that you want from $fileString? Like how should that string look?
  19. Are you sure it is a bot? If it is a bot, chances are it is reading the image. You could try to do Re-Catcha (google it for more info) and see if that stops them.
  20. They would not, since you are not referencing the array by "MKX" you are referencing it by index (0,1,2).
  21. You can, it is just about 5times more work. I would add the extra columns art needs to the table, add the datatype column then go from there. That way you can order it by type, name a certain column etc and filter it that way too. This will also save coding time down the line as you just need basic 1 query to do it all and just have the datatype field on the php page be dynamic to what you want.
  22. It is the same. PHP does pre processing and then generally displays html to the page. Which that would be the correct way to display the email in html on the page.
  23. Here is the question. If all the data is the same why have 3 tables? Why not add another column to the table called datatype if this is 1 it is a toon if it is a 2 it is art etc etc. Make it a lot simpler especially for retrieving data.
  24. Nest the queries... Not sure if this is the best way, but yea. <?php $query = mysql_query("SELECT * FROM user_games WHERE status = 'approved'"); $i=0; $data=array(); while ($row = mysql_fetch_assoc($query)) { $data[$i]['user_games'] = $row; $i++; } $i=0; $query2 = mysql_query("SELECT * FROM user_toons WHERE status = 'approved'"); while ($row2 = mysql_fetch_assoc($query2)) { $data[$i]['user_toons'] = $row2; $i++; } $i=0; $query3 = mysql_query("SELECT * FROM user_toons WHERE status = 'approved'"); while ($row3 = mysql_fetch_assoc($query3)) { $data[$i]['user_art'] = $row3; $i++; } print_r($data); ?> But each table data will not necessarily be related to each other. Is there a way that each table is related, or did you just want to show random data together ? EDIT: Fixed my logic.
  25. mysql_insert_id should do it.
×
×
  • 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.