Jump to content

Jessica

Staff Alumni
  • Posts

    8,968
  • Joined

  • Last visited

  • Days Won

    41

Everything posted by Jessica

  1. I do! I take a few short breaks for stuff, like meetings or whatever. Although now if I sit through a meeting more than an hour I have to stand up.
  2. I think he said he hardcoded the 333 value in, but do you think if the 333 was copied/pasted from something it could have the non printing character still?
  3. You're sure it's the same database? IE, you don't have a prod/dev database either on same or different servers, with similar names? I had the same problem last week and after 2 hours of working on it figured out someone had made a copy of the DB with a misspelled name with one letter off, and in phpMyAdmin I was looking at the misspelled one (simply because it was first in the list!)
  4. DATE_FORMAT(lbrides.RideStartTime,'%H:%i') RideStartTime should be DATE_FORMAT(lbrides.RideStartTime,'%H:%i') AS RideStartTime If you run that exact query in phpmyadmin it doesn't give you an error for that? Because it should.
  5. do a print_r($EntryResult); What does it output? Are you sure you're connecting to the same database?
  6. He does have a line for it. $correct_id = $_GET['id']; It doesn't have to come before the doctype, especially if there's other processing. You first need to actually check if it even exists, so I would put all the processing in one place. The only reason for it to be before the doctype is if you are going to redirect to another page based on that value or lack of value.
  7. Is error reporting enabled? And is the "variable hardcoded" in the actual page or just in your example?
  8. Change the data type to a boolean. Then read the code I provided.
  9. You know how to send one mail. Do it twice. With two different bodies. Remove the CC from the first and second a second mail to that address. Edit: We really need to fix the reply-already-posted-type notification. What the above posters said.
  10. I forgot 9, use mysqli So. You should change the table structure to have one table for types of pets (like pet_types with a PK like pet_type_id), one table for users, and a third table for users_pets, linking the pet_type_id and the user_id. Then your code could work as follows: <?php //Get the pet types. $sql = "SELECT pet_type_id, pet_type FROM pet_types"; $pet_types = array(); $result = mysqli_query($conn, $sql) or trigger_error("Query Failed! SQL: $sql - Error: ".mysqli_error(), E_USER_ERROR); while($row = mysqli_fetch_assoc($result)){ $pet_types[$row['pet_type_id']] = $row['pet_type']; } //If the array was sent via POST if(isset($_POST['selected_pet_types'])){ //Sanitize the user input $pet_type_ids = array_filter($_POST['selected_pet_types'], "intval"); //Build the SQL to join all 3 tables. $sql = "SELECT users.*, pet_types.pet_type FROM users INNER JOIN users_pets ON users.user_id = users_pets.user_id INNER JOIN pet_types ON users_pets.pet_type_id = pet_types.pet_type_id WHERE pet_type_id IN (".implode(', ', $pet_type_ids.")"; $result = mysqli_query($conn, $sql) or trigger_error("Query Failed! SQL: $sql - Error: ".mysqli_error(), E_USER_ERROR); //Here, do whatever you want with the results. echo '<pre>'; while($row = mysqli_fetch_assoc($result)){ print_r($row); } }else{ //Display the form echo '<form method="post" action="">'; //Display each pet type with a checkbox. foreach($pet_types AS $pet_type_id=>$pet_type){ echo "<p>$pet_type <input type=\"checkbox\" name=\"selected_pet_types[]\" value=\"$pet_type_id\"></p>"; } echo '<p><input type="submit" value="Search" /></p> </form>'; }
  11. 1. $Name = (''); Why are you doing that??? 2. Variables are case sensitive, so $dog and $Dog are not the same. 3. Your SQL is missing AND/OR between the columns. Look up the syntax. 4. What is the datatype in the DB? 5. See the link in my signature about debugging SQL, and use that technique instead of just die() with a useless message. 6. Use :codetags: on this forum. 7. I just realized you have all of that in a function, without any evidence that you're even calling the function. You probably don't need a function for this. 8. When you post a form, the values will be in the $_POST array.
  12. If it's a value that is POSTed, it's not going to stay constant and not change. Why bother POSTing it then? Just set it.
  13. That has nothing to do with your original question. The error is telling you - $result is undefined. It's defined within your function, but not when you try to use it after calling the function, because that's not how functions work. See the code below. function changeName(){ $name = 'John'; return $name; } $name = 'Bob'; changeName(); echo $name; What will be echo'd? Now change it to $name = 'Bob'; $name = changeName(); echo $name; How are they DIFFERENT?
  14. That error has nothing to do with the code posted. Post the entire error including line number, and the code that is around that line number. Applet? Really? :eyeroll:
  15. When you return a value, you must assign it to a new variable if you want to use it. There is no way you read all of those links in that short amount of time. :/
  16. You haven't posted any code that you've tried that doesn't work. It's a simple select, so show us what you tried and we can help.
  17. http://php.net/manual/en/language.functions.php http://php.net/manual/en/functions.user-defined.php http://php.net/manual/en/functions.returning-values.php http://php.net/manual/en/language.variables.scope.php
  18. Your question makes no sense. The only advice I can offer is make sure error reporting is on and try using require_once instead.
  19. In your second section of code, where is $result defined? The error is fairly clear. Your function returns a value and you do nothing with it...
  20. I misunderstood your table structure. Looks fine to me, sorry about the confusion.
  21. My point is if you change that query to the below, which is what you're suggesting, it will not return anything. SELECT DISTINCT publications.title, publications.date, publications.description FROM publications JOIN link_audience ON link_audience.pub_id = publications.pub_id JOIN audience ON audience.id = link_audience.audience.id WHERE (audience.type = 'advocates' AND audience.type = 'legislators') ORDER BY publications.title One single column cannot be a value AND another value. You would have to do multiple joins, and have multiple relationships.
×
×
  • 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.