Jump to content

MmmVomit

Members
  • Posts

    319
  • Joined

  • Last visited

    Never

Everything posted by MmmVomit

  1. Now show us the code that calls that function.
  2. This syntax defines a function. function func_name() When you want to actually use, or call, a function, you use this syntax. func_name();
  3. I'm working on a site where people can post audition announcements. The problem I'm having is how I should categorize the auditions into usable groups. Here's my main problem. This site will be targeted specifically to singers. There is somewhat of a divide between opera singers and musical theater singers, such that an opera singer would not be interested in auditioning for Oklahoma, and a musical theater singer would not be interested in auditioning for Magic Flute. Singers I have talked to said that it would be a good idea to have separate sections of the site devoted to opera and musical theater However, there is a grey area. A company in the area does both opera and musical theater, and they hold one round of auditions for their entire season. What would be a good way of structuring my database such that it could take this into account?
  4. You can think of them like an if statement. ($expr ? $true_value : $false_value) $expr is some expression that will be evaluated as either true or false. If it is true, the whole expression in parentheses will evaluate to $true_value. If $expr is false, the whole expression in parentheses will evaluate to $false_value.
  5. Sorry, that should have been this. <?php ini_set('error_reporting', E_ALL); ?>
  6. Create an array called $sqldata. Make it a practice to only add escaped data to that array. Also make it a practice to only use $sqldata when building queries. Like so. <?php $var1 = "here's a string"; $var2 = "here's another string" // don't use mysql_escape_string. it is deprecated. // use mysql_real_escape_string instead. $sqldata['var1'] = mysql_real_escape_string($var1); $sqldata['var2'] = mysql_real_escape_string($var2); $query = "INSERT INTO table (col1,col2) VALUES ('$sqldata[var1]','$sqldata[var2]')"; ?>
  7. I don't have PHP on this computer. Would someone be willing to run the following script and see if it works? Pretty please? With a cherry on top? <html> <head> <title> Title </title> </head> <body> <form method="post" action=""> <select name="bar[]" multiple> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> </select> <input type="submit" name="submit" value="Submit" /> </form> <pre> <?php print_r($_POST); ?> </pre> </body> </html>
  8. Is this what you're trying to do? <?php function detect() { $counter=0; echo "</br>detect"; $result=mysql_query("SELECT * FROM result") or die('Query failed: ' . mysql_error()); while ($row = mysql_fetch_array($result,MYSQL_ASSOC)) { echo "</br>counter=$counter"; echo "</br>$row[Category]"; echo "</br>Drawdate in sql=$row[DrawDate]"; echo "</br>POST drawdate=$_POST[drawnumber]"; if ($row[Category]=='Magnum'&& $row[DrawDate]==$_POST[drawnumber]) { echo "if"; // return 1; }//end if else { echo "else"; continue; // return 0; } $counter++; }//end while return $counter; }//end detect() ?>
  9. Yep. If I had the code handy, I'd post it. It parses the raw post data from the file 'php://input'.
  10. If PHP encounters a fatal error, it will simply quit. Something like an undefined variable will just make the interpreter complain, and it will keep on processing the script, but there's a missing semicolon, the script will quit right there and not find errors further on in the script.
  11. You don't need to define an onclick function. Write a function with whatever name you feel is appropriate, then call that function from the OnClick attribute of the particular input field.
  12. If you have a form like this <form method="post" action="foo.php"> <select name="bar" multiple> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> </select> <input type="submit" name="submit" value="Submit" /> </form> Is there a way to properly retrieve the multiple selected items from the "bar" select box? If multiple options are selected, the $_POST variable only contains the last option selected. I've written a function myself that solves the problem, but was wondering if there is a way native to PHP, so I don't have to worry about having to put this function in every website I write.
  13. Put this as the first line in your script and let us know what happens. <?php ini_set('error_reporting', PHP_INI_ALL); ?>
  14. To start with, it sounds like you need the following tables. item find user Item will have one record for each individual item you want to track. ID number, maybe a description, etc. User will have user information, so you can track who has found what. This table may not be strictly necessary. Find will log where and when the different items were found and who found them. Is that enough to get you started?
  15. print "<input name=\"$row[id]\" type=\"checkbox\">";
  16. <? $sql = "SELECT fname, lname FROM admin ORDER BY `ID` DESC"; if ($result = mysql_query($sql)) { if (mysql_num_rows($result)) { while ($row = mysql_fetch_assoc($result)) { echo "<option value=\"$row[fname], $row[lname]}\">$row[fname], $row[lname]</option>"; } } } ?>
  17. <input type="text" name="name" value="<?=$your_variable?>">
  18. Yes, this is html. You either need to set the value attribute, or add a selected attribute to the proper element of a dropdown list.
  19. I wouldn't say any one function is better than another. One's a hammer, another's a screwdriver. Niether is better than the other, they're just suited to different jobs. If you tell us what you'd like to actually DO with an image, then maybe we can help you.
×
×
  • 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.