Jump to content

dmaar

Members
  • Posts

    20
  • Joined

  • Last visited

    Never

Everything posted by dmaar

  1. Yeah I figured it out. I don't know what I was was thinking pasting the PHP code directly in there haha. It ended up all working out though.
  2. That worked great. Thank a lot, I really appreciate it. This just goes to show how much I have to learn.
  3. Haha, sorry...you can probably tell how much of a newbie I am. Anyways, this is what I got when i switched it to what you said: #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'MEDUIMINT(10) NOT NULL AUTO_INCREMENT, product_name VARCHAR(225), product_ca' at line 3 Seriously though if you don't know what it could be don't even worry about it. It's not that big of a deal, I fixed the biggest problems. I appreciate all the help you guys have given me, you've saved my ass more than once.
  4. Oh wait, do you mean in the SQL tab in phpMyAdmin? Sorry, this is pretty much my first day using phpadmin, so not all that familiar with how it works. Here's what it spits out: Error There seems to be an error in your SQL query. The MySQL server error output below, if there is any, may also help you in diagnosing the problem ERROR: Unknown Punctuation String @ 30 STR: -> SQL: if(isset($create)) { $q=$db->query("CREATE TABLE products ( id auto_increment INT(10), product_name VARCHAR(225), product_category VARCHAR(225), price DECIMAL (4,2) )");if(isset($create)) { $q=$db->query("CREATE TABLE products ( id auto_increment INT(10), product_name VARCHAR(225), product_category VARCHAR(225), price DECIMAL (4,2) )");if(isset($create)) { $q=$db->query("CREATE TABLE products ( id auto_increment INT(10), product_name VARCHAR(225), product_category VARCHAR(225), price DECIMAL (4,2) )");if(isset($create)) { $q=$db->query("CREATE TABLE products ( id auto_increment INT(10), product_name VARCHAR(225), product_category VARCHAR(225), price DECIMAL (4,2) )"); SQL query: if(isset($create)) { $q=$db->query("CREATE TABLE products ( id auto_increment INT(10), product_name VARCHAR(225), product_category VARCHAR(225), price DECIMAL (4,2) )"); MySQL said: #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'if(isset($create)) { $q=$db->query("CREATE TABLE products ( id auto_inc' at line 1
  5. It just says "DB Error: syntax error"
  6. I tried this, but it was giving me a syntax error as well: if(isset($create)) { $q=$db->query("CREATE TABLE products ( id MEDUIMINT NOT NULL AUTO_INCREMENT, product_name VARCHAR(225), product_category VARCHAR(225), price DECIMAL (4,2) )");
  7. I think it was the fact that I didn't have those single quotes like you said. One quick question...my display button is showing everything except the ID numbers...and auto_increment shows as null in phpMyAdmin....I'm guessing that has something to do with what you said about not having it named? Is there a way to fix this? What you told me to do before was giving me a syntax error.
  8. the second thing you said gave me a syntax error, but the first worked perfectly. Thanks a lot, you really saved my ass. One quick question...my display button is showing everything except the ID numbers...and auto_increment shows as null in phpMyAdmin....I'm guessing that has something to do with what you said? Is there a way to fix this?
  9. I have to have this done my midnight....anyone know what the problem could be?
  10. The error doesn't do a very good job of explaining what is going wrong, all it says is "DB Error: no such field". I posted a link to the form in my original post, if that helps. I don't know much, but I would guess that there is some discrepancy between my original "create" code and the "input" code...but I really can't find it. That may not even be it though, I have no clue.
  11. That shouldn't mess up the other sections to my knowledge, but to be safe I commented it out. Still does the same thing. That part is messy though, I have to clean that up after I get this figured out.
  12. Couldn't figure out how to do a describe table query, but in phpMyAdmin under "field" for the products table is: auto_increment product_name product_category price So it seems to be good as far as actually having the fields. Could it have something to do with the way I set up auto_increment in the code? Not sure I did that right.
  13. I'm having a bit of trouble using a simple form I created in conjunction with phpMyAdmin. I have buttons on the form that do different things, but I have one in particular that is giving me a bit of trouble. The button is used to input new products into the table using fields above the buttons, but I keep getting "DB Error: no such field". I'm an extreme newbie, so if someone could take a look at the code and help me out I would appreciate it. I'm having some other problems with the form as well, but can't even try to do anything about those until I get this one fixed. HTML: <!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> <title>Mar Audio</title> </head> <body> <form action="database.php" method="post"> <h1 align="center">Table Creation / Editing Form</h1> Product Name: <br/> <input type="text" name="name"/> <br/> Category: <br/> <input type="text" name="category"/> <br/> Price: <br/> <input type="text" name="price"/> <br/> <input type="submit" value="Create Product Table" name="create"/> <br/> <input type="submit" value="Delete Table" name="delete"/> <br/> <input type="submit" value="Input Product" name="input"/> <br/> <input type="submit" value="Update Product" name="update"/> <br/> <input type="sumbit" value="Display Table" name="display"/> <br/> <input type="reset" value="Clear All Fields"/> </form> </body> </html> PHP (current problem occurs under the "else if (isset($input))" part: $db = DB::connect('mysql://sequela:777956@localhost/sequela'); $db->setErrorHandling(PEAR_ERROR_DIE); if (DB::isError($db)) die("Can't connect:".$db->getMessage()); else print("Was able to connect"); extract($_POST); if(isset($create)) { $q=$db->query("CREATE TABLE products ( auto_increment INT, product_name VARCHAR(225), product_category VARCHAR(225), price DECIMAL (4,2) )"); if ($q) print('<br/>Products Table was Created'); } else if (isset($delete)) { $q=$db->query("DROP TABLE products"); if($q) print('<br/>Products Table was Deleted'); } else if (isset($input)) { $q=$db->query("INSERT INTO products (product_name, product_category, price) VALUES($name, $category, $price)"); if($q) print('<br/> Product Was Added'); } else if (isset($update)) $q=$db->query("UPDATE products SET price = price - 100 WHERE price > 999.00"); else if (isset($display)) ?> Link to form: http://mktg-content.bsa.kent.edu/~sequela/insertproducts.html Thanks guys, I appreciate it.
  14. Thanks DavidAM, worked perfectly. I don't know what I was thinking when I set it up like that.
  15. Here's the full PHP code: <?php extract($_POST); if (empty ($name)) { die('You did not enter your Name. Please press the back button on your browser and complete all of the required fields'); } if (empty ($phone)) { die('You did not enter your Phone Number. Please press the back button on your browser and complete all of the required fields'); } if (!preg_match('/^[0-9]{3}-[0-9]{3}-[0-9]{4}$/', $phone)) { die('You did not enter your Phone Number in the correct format. Please go back and enter your Phone Number again.'); } if (empty ($street)) { die('You did not enter your Street Address. Please press the back button on your browser and complete all of the required fields'); } if (empty ($city)) { die('You did not enter your City, State, or Zipcode. Please press the back button on your browser and complete all of the required fields'); } if (empty ($payment)) { die('You did not enter your Credit Card information. Please press the back button on your browser and complete all of the required fields'); } if ($SG=="") $SG = 0; if ($lespaul=="") $lespaul = 0; if ($musicman=="") $musicman = 0; if ($jazz=="") $jazz = 0; if ($mackie=="") $mackie = 0; if ($mackie2=="") $mackie2 = 0; if ($firestudio=="") $firestudio = 0; $sg_cost = 1899.99 * $sg; $lespaul_cost = 1315.99 * $lespaul; $musicman_cost = 1499.99 * $musicman; $jazz_cost = 1225.99 * $jazz; $mackie_cost = 2125.99 * $mackie; $mackie2_cost = 629.99 * $mackie2; $firestudio_cost = 649.99 * $firestudio; $total_price = $sg_cost + $lespaul_cost + $musicman_cost + $jazz_cost + $mackie_cost + $mackie2_cost + $firestudio_cost; $total_items = $sg + $lespaul + $musicman + $jazz + $mackie + $mackie2 + $firestudio; ?> <h4> Customer Info: </h4> <?php print ("$name <br /> $street <br /> $city <br />"); ?> <table border = "1"> <caption> Order Information </caption> <tr> <th> Product </th> <th> Unit Price </th> <th> Quantity Ordered </th> <th> Item Cost </th> </tr> <tr align = "center"> <td> SG </td> <td> $1899.99 </td> <td> <?php print ("$sg"); ?> </td> <td> <?php print ("$sg_cost"); ?> </td> </tr> <tr align = "center"> <td> Les Paul </td> <td> $1315.99 </td> <td> <?php print ("$lespaul"); ?> </td> <td> <?php print ("$lespaul_cost"); ?> </td> </tr> <tr align = "center"> <td>Music Man</td> <td> $1499.99 </td> <td> <?php print ("$musicman"); ?> </td> <td> <?php print ("$musicman_cost"); ?> </td> </tr> <tr align = "center"> <td> Fender Jazz Bass </td> <td> $1225.99 </td> <td> <?php print ("$jazz"); ?> </td> <td> <?php print ("$jazz_cost"); ?> </td> </tr> </table>
  16. Yeah, the 0's are used to set the value to 0 "if" the value the user entered was "" (nothing). I changed the uppercase SG right after I posted this. Here's the html page with the form: http://mktg-content.bsa.kent.edu/~sequela/products.html Here's the html code for the form (scroll to the left): <strong>Instruments</strong> <table border="1" cellspacing="20" cellpadding="5"> <tr> <td> <a href="sg.jpg" target="_blank"><img src="sg.jpg" alt="picture of a SG guitar" width="100" height="100"/></a> </td> <td class="product"> <b><span style="color:#242D6B">Gibson SG Reissue</span></b> <br/> P-90 pickups re-create '60s sound and look, all-mahogany body, bound rosewood fingerboard with dot inlays <br/><br/> <span style="color:#cc0000"><b>$</b>1,899.99</span> <br/> Quantity? <form action=""> <input type="text" name="sg" size="1"/> </form> </td> </tr> <tr> <td> <a href="gibson.jpg" target="_blank"><img src="gibson.jpg" alt="picture of a Gibson Les Paul Guitar" width="100" height="100" /></a> </td> <td class="product"> <b><span style="color:#242D6B">Gibson Les Paul Studio</span></b> <br/> Mahogany neck with '60s profile, ebony fretboard, trapezoid inlays <br/><br/> <span style="color:#cc0000"><b>$</b>1,315.99</span> <br/> Quantity? <form action=""> <input type="text" name="lespaul" size="1"/> </form> </td> </tr> <tr> <td> <a href="bass.jpg" target="_blank"><img src="bass.jpg" alt="picture of a Music Man Bass Guitar" width="100" height="100" /></a> </td> <td class="product"> <b><span style="color:#242D6B">Music Man Stealth Stringray Bass</span></b> <br/> 4 string, matte black finish, maple neck, ebony fretboard <br/><br/> <span style="color:#cc0000"><b>$</b>1,499.99</span> <br/> Quantity? <form action=""> <input type="text" name="musicman" size="1"/> </form> </td> </tr> <tr> <td> <a href="fender.jpg" target="_blank"><img src="fender.jpg" alt="picture of an American Fender Bass Guitar" width="100" height="100" /></a> </td> <td class="product"> <b><span style="color:#242D6B">Fender American Jazz Bass</span></b> <br/> Alder body, graphite-reinforced neck, rosewood fretboard, chrome hardware <br/><br/> <span style="color:#cc0000"><b>$</b>1,225.99</span> <br/> Quantity? <form action=""> <input type="text" name="jazz" size="1"/> </form> </td> </tr> </table> <strong>Pro Audio</strong> <table border="1" cellspacing="20" cellpadding="5"> <tr> <td> <a href="mackie2.jpg" target="_blank"><img src="mackie2.jpg" alt="picture of a Mackie Onyx Mixer" width="100" height="100" /></a> </td> <td class="product"> <b><span style="color:#242D6B">Mackie Onyx Premium 32-Channel Mixer</span></b> <br/> 32 channel analog, 32 Onyx preamps, built-in limiter/compressor <br/><br/> <span style="color:#cc0000"><b>$</b>2125.99</span> <br/> Quantity? <form action=""> <input type="text" name="mackie" size="1"/> </form> </td> </tr> <tr> <td> <a href="mackie1.jpg" target="_blank"><img src="mackie1.jpg" alt="picture of a Mackie CFX16 Mixer" width="100" height="100" /></a> </td> <td class="product"> <b><span style="color:#242D6B">Mackie CFX16 Mixer</span></b> <br/> Low noise high-headroom Mackie preamps, 12 mono mic channels, built in digital effects processor <br/><br/> <span style="color:#cc0000"><b>$</b>629.99</span> <br/> Quantity? <form action=""> <input type="text" name="mackie2" size="1"/> </form> </td> </tr> <tr> <td> <a href="firestudio.jpg" target="_blank"><img src="firestudio.jpg" alt="picture of a Presonus Firestudio Recording Interface" width="100" height="100" /></a> </td> <td class="product"> <b><span style="color:#242D6B">Presonus FireStudio Recording Interface</span></b> <br/> Firewire, 8 class A mic preamps, Mac and Windows compatible, includes software suite <br/><br/> <span style="color:#cc0000"><b>$</b>649.99</span> <br/> Quantity? <form action=""> <input type="text" name="firestudio" size="1"/> </form> </td> </tr> </table> <br/><hr/><h3>Order Form</h3> <hr/> <form action="products.php" method="post"> Full Name: <br/> <input type="text" name="name" size="30"/><br/> Street Address:<br/> <input type="text" name="street" size="70"/> <br/> City, State, Zip:<br/> <input type="text" name="city" size="70"/><br/> Phone Number (ddd-ddd-dddd) <br/> <input type="text" name="phone" size="30"/> <br/> <strong>Payment Method</strong><br/> <input type="radio" name="payment" value= "Visa"/> Visa<br/> <input type="radio" name="payment" value ="Mastercard"/> Mastercard<br/> <input type="radio" name="payment" value= "Discover"/> Discover<br/> <input type="radio" name="payment" value ="American Express"/> American Express<br/> <input type="submit" value="Checkout"/> <input type="reset" value="Clear All Fields"/> </form>
  17. This is seriously giving me an ulcer...I've been working on this reasonably simple code all day, and can not get it to work for the life of me. Here's the rundown: On the html page the user inputs the quantity desired for each item. When they submit, the PHP is supposed to print a table with the name, cost, quantity desired, and price for each item. It's pretty straight forward, so I have to be overlooking something fairly basic. Basically what is happening is that it prints 0 for both quantity desired and item cost no matter what the user inputs. I opted to to use arrays because I'm pretty new to PHP, and this way makes more sense to me. Here's the code: if ($SG=="") $SG = 0; if ($lespaul=="") $lespaul = 0; if ($musicman=="") $musicman = 0; if ($jazz=="") $jazz = 0; if ($mackie=="") $mackie = 0; if ($mackie2=="") $mackie2 = 0; if ($firestudio=="") $firestudio = 0; $sg_cost = 1899.99 * $sg; $lespaul_cost = 1315.99 * $lespaul; $musicman_cost = 1499.99 * $musicman; $jazz_cost = 1225.99 * $jazz; $mackie_cost = 2125.99 * $mackie; $mackie2_cost = 629.99 * $mackie2; $firestudio_cost = 649.99 * $firestudio; $total_price = $sg_cost + $lespaul_cost + $musicman_cost + $jazz_cost + $mackie_cost + $mackie2_cost + $firestudio_cost; $total_items = $sg + $lespaul + $musicman + $jazz + $mackie + $mackie2 + $firestudio; ?> <h4> Customer Info: </h4> <?php print ("$name <br /> $street <br /> $city <br />"); ?> <table border = "1"> <caption> Order Information </caption> <tr> <th> Product </th> <th> Unit Price </th> <th> Quantity Ordered </th> <th> Item Cost </th> </tr> <tr align = "center"> <td> SG </td> <td> $1899.99 </td> <td> <?php print ("$sg"); ?> </td> <td> <?php print ("$sg_cost"); ?> </td> </tr> <tr align = "center"> <td> Les Paul </td> <td> $1315.99 </td> <td> <?php print ("$lespaul"); ?> </td> <td> <?php print ("$lespaul_cost"); ?> </td> </tr> <tr align = "center"> <td>Music Man</td> <td> $1499.99 </td> <td> <?php print ("$musicman"); ?> </td> <td> <?php print ("$musicman_cost"); ?> </td> </tr> <tr align = "center"> <td> Fender Jazz Bass </td> <td> $1225.99 </td> <td> <?php print ("$jazz"); ?> </td> <td> <?php print ("$jazz_cost"); ?> </td> </tr> </table> There's a little more code before that for processing the contact information, but that works fine so I didn't think it was relevant. Let me know if you need me to post anything else. I would really appreciate any help you guys could give, Thanks.
  18. Ignore my above post, I think I figured it out. Thanks again for the help, I appreciate it.
  19. Thanks for the help, it definitely works. I'd like to understand what exactly is going on in it though, could someone explain to me what the different parts of that string mean (as in all the numbers and the different sections in the parenthesis)? I think I understand some of it, like the [0-9] are to make sure that there is a valid number..but what about the {1} and {2} and so on? Thanks again for the help.
  20. Hey all, new guy here. I just started learning PHP this past week, but am having a little trouble when trying to mess around with it. Basically I have a page with an order form on it that has a few sections for input. One of those is a phone number text box. I want the page to return an error message when the string length is not equal to 12 (in the format xxx-xxx-xxxx counting the hyphens). No matter what I try I either always get the error message, or get it sometimes but not when I should. Here's what I currently have: if (strlen($phone != 12)) { die ('You did not enter your phone number in the correct format. Please press the back button on your browser and enter your phone number in the format ddd-ddd-dddd'); } So that makes perfect sense in my mind...but obviously not to PHP. Any help would be appreciated, thanks.
×
×
  • 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.