Jump to content


  • Content Count

  • Joined

  • Last visited

  • Days Won


Everything posted by ginerjm

  1. I build small folders of trip pics and add caption files (.txt) to the same folder. Then as I loop thru the image files to display them I also check for files with the same basenames but a .txt extension and display that along with the pic.
  2. The glob function is correct. Try the manual. It will tell you more.
  3. Create a drop down list of the services. When the user picks one from the list go back to the php script with that choice and the id number and build the url from an array of them keyed by the items in that dropdown list. Then use a header() call to go to their website.
  4. Took an attempt to clean up your code. See if this reads better for you. Note the subtle changes I have made here to help you understand what you are doing better. echo "<form action='' method='post' id='add_edit_reservation_form'>"; if (isset($reg_id)) { echo "<input type='hidden' name='action' value='update_reservation' /> <label>Reservation ID:</label> <input type='text' name='reg_id' value='$reg_id'/>"; } else { echo "<input type='hidden' name='action' value='add_reservation'/> <label>User_ID</label> <input type='text' name='ms_user_id' value='" . $user_info['ms_user_id'] . "'>"; } echo "<label>Which room would you like?</label> <select name='room_id'>"; foreach ($room_ids as $room_id) { if ($room_id['room_id'] == $reservation['room_id']) $selected = 'selected'; else $selected = ''; echo "<option $selected value='" .$room_id['room_id'] . "'>" . $room_id['room_name'] . "</option>"; } echo " </select><br> <label>What date would you like to reserve your room?</label> <input type='date' name='reserve_date' value='" . $reservation['reserve_date'] . "'> <br> <label>Please submit form to reserve your room.</label> <input type='submit' value='Submit'> </form> "; //********************************** // Functions below //********************************** function update_reservation($room_id, $reg_id, $reserve_date) { global $db; $query = 'UPDATE reservations SET room_id = :room_id, reserve_date = :reserve_date, WHERE reg_id =:reg_id'; try { $statement = $db->prepare($query); $statement->bindValue(':room_id', $room_id); $statement->bindValue(':reserve_date', $reserve_date); $statement->bindValue(':reg_id', $reg_id); $row_count = $statement->execute(); $statement->closeCursor(); return $row_count; } catch (PDOException $e) { $error_message = $e->getMessage(); display_db_error($error_message); } } Now - what doesn't work?
  5. I stopped reading when I saw this: This suggests a very bad database design. Joining multiple values and placing them all into one record is not the way to store data. This should really be done by making multiple related records in a separate table, linked to the main record for the user/item/primary key so that you can then easily do queries for these data values. Your current design/approach prevents this from being easily done.
  6. What does your html look like for this input tag? When I research the $_FILES array I get the following as the elements: name tmp_name size type error I get no "upload" element. I can only assume that 'upload' is the actual NAME of your input tag so you have to add another index to your grab to get the value you actually want. Such as $_FILES['upload']['name'];
  7. Yes - you have corrected the syntax errors of your first two posts and are now referencing that item properly. Now you just have to follow the other good advice you are receiving.
  8. This line: $startingFolder = '$_FILE[upload]'; is TOTALLY incorrect. In fact you are assigning the following text value "$_FILE[upload]" to the variable $startingFolder. If you added this line echo $startingFolder; following the above line you would see: $_FILE[upload] instead of what you expect to see. Move the quotes to where they should be.
  9. As well as putting your array indices in quotes as in $_FILE['upload']
  10. Your english isn't making sense to me. Are the images being saved as files in a folder or are they in a "db"?
  11. I think we gave you what you asked for. And more. My array suggestion is just a (imho) better way of connecting the values to the parms.
  12. It is since the parms are not 'user input' but simply values that your script produced. FYI - you can avoid the bind-param calls if you simply create an array of your parms and their values like this: $parms = array( 'min_price' => $min_price, 'max_price' => $max_price, 'featured' => $featured); $find_records-> execute($parms); allows for easier maintenance later on and avoids all of the bind-param calls.
  13. See if this makes sense to you. <?php /* ****************************** script name description of what this does end of comments ********************************* */ session_start(); error_reporting (E_ALL ^ E_NOTICE); include "includes/db.php"; $query = "SELECT videoid, titulo, url_video from videos"; $result = mysqli_query($connection, $query); $num_per_page =05; $table_data = " <table border='1' width='100%'> <tr> <th>Video Id</th> <th>Titulo</th> <th>Video</th> </tr> "; while (list($videoid, $titulo, $url_video) = mysqli_fetch_row($result)) { $table_data .= " <tr> <td>$videoid</td> <td>$titulo</td> <td>$url_video</td> </tr>"; } $table_data .= " </table> <br> "; $query = "SELECT * from videos"; $pr_result = mysqli_query($connection, $query); $table_data .= "Results found: " . mysqli_num_rows($pr_result); // // Now output the html data including the generated data above. // echo $html=<<<heredocs <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link href="style.css" rel="stylesheet" type="text/css" /> <link href="tablefiestas.css" rel="stylesheet" type="text/css" /> <title>La Taverna de Juan</title> </head> <body> <div id="container"> <div id="header"> <!--MENU BAR--> </div> <!--VIDEOS--> $table_data <br> <div id="footer"> <!--FOOTER--> heredocs; // echo $html; // include "includes/footer.inc.php"; echo " </div> </div> </body> </html> "; exit(); I may have not inserted the table data in the correct place in your html block but I'm sure you can place it in the correct spot if not.
  14. 1 - Yes! Stop going in and out of php mode. Learn how to code better. 2 - How about those echos you buried in the td statements? They look a bit different from your other lines doing similar things. Add a semi.
  15. Do you ever read your code when you write it? "delete records where user_id = a date value?" I thought user ids were integers like 1,2 or 3 as you used earlier. Now they are date values?
  16. Why do you begin the second script with a leap to ANOTHER script? Makes no sense at all.
  17. Is the echo for "not being inserted" showing up? PS - your check to see if a row is returned matching your $email could also be done by simply checking the number of rows returned. Plus - using the input value directly could compare a bad input value against the most-likely 'good' value saved in your db if your user is providing 'bad' input.
  18. Can I ask why all the parens and braces??? A simple assignment statement looks like this (in a simpler format): $a = $b; No need to be typing: $a = {($b)};
  19. But - getting back to your original question. If the script used to work and now it doesn't something has changed. If not the code then, as Barand said, it must be your environment. PHP Version? Default folders in use? .INI settings? I mean - what has changed? We know something has, you just have to find it. Basically - what is the difference between the time when it did work and now? Do you have php error checking turned on in your ini? Have you checked the error log file?
  20. And I would learn how to structure your scripts to separate the logic (PHP) from the presentation (HTML/JS) so that it is easier to read/understand and maintain. As it is your script is very hard to follow. A good style would be to place your php at the beginning and your html at the end and your js embedded inside of that HTML. Test the current status of the script's execution (is this the first time in here? or not?) to determine what you php code should do and avoid trying to handle things from the form that don't yet exist. A nice clean method of writing php scripts would leave you with just one pair of php tags (<?php & ?>) in it.
  21. While reading the item linked to by Barand would be a great place to improve your PDO knowledge, a simple loop on a fetch is the usual way of outputting the results of a query. One problem with your query though is all you are asking for is a count of the rows that match your where condition. Don't you want so select some fields from those matching records to be displayed? After that you simply do this: echo "<table>"; while ($row = $stmt-fetch(PDO::FETCH_ASSOC)) { echo "<tr> <td>{$row['fieldname1']}</td> <td>{$row['fieldname2']}</td> <td>.....</td>.... </tr>"; } echo "</table>"; This will give you a nice html table of the results. You can add your own table headings (th tags) to improve it. And you could add some css code to make more improvements. Note - the "fieldname1 and "fieldname2" are made-up names for your query results. Obviously you would substitute your queried item names for the $row elements. PS - you should also add some error handling code to ensure that the query has actually run or that you have some results to be displayed before starting the loop.
  22. Not trying to be difficult here but I want to ask - What has changed in your code? Working scripts that suddenly don't work usually means you changed something. Have you tried adding any kind of debugging code (echo's or writes to a text file) to track the actions that your script is taking?
  23. array_pop is just an array function that works on any array. Using it on a $_SESSION array is no different than any other array. If you pop something off an array it is no longer a member of that array and that's that. And using it on the $_SESSION array itself (and not a member array) is the same. Why do you think that using it on a $_SESSION array or $_SESSION itself would give you something different? PS - What is this "REQUEST" item that you mention? It is not an automatic entry that I know of.
  24. Actually the OP began this topic by stating that he was working on a 'string' value (from a form). If he is willing to move forward with that and is comfortable that the users will input a valid currency amount, my suggestion made sense. Afterall, it doesn't appear to be a mathematical situation here, simply a formatting change.
  25. Couldn't you just use the str_replace to remove the dot?
  • 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.