Jump to content

phppup

Members
  • Posts

    644
  • Joined

  • Last visited

Everything posted by phppup

  1. Thanks for the clarifications guys and examples. Good educational for when my head clears.
  2. It's one of those days after a long weekend and a rainy morning. Simply trying to get the correct message depending on the variable's value if($a = 'one'){ echo "POOR";} if($a = 'two'){ echo "GOOD";} if($a = 'three'){ echo "VERY GOOD";} if($a = 'four'){ echo "EXCELLENT";} Not sure if I need to use ==, extra quotes, or ELSEIF for the best result.
  3. Don't have access to full code at the moment, but if I recall, the query was written once at the top of the code when only Mysql. Does it need to be repeated ahead of this statement with up-to-date MYSQLi? It did work for the other statement without error.
  4. I think this code was working before I updated MySQLi coding. Now I am receiving an error: Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in.... I haven't gone through all my code, but are there any obvious symptoms to note from the following segment: if (mysqli_num_rows($result) > 0) { while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { //do this } } All else style to be functioning as specified. Thanks
  5. Thanks KICKEN. I came up with something similar at 2:AM this morning, which uses Javascript in a shoddy kinda way, but looked as if it would get the job done. This seems like an excellent alternative to weigh in contention, and looks as if it too, would do EXACTLY what I am attempting to accomplish. Thanks again.
  6. Or perhaps I am misunderstanding. When the link states: If the string is empty, the browser will create a new window every time are the statement meant to indicate "... Everytime that a singular new window is opened" but that once opened, it will forever be pointed to until closed? Or does everytime meet my goal, which is to open a new window everytime a submit button is clicked??? So confused now.
  7. I've read the link. It seems to indicate in the first section that leaving the windowName empty will cause new windows to be opened, yet that does not seem to be the case. is this bc I'm using chrome at the moment (I would think not). so what am I doing wrong? I've read the link. It seems to indicate in the first section that leaving the windowName empty will cause new windows to be opened, yet that does not seem to be the case. is this bc I'm using chrome at the moment (I would think not). so what am I doing wrong?
  8. I seem to be getting an acceptable result, sort of. I believe at this point the problem is more with the "target" because I on placing results for submitting 1,2, or 3 on the same target. If I submit with button 1, a valid result opens in a new window. If I then submit with button 2, the SAME "new window" repopulates and updates with data associated to that query. I am currently unable to get a second "new window" to open for a side by side comparison of on screen data. I was thinking of using JS to alter the name of the "target" so I could hopefully evade the conflict in that manner. But not having much luck there either.
  9. I'm popping open process. php which will populate the data the same way that it does when it opens as a standard PHP page.
  10. I have a form with three submit buttons that ALL have the same action="process. php" Each submit has a different value to query a database table which provides the requested information. Button 1 value = baseball team Button 2 value = football team Button 3 value = hockey team Currently, a submission will process and provide information of the team members for the sport that is selected. I have decided it might be nice to retrieve the data in separate windows for easy side by side comparison. Using<form action="process. php" onsubmit="window.open('about:blank','print_popup','width=1000,height=800');"> I have been able to get data to populate in a newly opened window. But the data continues to re-populate the same window. How can I get 3 independent NEW WINDOW to open so they can be compared side by side?
  11. The data is in a simple table with a column for carrots which received a numeric value of the amount that was ordered. The table is populated by a form submission. I think that is what you are asking me. I do not have access to my code right now, but will try altering the quotes suggested by gw1500se. Any additional guidance is welcome.
  12. The data is in $mytable input into a column named carrots. My output was There were 3 orders for carrots for 1 lbs. each There were 2 orders for carrots for 2 lbs. each There were 1 orders for carrots for 3 lbs. each but after altering the WHILE STATEMENT it became There were orders for carrots for lbs. each There were orders for carrots for lbs. each There were orders for carrots for lbs. each which removed the data information. Does something special or unique to MySQLi need to be done to change the hardcoded word "carrots" to the variable $item within that statement?
  13. It was: $query = "SELECT carrots, COUNT(carrots) FROM $mytable WHERE carrots>0 GROUP BY carrots ORDER BY carrots ASC"; $result = mysqli_query($link, $query) or die(mysqli_error()); Until I changed all the CARROTS to $item. The loss of values did not occur until I altered the while statement.
  14. I am UPGRADING some old files to MySQLi and while doing so have decided to complete some leftover projects. In this project, I was counting vegetables sold to customers that displayed a report displaying information like this: There were 3 orders for carrots for 1 lbs. each There were 2 orders for carrots for 2 lbs. each There were 1 orders for carrots for 3 lbs. each The code I used to generate the messages was: while($row = mysqli_fetch_array($result)){ echo "There were ". $row['COUNT(carrots)'] ." orders for carrots for ". $row['carrots'] ." lbs. each <br />"; } At the time, I was going to call a separate script for carrots, potatoes, and celery. Now, with my worldly advancement (or maybe not.. LOL) I realize I should be able to use the same single script and assign a variable to accommodate each vegetable item. After declaring the $item = 'carrots' I inserted it to test my theory. I tested the output in stages and all seemed okay until I did this: while($row = mysqli_fetch_array($result)){ echo "There were ". $row['COUNT($item)'] ." orders for carrots for ". $row['$item'] ." lbs. each <br />"; } Is there an issue with using a variable inside a $row? Is there a syntax error (no error messages)? Perhaps a MySQLi addition that is required?
  15. A silly question, since simply fixing the error would likely take less time, but my curiosity won't stop nagging me. I have several php pages that ALL use the INCLUDE file connection.php which has the following scripting $conn = mysqli_connect(...etc, etc,etc,); Everything works fine EXCEPT for a few pages which were written using $DBCONN instead of $conn Can I somehow alter the value of $DBCONN so it is equal to $conn And interpreted correctly without having to change the mistaken variable in the pages that use $DBCONN ? I tried a quick $DBCONN = $conn; but there was no effect, so I thought I'd ask.
  16. Now that I'm playing with ERROR messages, I see that or die(mysqli_error()) provides the line number that corresponds to the coding issue, but differs from or die(mysqli_error($conn)) which specifically gave me a reason for the unsuccessful effort. Is there a simple way to display BOTH pieces of information, or does an IF statement need to be created?
  17. It is rather unfair of you to force me to think so decisively. I was doubting my code, rather than simply verifying the easy (and stupid) mistakes. I got it now. Thank you, as always.
  18. I have many BLANK lines for easier reading in my coding. My first ERROR MESSAGE read: Warning: mysqli_error() expects exactly 1 parameter, 0 given in /home/..... on line 368 So, I commented out line 368 $result = mysqli_query($conn, "SELECT * FROM $table WHERE id = $record_id "); //or die(mysqli_error()); This took me to the following: Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in /home/.... on line 378 $row = mysqli_fetch_array( $result, MYSQLI_BOTH ); which is required to fill fields with data from my table. I guess I need to fix the fetch and the mysqli_error for a fully acceptable coding result.
  19. I am updating some old code to the IMPROVED version of PHP and running into a problem in this section after connecting successfully to my database: // retrieve the record that was selected $record_id = (isset($_POST['record_id'])) ? $_POST['record_id'] : ''; //check for $record_id emptiness if(!empty($record_id)){ // Retrieve ALL the data from the "example" table $result = mysqli_query($conn, "SELECT * FROM $table WHERE id = $record_id ") or die(mysqli_error()); // store the record of the "example" table into $row $row = mysqli_fetch_array( $result, MYSQLI_BOTH ); } Not sure what I'm missing or what needs to be re-organized. Please advise.
  20. Can I simply change the MP4 extension to AVI just to confirm functionality?
  21. I opened the webpage in both Firefox and Chrome and got the same result. I'm going to conclude that since these are the same browsers that played the video from W3 (both while at their URL and after saving the file locally) that it is not a browser issue. How do I proceed regarding the codecs, or is their a simpler / more effective way to make a simple screen recording for use on a webpage?
  22. This is a first time effort to create a video of my local pc workstation screen. Attempt #1 utilized an application provided in Windows 10 to create the MP4 file. Attempt #2 was to convert a Powerpoint 2010 presentation into an MP4 file Both seemed to go well, and produced files then when clicked independently on the desktop, will play their clip. However, when called from a local webpage "No video with supported format" is the message displayed where the working video is expected. <video width="400" controls> <source src="mov_bbb.mp4" type="video/mp4"> <source src="mov_bbb.ogg" type="video/ogg"> Your browser does not support HTML5 video. </video> <video width="400" controls> <source src="Presentation2.mp4" type="video/mp4"> <source src="Presentation2.mp4" type="video/ogg"> Your browser does not support HTML5 video. </video> I borrowed a video clip from W3 and it seems to work fine, which leads me to believe that either I am creating a damaged file or the file is not truly MP4. The file PROPERTIES indicate it is MP4 in all instances. Where did I go wrong?
  23. You are correct. Located the problem and remedies it. So, if I make the EMAIL column unique, how would I trigger an error message to the user when a duplicate email is entered, without querying the table?
  24. More info..... Here is my original code that works well PRIOR to attempting to acquire the LAST INSERT ID: $query = "SELECT * FROM table WHERE email='$email' "; //checks that email is unique $result = mysqli_query($conn, $query); //RUNS the above query if (mysqli_num_rows($result) == 0) { //if no duplicates exist, then INSERT $sql="INSERT INTO $table..... etc etc } So the question remains, how do I retrieve the LAST INSERT ID without having duplicate entries into my table, and without restructuring my code too drastically (as to affect other portions that use the same CONN).
  25. Fought with code until I eventually put this after my INSERT statement: if (mysqli_query($conn, $sql)) { $last_id = mysqli_insert_id($conn); echo "New record is: " . $last_id; } else { echo "Error: " . $sql . "<br>" . mysqli_error($conn); } I finally got the ID value, except all entries into the table are being duplicated from each single form submission. It appears that this is because $sql is being called twice. I even tried to put this into a function (didn't execute at all). How do I get to a single table posting?
×
×
  • 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.