Jump to content

dmaar

Members
  • Posts

    20
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

dmaar's Achievements

Newbie

Newbie (1/5)

1

Reputation

  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>
×
×
  • 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.