-
Posts
6,906 -
Joined
-
Last visited
-
Days Won
99
Everything posted by ginerjm
-
Echoing out variable in a table cell doesn't work
ginerjm replied to makamo66's topic in PHP Coding Help
Try running this code. I've added an echo at the start and end to give you at least something to 'see' if it is actually running. If it is not, then you need to find the errors. AND get your ini file updated to allow you to turn on error checking when you need it. <?php echo "Script is beginning<br>"; $code=<<<heredocs <table border='1'> <tr> <th>Remove </th> <th width='100'>Your Product </th> <th>Quantity</th> <th>Description</th> <th>Price per item</th> <th>Sub Total</th> </tr> <form method='post' name='yourForm'> <tr><td></td> <td><img src="$thumbnail"/></td> <td>$cart_product_quantity</td> <td>{$product}(s) </td> <td>${$price}</td> <td>${$number}</td> </tr> </form> </table> heredocs; echo $code; echo "<br>Script finished"; When you test this and have problems, show us the code as you ran it and be sure to show us how those vars are being set! -
If the last set of code is what you are running, what exactly do you expect it to be showing you? And why is your 'fputs' call embedded in an 'echo' statement?
-
Echoing out variable in a table cell doesn't work
ginerjm replied to makamo66's topic in PHP Coding Help
Have the variables been assigned any values yet? -
Your new if is asking if the variable contains the string "true". It is not checking if the value of it is a boolean value. Do you not know the difference between a string value and a boolean one?
-
Echoing out variable in a table cell doesn't work
ginerjm replied to makamo66's topic in PHP Coding Help
What exactly are you telling us? An echo is an echo. What is the problem here? The real problem is that you aren't giving us anything to look at in order to help you. Does that make sense to you? -
One problem might be the very first line of your post. That "if" statement is incorrect.
-
Yes you could add an extra line of code to do the check. But - the better way is to decide which scripts are your 'major' ones, ie, the ones that start a process. The ones that are used solely as includes/requires (I think of them as modules) do not need to begin a session and that is when you have to think about it. FWIW - that PHP 'notice' is just that - a notice. Not an error or warning. When you see it make the change. If you have even basic programming skills I don't think you would ever have a script that is both a "trigger" script and an included module. Have a Merry!
-
Ok - you send the user a form with a value in it. Is there really a form involved there? Sounds like you the user simply runs a script to get the code emailed to them, although I don't know how he provides the email address. Is that in this first form? Ok - the user gets an email with a code. is there already a new form on screen for him to switch back to from his email client and type in the just-received code? If so then he simply submits that 2nd form and your server has everything it needs. Either with a hidden field in that second form, or better yet, saved in the session by the first script that created the code. Does that make sense to you?
-
At some point in your learning curve you will realize that you don't need to preface every column name with the table name. It will save an awful lot of future typing.. And your query statements do not have to be broken up as you did above. This: $sql_2_2 = "UPDATE analytics SET visitor_visitor_sessions = '{$analytics["visitor_visitor_sessions"]}' WHERE visitor_visitor_id = '$visitor_visitor_id'"; will work just fine. As Barand has said, you should really write your queries to use prepared statements and avoid placing the variables directly into the query.
-
Since you aren't giving us any error message have you looked into the error log on your system to see if any is being reported? Do you get any message from the code that says the query did not run, or just looking at the table and not seeing your record(s)?
-
Have you tried adding some debugging statements (echo?) to your login process to see how things are being handled and set? That would be a good place to start. That and perhaps giving us something to look at.
-
Actually, wouldn't all of the tables have to have a column name of job_id? And - is "FROM" a required field to distinguish column names from table names?
-
I like Barand's answer. I wasn't sure about using a join for a Delete query, so his is definitely better.
-
IIRC one cannot use prepared statements using table names as an argument. For what you describe I would write a function that has a query statement and query execution for each of your tables. The function would use your 'job id' as the its lone parameter which you could use in a "parms array" that you reference in each of your execute calls (assuming that you are using PDO). A pseudo-example:
-
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.
-
The glob function is correct. Try the manual. It will tell you more.
-
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?
-
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.
-
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'];
-
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.
-
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.
-
As well as putting your array indices in quotes as in $_FILE['upload']
-
Your english isn't making sense to me. Are the images being saved as files in a folder or are they in a "db"?