Jump to content

Barand

Moderators
  • Posts

    24,563
  • Joined

  • Last visited

  • Days Won

    822

Everything posted by Barand

  1. No quotes if numeric value, and $category_id probably is, as is the $price
  2. $fleetarray[$a]["w$b"]
  3. You won't know if there is an error unless you echo the message
  4. You could use a query like this SELECT user , GROUP_CONCAT(short_link) as short_links , server , format , SUM(size) as size , resolution FROM table_name WHERE type = 'tutorials' and type2='word' and video_id='01' GROUP BY user, server However, your sizes need to be stored as INT (eg value 100) and not as VARCHAR (eg value 100MB) When processing, explode the "short_links" field.
  5. simpler alternative <form id="inputForm" name="inputForm" method="POST" action="code-login.php"> <p>Grab some coffee: <input type="text" name="input[]" size="2" /> <input type="text" name="input[]" size="2" /> <input type="text" name="input[]" size="2" /> <input type="text" name="input[]" size="2" /> <input type="submit" value="Crack the Code!" /> </p> </form> then <?php $correct = array ('##', '##', '##', '##'); if (isset($_POST['input'])) { if ($_POST['input'] == $correct) { header("Location: http://www.someotherpage.com/"); exit; } else { echo "Code is incorrect<br>"; } } ?>
  6. The best method is don't use dynamic tables. Use a single table with the date in the records.
  7. One way (anniversaries in the next seven days) SELECT thedate FROM dates WHERE DATE_FORMAT(thedate,'%m%d') BETWEEN DATE_FORMAT(CURDATE(),'%m%d') AND DATE_FORMAT(CURDATE() + INTERVAL 7 DAY,'%m%d') edit : caution - it won't work if 7-day range spans year end
  8. check for errors $sql = "SELECT * FROM table WHERE id=$id"; $res = mysql_query($sql); if (!$res) die(mysql_error());
  9. See web_craftsman's reply $sql = "SELECT * FROM table WHERE id=$id"; $res = mysql_query($sql);
  10. 1. Use code tags (or <> button) when posting code. 2. post the actual error message
  11. try <?php session_start(); $cal = ""; if(isset($_GET["cal"]) and isset($_GET["num1"]) and isset($_GET["num2"])) { if ( $_GET["cal"] == "+" ) $cal = $_GET["num1"] ."+". $_GET["num2"] ."=".(($_GET["num1"] + $_GET["num2"])); elseif ( $_GET["cal"] == "-" ) $cal = $_GET["num1"] ."-". $_GET["num2"] ."=".(($_GET["num1"] - $_GET["num2"])); elseif ( $_GET["cal"] == "/" ) $cal = $_GET["num1"] ."/". $_GET["num2"] ."=".(($_GET["num1"] / $_GET["num2"])); elseif ( $_GET["cal"] == "*" ) $cal = $_GET["num1"] ."*". $_GET["num2"] ."=".(($_GET["num1"] * $_GET["num2"])); $_SESSION['results'][] = $cal; // store in session array } ?> <!DOCTYPE html> <html> <head><title> test </title> </head> <body> <h1> Enter Comment </h1> <form action="" method="get"> Number1: <input type="text" name="num1"> Number2: <input type="text" name="num2"> <select name="cal"> <option value="+"> + </option> <option value="-"> - </option> <option value="/"> / </option> <option value="*"> * </option> </select> <input type="submit" value="Do Math"> </form> <?php // print stored session array if (isset($_SESSION['results'])) { foreach ($_SESSION['results'] as $res) { echo $res . '<br>'; } } ?> </body> </html>
  12. Just replace the single array element if(empty($details_array["propview"])) { $details_array["propview"] = "No Contingencies"; }
  13. No, they shouldn't. An id is a unique identifier for a record, not a sequence number, and should not change for the life of that record. Nor should the ids of deleted records be reallocated to new records. If you need to maintain the sequence that that the records were added use something else, like a timestamp.
  14. mysql_fetch_array Plenty of examples
  15. You would select the data with a WHERE clause such as "WHERE datefield BETWEEN CURDATE() - INTERVAL 30 DAY AND CURDATE()". How you then store the results for a graph would depend on the requirements of the software you are using to produce the graph
  16. something like this? SELECT SUM(IF(shift_id IN (1,3,5), IF(shift_id=5, compound_output/2,compound_output),0)) as val1, SUM(IF(shift_id IN (2,4,5), IF(shift_id=5, compound_output/2,compound_output),0)) as val2 FROM op_output;
  17. Use a while() loop $result = mysql_query($query) or die(mysql_error()); while ($row = mysql_fetch_array($result) ) { echo ... }
  18. Better to check if it is set also $par = (isset($_GET['par1']) && !empty($_GET['par1']) ) ? $_GET['par1'] : 4;
  19. You should check the output from mysql_error() function and you will find you have a syntax error in the query. "TO" is a mysql reserved word. If you must use it as a column name it needs to be inside backticks (`to`)
  20. Jessica's CRUD tutorial should be of help http://thewebmason.com/php-mysql-crud-tutorial-using-pdo-create-read-update-delete-part-4-delete/
  21. "desc" is a reserved MySql word. Either change it (recommended) or enclose it in backticks in your queries eg `desc`
  22. you have mysql_select_db("jobs"); you need to select the database that contains the jobs table
  23. You are testing for missing fields before you get the values from the POST array
  24. You could try using realpath
  25. Error in this line <input type=expiry name= maxlength=15 size=15><br /><br /> Also values should be quoted eg type="text" But your main problem is that your reference book seems to be 10 years out of date (look up register_globals) and you need to pick up the posted values from the $_POST array $title = $_POST['title']; etc
×
×
  • 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.