captdavid Posted February 26, 2008 Share Posted February 26, 2008 Have simple Mysql db containing one table (catalog) with 6 fields.... First field (id_num) is auto increment and primary. This script connects and dislplays fields as requested: ?php include 'config.php'; include 'opendb.php'; $data = mysql_query("SELECT * FROM catalog") or die(mysql_error()); Print "<table border=0 cellpadding=3>"; while($info = mysql_fetch_array( $data )) { Print "<tr>"; Print " <td align=center>".$info['mfg']."<br><img src=".$info['photo_path'] . " width=150 height=100><br>" .$info['model'] . "</td> "; Print "</tr>"; Print "</table>"; } ?> Attempting to populate table using following form as input: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <body> <table border=0 > <form method="post" action="../php-bin/catalog_upload.php"> <input type="hidden" name="id_num" value="NULL"> <tr><td> Type<br> <select name="type" size="1"> <option value="Road Bike">Road Bike</option> <option value="Cruiser">Cruiser</option> <option value="BMX">BMX</option> <option value="Mountain Bike">Mountain Bike</option> <option value="Other Bike">Other Bike</option> </select> </td></tr> <tr><td> Manufacturer<br> <select name="mfg" size="1"> <option value="Schwinn">Schwinn</option> <option value="Mongoose">Mongoose</option> <option value="Sun">Sun</option> <option value="GT">GT</option> <option value="Firmstrong">Firmstrong</option> </select> </td></tr> <tr><td> Model<br> <textarea name="model" rows="0" cols="50"></textarea> </td></tr> <tr><td> Description<br> <textarea name="desc" rows="10" cols="50"></textarea> </td></tr> <tr><td> Photo Path<br> <textarea name="photo_path" rows="0" cols="100"></textarea> </td></tr> <tr><td> <input type="submit">     <input type="reset"> </td></tr> </form> </table> </body> </html> catalog_upload.php as follows: <? include 'config.php'; $id_num=$_POST['id_num']; $type=$_POST['type']; $mfg=$_POST['mfg']; $model=$_POST['model']; $desc=$_POST['desc']; $photo_path=$_POST['photo_path']; include 'opendb.php'; $query = ("insert into 'catalog' (`id_num`, `mfg`, `type`, `model`, `desc`, `photo_path`) values ('$id_num', '$type', '$mfg', '$model', '$desc', '$photo_path')"); mysql_query($query); ?> Script returns no errors on execution of submit... PhpMyadmin shows no rows added to table (catalog) after execution of script.. Any Suggestions appreciated TIA Quote Link to comment Share on other sites More sharing options...
DarkerAngel Posted February 26, 2008 Share Posted February 26, 2008 catalog_upload.php: <?php include 'config.php'; $id_num=$_POST['id_num']; $type=$_POST['type']; $mfg=$_POST['mfg']; $model=$_POST['model']; $desc=$_POST['desc']; $photo_path=$_POST['photo_path']; include 'opendb.php'; $query = ("INSERT INTO catalog (id_num, mfg, type, model, desc, photo_path) values ('', '$type', '$mfg', '$model', '$desc', '$photo_path')"); mysql_query($query) or die("<pre>MySQL Error:\nMySQL Returned: ".mysql_error()."\nQuery: ".$query); ?> EDITED SOURCE Quote Link to comment Share on other sites More sharing options...
captdavid Posted February 26, 2008 Author Share Posted February 26, 2008 Thanks Darker Angel but dumb as it was, doesn't seem to have affected the initial problem Quote Link to comment Share on other sites More sharing options...
DarkerAngel Posted February 26, 2008 Share Posted February 26, 2008 Okay, 1 other thing I seen, you have the action="../php-bin/catalog_upload.php" in the form element in the HTML form change that to an absolute path http://yoursite/php-bin/catalog_upload.php Also add something to the end of the catalog_upload.php like: echo("<b>The Form Was Submitted</b>"); to get some kind of verification that you hit the page Quote Link to comment Share on other sites More sharing options...
captdavid Posted February 26, 2008 Author Share Posted February 26, 2008 Ok, at least the absolute path got a Mysql error; MySQL Error: MySQL Returned: 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 'desc, photo_path) values ('NULL', 'BMX', 'Mongoose', '2008 Brawler', 'BMX Plus!,' at line 1 Query: INSERT INTO catalog (id_num, mfg, type, model, desc, photo_path) values ('NULL', 'BMX', 'Mongoose', '2008 Brawler', 'BMX Plus!, Jan 2008 - The Brawler rocks chromoly tubing, Alex rims, Kenda tires, a solid set of three-piece cranks and is topped off nicely with a pair of Primo grips.', 'http://www.mongoose.com/bmx/MongooseFiles/ProductImages/2590_1_large.jpg') Are Characters in the "desc" possibly causing errors? Quote Link to comment Share on other sites More sharing options...
DarkerAngel Posted February 26, 2008 Share Posted February 26, 2008 desc is a SQL function, that might be why.... change $query = ("INSERT INTO `catalog` (`id_num`, `mfg`, `type`, `model`, `desc`, `photo_path`) values ('', '$type', '$mfg', '$model', '$desc', '$photo_path')"); Quote Link to comment Share on other sites More sharing options...
captdavid Posted February 26, 2008 Author Share Posted February 26, 2008 Killed the error msg, and returned the Form was submitted echo but still no new row in the db table Quote Link to comment Share on other sites More sharing options...
DarkerAngel Posted February 26, 2008 Share Posted February 26, 2008 $query = ("INSERT INTO `catalog` (`mfg`, `type`, `model`, `desc`, `photo_path`) values ( '$type', '$mfg', '$model', '$desc', '$photo_path')"); if that don't work then i'm lost... Quote Link to comment Share on other sites More sharing options...
captdavid Posted February 27, 2008 Author Share Posted February 27, 2008 Resolved... actually the prob last night prior to your last post was a missing mysql_query($query); Thanks again the world is much clearer after some sleep Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.