Jump to content

LostinGA

New Members
  • Posts

    5
  • Joined

  • Last visited

Everything posted by LostinGA

  1. I know my query is wrong I just need fresh eyes on it to tell me what's wrong. I am generating errors for lines 50 and 57. //Make the paginated query; $query = "SELECT * FROM Company LIMIT $start, $display"; $result = @mysql_query ($query); //Table header: echo "<table cellpadding=5 cellspacing=5 border=1><tr> <th>Company</th><th>Product</th><th>City</th><th>State</th></tr>"; //Fetch and print all the records... while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { echo "<tr><td>".$row['Company_Name']."</td>"; echo "<td>".$row['Product_Type']."</td>"; echo "<td>".$row['City']."</td>"; echo "<td>".$row['State']."</td>"; } // End of While statement echo "</table>"; mysql_free_result ($result); // Free up the resources. mysql_close(); // Close the database connection.
  2. In case you are wondering the php was right and I was wrong. I had several versions of this on the server (about 12 or so with different names), I had the php right in a lot of the versions, but the html was still referencing the first version I worked with. You are right the error messages should have been working and they weren't displaying any errors, which got me thinking and then it hit me that the html was grabbing the first file over and over again. Thank you for trying to help, I really thought I was going nuts because the instructor told me the php was right and you guys did here as well, yet it wasn't working. I will never leave old versions sitting on the server again. That was a hard way to learn that lesson. Thanks again.
  3. No luck. I tried this: // Check for form submission: if (isset($_POST['submitted'])) { // Minimal form validation: if ( is_numeric($qtySold) && is_numeric($price) ) { // Print the heading: echo '<h1>Commission</h1>'; if ($qtySold >= 100){ $commissionRate = 0.03; else{ $commissionRate = 0.02; } $commission = $total * $commissionRate; and this: // Check for form submission: if (isset($_POST['submitted'])) { // Minimal form validation: if ( is_numeric($qtySold) && is_numeric($price) ) { // Print the heading: echo '<h1>Commission</h1>'; if ($qtySold >= 100){ $commissionRate = 0.03; $commissionRate = 0.02; }else{ $commission = $total * $commissionRate; and this: // Check for form submission: if (isset($_POST['submitted'])) { // Minimal form validation: if ( is_numeric($qtySold) && is_numeric($price) ) { // Print the heading: echo '<h1>Commission</h1>'; if ($qtySold >= 100){ $commissionRate = 0.03; }else{ $commissionRate = 0.02; //up from below } $commission = $total * $commissionRate; // Print the results: All give me the same issues - nothing works for any number over 100 and the wrong commission rate for all numbers under 100. I would happily re-write the code, but we are not supposed to. Thanks again for taking a look at it, it help knowing there isn't a glaring error in it that I am missing.
  4. Thanks for the tip, I have tried the error reporting but I get an error for the error_reporting line. I swear the php is just mocking me now. I have tried with and without the ==, =, (, in various combinations just to get something that works. Nothing helped. Here's the latest best working out of many version I have now: <?php # Script 3.10 - Errors.php #5 error_reporting = -1 display_errors = on $page_title = 'Errors'; // Set the variable number $qtySold = $_POST["qtySold"]; $price = $_POST["price"]; $total = $qtySold * $price; // Check for form submission: if (isset($_POST['submitted'])) { // Minimal form validation: if ( is_numeric($qtySold) && is_numeric($price) ) { // Print the heading: echo '<h1>Commission</h1>'; if ($qtySold >= 100){ $commissionRate = 0.03; }else{ $commissionRate = 0.02; $commission = $total * $commissionRate; // Print the results: echo "<p>Your commission is <b> $commission</b>."; } } else { echo "You forgot to enter values!"; } } This version doesn't give the "You forgot to enter values!" right off the bat, which is an improvement. It's still giving me 0.03 commission rate for all numbers under 100. I have even tried switching the >= to a <= to get a different result and it spit out the same result. Again, I think it's mocking me.
  5. I am debugging code for an assignment that the instructor has assured me only involves brackets and semicolons, yet the commission rate calculator never runs correctly no matter what I do. It should make the commission rate 0.03 if items sold is over 100 and 0.02 if under. I just want to know how to make this calculator work. I haven't been able to dig up an example of something similar and it's driving me nuts. I would really appreciate it if someone could point out what I am missing. // Check for form submission: if (isset($_POST['submitted'])) { // Minimal form validation: if ( is_numeric($qtySold) && is_numeric($price) ) { // Print the heading: echo '<h1>Commission</h1>'; if ($qtySold >= 100){ ($commissionRate == 0.03); }else{ ($commissionRate == 0.02); $commission = $total * $commissionRate; // Print the results: echo "<p>Your commission is <b> $commission</b>."; } }else{ echo "You forgot to enter values!"; } }
×
×
  • 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.