Jump to content

green917

Members
  • Posts

    17
  • Joined

  • Last visited

    Never

Everything posted by green917

  1. Any help any of you gurus could give me here would be greatly appreciated. I have a very simple php/mysql script that opens a template page and displays the title, picture (at least it's supposed to display the pic) and ingredients, etc. from a db table called 'recipes'. In firefox and all other compliant browsers, the whole function works fine. In Internet Explorer however, the images don't display and it simply prints the html img tag out on the user's screen. Please help if you can. Here's the applicable code: $result=mysql_query("SELECT * FROM recipes where id = ".$_GET['id']."") or die("Could not connect to database!"); while($row=mysql_fetch_row($result)) { echo "<h2><center>".$row[1]."</center></h2>\n"; echo "<center><img src='http://www.healthylifestylegourmet.com/images/".$row[4]." width='".$row[5]."' height='".$row[6]."' /> </img></center><br/>\n"; Everything but the picture displays perfectly using virtually the same syntax and, as I said, it works fine in compliant browsers. I'm at a loss and have been staring at it for far too long. Thanks again!
  2. Thank you David AM! That solved the problem. Can't believe I didn't see that extra semi-colon...been looking at it for over an hour. Thanks again! Green917
  3. Hello all, I'm writing a page with a simple database with a table called recipes in it with a series of recipes (go figure). I want to display a list of the recipe titles in ascending alphabetical order with each title linked to another page that displays all of the information about the recipe. I can't seem to get anything to display though (not even the titles) but I'm not getting any errors returned either. It seems as if there is nothing in the table to display (even though there are 40 records there). Any help would be greatly appreciated. Here is the code I have so far: <?php $dbhost = 'localhost'; $dbuser = '*****'; $dbpass = '*****'; $dbname = '*******'; $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to database'); mysql_select_db($dbname) or die('Error selecting the database'); // select data from db to use $result = mysql_query("SELECT * FROM recipes ORDER BY title ASC LIMIT 0,50") or die('mysql_error()'.'Error: ' .mysql_errno() ); //display the data while($row = mysql_fetch_array($result)); { echo"<b><center>Healthy Lifestyle Gourmet Recipes</center></b><br /><br />"; echo "<span class=\"recipelink\"><a href=\"reciperesults.php?id=".$row['id']."\" target=\"_blank\">".$row['title']."</a></span><br/>\n"; } mysql_close(); ?> I starred out the connection variables but, they are all correct in my code (I'm not getting the "or die" errors)
  4. Hey all, Relative newbie here. I am trying to create a script that generates a random image (and the associated title) from my mySQL database. The code doesn't seem to be working as the image is blank and the title does not appear either. A new set of eyes may be able to find the problem. Thanks! <?php include 'open.php'; include 'opendb.php'; $offset_result = mysql_query( " SELECT FLOOR(RAND() * COUNT(*)) AS 'offset' FROM 'recipes' "); $offset_row = mysql_fetch_object( $offset_result ); $offset = $offset_row->offset; $result = mysql_query( " SELECT * FROM 'recipes' LIMIT $offset, 1 " ); print "<table width=\"366\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">"; print "<tr>"; print "<td class=\"recipe_head\">Healthy Lifestyle Gourmet Recipes</td>"; print "<tr>"; print "<td class=\"recipe_title\">{$result['title']}</td>"; print "</tr>"; print "<tr>"; print "<td><image src=\"{$result['image_path'].$result['image_name']}\" height=\"{$result['image_height']}\" width=\"{$result['image_width']}\" /></td>"; print "</tr></table>"; mysql_close(); ?>
  5. I'm testing on IE7 and, like I said, it allegedly can't find the file that's on the server. I'm at a loss =( Green
  6. As requested, here is the code. The DOCTYPE should be correct as I created it in dreamweaver and began it as a php file. Once again, thanks in advance. Green <?php if(isset($_POST['update'])) { $title=$_POST['title']; $desc=$_POST['desc']; $ingr1=$_POST['ingr1']; $ingr2=$_POST['ingr2']; $ingr3=$_POST['ingr3']; $ingr4=$_POST['ingr4']; $ingr5=$_POST['ingr5']; $ingr6=$_POST['ingr6']; $ingr7=$_POST['ingr7']; $ingr8=$_POST['ingr8']; $ingr9=$_POST['ingr9']; $ingr10=$_POST['ingr10']; $ingr11=$_POST['ingr11']; $ingr12=$_POST['ingr12']; $ingr13=$_POST['ingr13']; $ingr14=$_POST['ingr14']; $ingr15=$_POST['ingr15']; $ingr16=$_POST['ingr16']; $ingr17=$_POST['ingr17']; $ingr18=$_POST['ingr18']; $ingr19=$_POST['ingr19']; $ingr20=$_POST['ingr20']; $ingr21=$_POST['ingr21']; $ingr22=$_POST['ingr22']; $ingr23=$_POST['ingr23']; $ingr24=$_POST['ingr24']; $ingr25=$_POST['ingr25']; $instructions=$_POST['instructions']; $cps=$_POST['cps']; $ss=$_POST['ss']; $cal=$_POST['cal']; $fat=$_POST['fat']; $satfat=$_POST['satfat']; $carbs=$_POST['carbs']; $sugar=$_POST['sugar']; $sodium=$_POST['sodium']; $protein=$_POST['protein']; $fiber=$_POST['fiber']; if(!get_magic_quotes_gpc()) { $title=addslashes($title); $desc=addslashes($desc); $ingr1=addslashes($ingr1); $ingr2=addslashes($ingr2); $ingr3=addslashes($ingr3); $ingr4=addslashes($ingr4); $ingr5=addslashes($ingr5); $ingr6=addslashes($ingr6); $ingr7=addslashes($ingr7); $ingr8=addslashes($ingr8); $ingr9=addslashes($ingr9); $ingr10=addslashes($ingr10); $ingr11=addslashes($ingr11); $ingr12=addslashes($ingr12); $ingr13=addslashes($ingr13); $ingr14=addslashes($ingr14); $ingr15=addslashes($ingr15); $ingr16=addslashes($ingr16); $ingr17=addslashes($ingr17); $ingr18=addslashes($ingr18); $ingr19=addslashes($ingr19); $ingr20=addslashes($ingr20); $ingr21=addslashes($ingr21); $ingr22=addslashes($ingr22); $ingr23=addslashes($ingr23); $ingr24=addslashes($ingr24); $ingr25=addslashes($ingr25); $instructions=addslashes($instructions); $cps=addslashes($cps); $ss=addslashes($ss); $cal=addslashes($cal); $fat=addslashes($fat); $satfat=addslashes($satfat); $carbs=addslashes($carbs); $sugar=addslashes($sugar); $sodium=addslashes($sodium); $protein=addslashes($protein); $fiber=addslashes($fiber); } include 'config.php'; $query= "INSERT INTO recipes (title, description, ingr_1, ingr_2, ingr_3, ingr_4, ingr_5, ingr_6, ingr_7, ingr_8, ingr_9, ingr_10, ingr_11, ingr_12, ingr_13, ingr_14, ingr_15, ingr_16, ingr_17, ingr_18, ingr_19, ingr_20, ingr_21, ingr_22, ingr_23, ingr_24, ingr_25, instructions, cps, ss, cal, fat, satfat, carbs, sugar, sodium, protein, fiber)"."VALUES ('$title', '$description', '$ingr1', '$ingr2', '$ingr3', '$ingr4', '$ingr5', '$ingr6', '$ingr7', '$ingr8', '$ingr9', '$ingr10', '$ingr11', '$ingr12', '$ingr13', '$ingr14', '$ingr15', '$ingr16', '$ingr17', '$ingr18', '$ingr19', '$ingr20', '$ingr21', '$ingr22', '$ingr23', '$ingr24', '$ingr25', '$instructions', '$cps', '$ss', '$cal', '$fat', '$satfat', '$carbs', '$sugar', '$sodium', '$protein', '$fiber')"; mysql_query($query) or die('Error ,query failed'); mysql_close($link); print $title . " has been added to the database."; } ?> <!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> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>healthy lifestyle gourmet</title> <style type="text/css"> .conlink a {font-family:Geneva, Arial, Helvetica, sans-serif; font-size:14px; border:1px solid #000000; background-color:#cddf77; color:#000000; text-decoration:none; position:absolute; left:560px; height:18px; width:160px; padding-left:2px; padding-right:2px; text-align:center;} .conlink a:hover {font-family:Geneva, Arial, Helvetica, sans-serif; font-size:14px; border:1px solid black; background-color:#000000; color:#cddf77; text-decoration:none; position:absolute; left:560px; height:18px; width:160px; padding-left:2px; padding-right:2px; text-align:center;} </style> </head> <body> <form method="post" action="<?php echo $PHP_SELF;?>"> <table cellpadding="2" cellspacing="1" align="center" width="960"> <tr> <td class="conlink" colspan="2"><a href="/hlgcon.php" target="_self">List database contents</a></td> </tr> <tr> <td> </td> </tr> <th colspan="8">Add Recipe:</th> <tr> <td width="100">Title</td><td><input name="title" type="text" /></td> </tr> <tr> <td width="100">description</td><td colspan="4"><textarea name="desc" cols="50" rows="5"></textarea></td> </tr> <tr> <td width="100">Ingr. 1</td><td><input name="ingr1" type="text" /></td> <td width="100">Ingr. 2</td><td><input name="ingr2" type="text" /></td> <td width="100">Ingr. 3</td><td><input name="ingr3" type="text" /></td> <td width="100">Ingr. 4</td><td><input name="ingr4" type="text" /></td> </tr> <tr> <td width="100">Ingr. 5</td><td><input name="ingr5" type="text" /></td> <td width="100">Ingr. 6</td><td><input name="ingr6" type="text" /></td> <td width="100">Ingr. 7</td><td><input name="ingr7" type="text" /></td> <td width="100">Ingr. 8</td><td><input name="ingr8" type="text" /></td> </tr> <tr> <td width="100">Ingr. 9</td><td><input name="ingr9" type="text" /></td> <td width="100">Ingr. 10</td><td><input name="ingr10" type="text" /></td> <td width="100">Ingr. 11</td><td><input name="ingr11" type="text" /></td> <td width="100">Ingr. 12</td><td><input name="ingr12" type="text" /></td> </tr> <tr> <td width="100">Ingr. 13</td><td><input name="ingr13" type="text" /></td> <td width="100">Ingr. 14</td><td><input name="ingr14" type="text" /></td> <td width="100">Ingr. 15</td><td><input name="ingr15" type="text" /></td> <td width="100">Ingr. 16</td><td><input name="ingr16" type="text" /></td> </tr> <tr> <td width="100">Ingr. 17</td><td><input name="ingr17" type="text" /></td> <td width="100">Ingr. 18</td><td><input name="ingr18" type="text" /></td> <td width="100">Ingr. 19</td><td><input name="ingr19" type="text" /></td> <td width="100">Ingr. 20</td><td><input name="ingr20" type="text" /></td> </tr> <tr> <td width="100">Ingr. 21</td><td><input name="ingr21" type="text" /></td> <td width="100">Ingr. 22</td><td><input name="ingr22" type="text" /></td> <td width="100">Ingr. 23</td><td><input name="ingr23" type="text" /></td> <td width="100">Ingr. 24</td><td><input name="ingr24" type="text" /></td> </tr> <tr> <td width="100">Ingr. 25</td><td><input name="ingr25" type="text" /></td> </tr> <tr> <td width="100">Instructions</td> <td colspan="8"><textarea name="instructions" cols="104" rows="10"></textarea></td> </tr> <tr> <td width="100">Cals/serving</td><td><input name="cps" type="text" /></td> <td width="100">serving size</td><td><input name="ss" type="text" /></td> <td width="100">Calories</td><td><input name="cal" type="text" /></td> <td width="100">Total fat</td><td><input name="fat" type="text" /></td> </tr> <tr> <td width="100">Saturated fat</td><td><input name="satfat" type="text" /></td> <td width="100">Carbohydrates</td><td><input name="carbs" type="text" /></td> <td width="100">Sugar</td><td><input name="sugar" type="text" /></td> <td width="100">Sodium</td><td><input name="sodium" type="text" /></td> </tr> <tr> <td width="100">protein</td><td><input name="protein" type="text" /></td> <td width="100">fiber</td><td><input name="fiber" type="text" /></td> </tr> <tr> <td colspan="8" align="center"><input name="update" type="submit" value="add recipe" /></td> </tr> </table> </form> <br /><br /> </body> </html>
  7. Hi all, I have a strange conundrum. I have a simple html form with a php script that updates a mysql database. The page has a standard www.h...com/xyz.php format. It loads and functions fine in firefox but when you type the address into Internet Explorer, it says it can't find the file. Anyone have any ideas as to why that may be? I contacted the web host and was told to submit a scripting ticket that may take 4 days (in other words, they were no help). I know there will be someone here who can help...this place never fails me! Thanks in advance! Green
  8. I'm attempting to create a very basic cms, wherein an enduser can change multiple pieces of data within the database from a single page. I have 4 basic tables that need to be changed. 1 of them is a little more advanced than the others with the ability to delete items from the database rather than simply the ability to update the info. The first is a bio section and the second is a table of recipes with the delete function built into it. I finally got the delete function to work but am unclear as to how to integrate the update scripts for the other tables into the same php script (or if that's even the correct way to do it.) Any help would be greatly appreciated. green delete function <?php if (isset ($_POST['rec_delete'])) { include 'config.php'; $id = $_POST['hidden_id']; $del = 'DELETE FROM recipes WHERE id="$id"'; $result = mysql_query($del,$link); echo 'Recipe has been deleted'; echo '<br /><br /><a href="/hlgcon.php">Back to database contents</a>'; } else{ include 'config.php'; $sql = "SELECT id,title FROM recipes ORDER BY title"; $rresult = mysql_query($sql,$link); ?> update function(once again, I'm unsure how to combine these 2 scripts into 1 that runs the whole page with less database calls, etc.) <?php if ($_POST['bio_update']) { header('Location: http://.php'); //header location removed } else{ include 'config.php'; $bio = "SELECT id, bio_text FROM bio ORDER BY id"; $bresult = mysql_query($bio,$link); mysql_close($link); } ?> html & php display loops <body> <form name="bioitem" action="<?php echo $PHP_SELF ?>" method="post"> <table width="650" border="1" cellpadding="2" cellspacing="1"> <tr><th width="100%" colspan="4" style="background-color:#cddf77;"><center>Bio</center></th></tr> <tr><th>id</th><th>bio text</th><th>update?</th></tr> <?php while ($row = mysql_fetch_array($bresult)) { echo '<tr><td>'.$row['id'].'</td>'; echo '<td>'.$row['bio_text'].'</td>'; echo '<td><center><input type="submit" name="bio_update" value="update" /></center></td></tr>'; } ?> </table> <form name="recitem" action="<?php echo $PHP_SELF ?>" method="post"> <table width="650" border="1" cellpadding="2" cellspacing="1"> <tr><th width="100%" colspan="4" style="background-color:#cddf77;"><center>Recipes</center></th></tr> <tr><th>id</th><th>title</th><th>delete?</th></tr> <?php while($row = mysql_fetch_array($rresult)) { echo '<tr><td>'.$row['id'].'</td>'; echo '<td>'.$row['title'].'</td>'; echo '<td><center><input type="hidden" name="recipe_id" value="' . $row['id'] . '" /><input type="submit" name="rec_delete" value="delete" /></center></td>'; echo '</tr>'; } echo '<TR><td width="100%" height="30" valign="center" colspan="4"><center><a href="/hlgup.php"><img src="recipebtn.gif" border="0"></a></center></td></TR>'; ?> </table> </form> </body>
  9. Thank you all so much for all of your help. This solved my issue and taught me some important syntax lessons about php I didn't know before. I really appreciate the help. Green
  10. Sorry for not getting this but, I still can't get it to delete the record. I updated the code by inserting a hidden input named "hidden_id" and passed it in a variable before establishing $query. The code is below. Thanks for all of your help again <?php if (isset ($_POST['delete'])) { include 'config.php'; $id = $_POST['hidden_id']; $del = 'DELETE FROM recipes WHERE id="$id"'; $result = mysql_query($del,$link); echo 'Recipe has been deleted'; echo '<br /><br /><a href="/hlgcon.php">Back to database contents</a>'; } else{ include 'config.php'; $sql = "SELECT id,title FROM recipes ORDER BY title"; $result = mysql_query($sql,$link); ?> <!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> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <link rel="stylesheet" href="concss.css" type="text/css"> </head> <body> <form name="recitem" action="<?php echo $PHP_SELF ?>" method="post"> <table width="650" border="1" cellpadding="2" cellspacing="1"> <tr><th width="100%" colspan="4" style="background-color:#cddf77;"><center>Recipes</center></th></tr> <tr><th>id</th><th>title</th><th>delete?</th></tr> <?php while($row = mysql_fetch_array($result)) { echo '<tr><td>'.$row['id'].'</td>'; echo '<td>'.$row['title'].'</td>'; echo '<td><center><input type="hidden" name="hidden_id" value="$row[id]" /><input type="submit" name="delete" value="delete" /></center></td>'; echo '</tr>'; } echo '<TR><td width="100%" height="30" valign="center" colspan="4"><center><a href="/hlgup.php"><img src="recipebtn.gif" border="0"></a></center></td></TR>'; mysql_close($link); ?> </table> </form> </body> </html> <?php } ?>
  11. Thanks for the help but, after changing the $query and defining $id as $id = $row['id']; prior to the aforementioned $query, the function still isn't working. Any more help you can provide me is greatly appreciated as, obviously, I'm rather new to this stuff. if (isset ($_POST['delete'])) { include 'config.php'; $id = $row['id']; $query = 'DELETE FROM recipes WHERE id="$id"'; $result = mysql_query($query,$link); echo 'Recipe has been deleted'; echo '<br /><br /><a href="/hlgcon.php">Back to database contents</a>'; } else{ include 'config.php'; $sql = "SELECT id,title FROM recipes ORDER BY title"; $result = mysql_query($sql,$link); ?>
  12. Hi all, I have a basic table for the site I'm writing that has a delete function for each record that should delete the record from the database. When you click the "delete" button, it appears to executes the command but, when I return to the contents table via the link I coded in, the record I was attempting to delete is still there. I have a feeling I may be calling the variable incorrectly in the mysql query called $query. The code follows. Any help would be greatly appreciated. Thank you in advance. <?php include 'config.php'; if ($_POST['delete']) { $query = "DELETE FROM recipes WHERE $id = '$id'"; $result = mysql_query($query,$link); echo 'Recipe has been deleted'; echo '<br /><br /><a href="/hlgcon.php">Back to database contents</a>'; } else{ $sql = "SELECT id,title FROM recipes ORDER BY title"; $result = mysql_query($sql,$link); ?> <!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> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <link rel="stylesheet" href="concss.css" type="text/css"> </head> <body> <form name="recitem" action="<?php echo $PHP_SELF ?>" method="post"> <table width="650" border="1" cellpadding="2" cellspacing="1"> <tr><th width="100%" colspan="3" style="background-color:#cddf77;"><center>Recipes</center></th></tr> <tr><th>id</th><th>title</th><th>delete?</th></tr> <?php while($row = mysql_fetch_array($result)) { echo '<tr><td>'.$row['id'].'</td>'; echo '<td>'.$row['title'].'</td>'; echo '<td><center><input type="submit" name="delete" value="delete" /></center></td>'; echo '</tr>'; } echo '<TR><td width="100%" height="30" valign="center" colspan="3"><center><a href="/hlgup.php"><img src="recipebtn.gif" border="0"></a></center></td></TR>'; mysql_close($link); ?> </table> </form> </body> </html> <?php } ?>
  13. Thanks for the help, I realized there was a character before the php tag that was throwing it off but, I wouldn't have even looked for that without your input. Thanks again. Green
  14. Hi all, I'm having some trouble with an issue I've encountered on a page I'm writing. I'm relatively new to php and mysql coding and have set up a simple table and php function that updates my mySql db when the user clicks a submit button in the form. That part of the code is working fine but I would like to add a page redirect on the same button that sends the user to another page which lists the contents of the db table they are updating. I don't want to use an auto redirect for fear that they wont get the information input before the redirect and, when I attempt to place an additional "header: ('Location: ...../...php') call at the end of the function, I get an error that I can't change the header. Any help would be greatly appreciated! Thanks in advance. <form method="post"> <table cellpadding="2" cellspacing="1" align="center" width="960"> <th colspan="8">Add Recipe:</th> <tr> <td width="100">Title</td><td><input name="title" type="text" /></td> </tr> <tr> <td width="100">description</td><td colspan="4"><textarea name="desc" cols="50" rows="5"></textarea></td> </tr> <tr> <td width="100">Ingr. 1</td><td><input name="ingr1" type="text" /></td> <td width="100">Ingr. 2</td><td><input name="ingr2" type="text" /></td> <td width="100">Ingr. 3</td><td><input name="ingr3" type="text" /></td> <td width="100">Ingr. 4</td><td><input name="ingr4" type="text" /></td> </tr> <tr> <td width="100">Ingr. 5</td><td><input name="ingr5" type="text" /></td> <td width="100">Ingr. 6</td><td><input name="ingr6" type="text" /></td> <td width="100">Ingr. 7</td><td><input name="ingr7" type="text" /></td> <td width="100">Ingr. 8</td><td><input name="ingr8" type="text" /></td> </tr> <tr> <td width="100">Ingr. 9</td><td><input name="ingr9" type="text" /></td> <td width="100">Ingr. 10</td><td><input name="ingr10" type="text" /></td> <td width="100">Ingr. 11</td><td><input name="ingr11" type="text" /></td> <td width="100">Ingr. 12</td><td><input name="ingr12" type="text" /></td> </tr> <tr> <td width="100">Ingr. 13</td><td><input name="ingr13" type="text" /></td> <td width="100">Ingr. 14</td><td><input name="ingr14" type="text" /></td> <td width="100">Ingr. 15</td><td><input name="ingr15" type="text" /></td> <td width="100">Ingr. 16</td><td><input name="ingr16" type="text" /></td> </tr> <tr> <td width="100">Ingr. 17</td><td><input name="ingr17" type="text" /></td> <td width="100">Ingr. 18</td><td><input name="ingr18" type="text" /></td> <td width="100">Ingr. 19</td><td><input name="ingr19" type="text" /></td> <td width="100">Ingr. 20</td><td><input name="ingr20" type="text" /></td> </tr> <tr> <td width="100">Ingr. 21</td><td><input name="ingr21" type="text" /></td> <td width="100">Ingr. 22</td><td><input name="ingr22" type="text" /></td> <td width="100">Ingr. 23</td><td><input name="ingr23" type="text" /></td> <td width="100">Ingr. 24</td><td><input name="ingr24" type="text" /></td> </tr> <tr> <td width="100">Ingr. 25</td><td><input name="ingr25" type="text" /></td> </tr> <tr> <td width="100">Instructions</td> <td colspan="8"><textarea name="instructions" cols="104" rows="10"></textarea></td> </tr> <tr> <td width="100">Cals/serving</td><td><input name="cps" type="text" /></td> <td width="100">serving size</td><td><input name="ss" type="text" /></td> <td width="100">Calories</td><td><input name="cal" type="text" /></td> <td width="100">Total fat</td><td><input name="fat" type="text" /></td> </tr> <tr> <td width="100">Saturated fat</td><td><input name="satfat" type="text" /></td> <td width="100">Carbohydrates</td><td><input name="carbs" type="text" /></td> <td width="100">Sugar</td><td><input name="sugar" type="text" /></td> <td width="100">Sodium</td><td><input name="sodium" type="text" /></td> </tr> <tr> <td width="100">protein</td><td><input name="protein" type="text" /></td> <td width="100">fiber</td><td><input name="fiber" type="text" /></td> </tr> <tr> <td colspan="8" align="center"><input name="update" type="submit" value="add recipe" onclick="Javascript:move();" /></td> </tr> </table> </form> <?php if(isset($_POST['update'])) { $title=$_POST['title']; $desc=$_POST['desc']; $ingr1=$_POST['ingr1']; $ingr2=$_POST['ingr2']; $ingr3=$_POST['ingr3']; $ingr4=$_POST['ingr4']; $ingr5=$_POST['ingr5']; $ingr6=$_POST['ingr6']; $ingr7=$_POST['ingr7']; $ingr8=$_POST['ingr8']; $ingr9=$_POST['ingr9']; $ingr10=$_POST['ingr10']; $ingr11=$_POST['ingr11']; $ingr12=$_POST['ingr12']; $ingr13=$_POST['ingr13']; $ingr14=$_POST['ingr14']; $ingr15=$_POST['ingr15']; $ingr16=$_POST['ingr16']; $ingr17=$_POST['ingr17']; $ingr18=$_POST['ingr18']; $ingr19=$_POST['ingr19']; $ingr20=$_POST['ingr20']; $ingr21=$_POST['ingr21']; $ingr22=$_POST['ingr22']; $ingr23=$_POST['ingr23']; $ingr24=$_POST['ingr24']; $ingr25=$_POST['ingr25']; $instructions=$_POST['instructions']; $cps=$_POST['cps']; $ss=$_POST['ss']; $cal=$_POST['cal']; $fat=$_POST['fat']; $satfat=$_POST['satfat']; $carbs=$_POST['carbs']; $sugar=$_POST['sugar']; $sodium=$_POST['sodium']; $protein=$_POST['protein']; $fiber=$_POST['fiber']; if(!get_magic_quotes_gpc()) { $title=addslashes($title); $desc=addslashes($desc); $ingr1=addslashes($ingr1); $ingr2=addslashes($ingr2); $ingr3=addslashes($ingr3); $ingr4=addslashes($ingr4); $ingr5=addslashes($ingr5); $ingr6=addslashes($ingr6); $ingr7=addslashes($ingr7); $ingr8=addslashes($ingr8); $ingr9=addslashes($ingr9); $ingr10=addslashes($ingr10); $ingr11=addslashes($ingr11); $ingr12=addslashes($ingr12); $ingr13=addslashes($ingr13); $ingr14=addslashes($ingr14); $ingr15=addslashes($ingr15); $ingr16=addslashes($ingr16); $ingr17=addslashes($ingr17); $ingr18=addslashes($ingr18); $ingr19=addslashes($ingr19); $ingr20=addslashes($ingr20); $ingr21=addslashes($ingr21); $ingr22=addslashes($ingr22); $ingr23=addslashes($ingr23); $ingr24=addslashes($ingr24); $ingr25=addslashes($ingr25); $instructions=addslashes($instructions); $cps=addslashes($cps); $ss=addslashes($ss); $cal=addslashes($cal); $fat=addslashes($fat); $satfat=addslashes($satfat); $carbs=addslashes($carbs); $sugar=addslashes($sugar); $sodium=addslashes($sodium); $protein=addslashes($protein); $fiber=addslashes($fiber); } include 'config.php'; $query= "INSERT INTO recipes (title, description, ingr_1, ingr_2, ingr_3, ingr_4, ingr_5, ingr_6, ingr_7, ingr_8, ingr_9, ingr_10, ingr_11, ingr_12, ingr_13, ingr_14, ingr_15, ingr_16, ingr_17, ingr_18, ingr_19, ingr_20, ingr_21, ingr_22, ingr_23, ingr_24, ingr_25, instructions, cps, ss, cal, fat, satfat, carbs, sugar, sodium, protein, fiber)"."VALUES ('$title', '$description', '$ingr_1', '$ingr_2', '$ingr_3', '$ingr_4', '$ingr_5', '$ingr_6', '$ingr_7', '$ingr_8', '$ingr_9', '$ingr_10', '$ingr_11', '$ingr_12', '$ingr_13', '$ingr_14', '$ingr_15', '$ingr_16', '$ingr_17', '$ingr_18', '$ingr_19', '$ingr_20', '$ingr_21', '$ingr_22', '$ingr_23', '$ingr_24', '$ingr_25', '$instructions', '$cps', '$ss', '$cal', '$fat', '$satfat', '$carbs', '$sugar', '$sodium', '$protein', '$fiber')"; mysql_query($query) or die('Error ,query failed'); mysql_close($link); } ?>
  15. my apologies, posted to the wrong forum. Meant to put into the php forum
  16. Hi there, I am relatively new to php and mysql and am attempting to create a database update script for my website. I have a table with a php function to update the database with a new recipe. I would like, however, to redirect the page to another page containing a list of what's in the database when the user clicks "submit" to upload the new recipe. I don't want to use an automatic redirect (meta tag) but, I can't make header: ('.../...php'); work. Code follows and any help would be greatly appreciated. Please feel free to contact me at my email listed on my profile here. Thanks again! Green Code: <form method="post"> <table cellpadding="2" cellspacing="1" align="center" width="960"> <th colspan="8">Add Recipe:</th> <tr> <td width="100">Title</td><td><input name="title" type="text" /></td> </tr> <tr> <td width="100">description</td><td colspan="4"><textarea name="desc" cols="50" rows="5"></textarea></td> </tr> <tr> <td width="100">Ingr. 1</td><td><input name="ingr1" type="text" /></td> <td width="100">Ingr. 2</td><td><input name="ingr2" type="text" /></td> <td width="100">Ingr. 3</td><td><input name="ingr3" type="text" /></td> <td width="100">Ingr. 4</td><td><input name="ingr4" type="text" /></td> </tr> <tr> <td width="100">Ingr. 5</td><td><input name="ingr5" type="text" /></td> <td width="100">Ingr. 6</td><td><input name="ingr6" type="text" /></td> <td width="100">Ingr. 7</td><td><input name="ingr7" type="text" /></td> <td width="100">Ingr. 8</td><td><input name="ingr8" type="text" /></td> </tr> <tr> <td width="100">Ingr. 9</td><td><input name="ingr9" type="text" /></td> <td width="100">Ingr. 10</td><td><input name="ingr10" type="text" /></td> <td width="100">Ingr. 11</td><td><input name="ingr11" type="text" /></td> <td width="100">Ingr. 12</td><td><input name="ingr12" type="text" /></td> </tr> <tr> <td width="100">Ingr. 13</td><td><input name="ingr13" type="text" /></td> <td width="100">Ingr. 14</td><td><input name="ingr14" type="text" /></td> <td width="100">Ingr. 15</td><td><input name="ingr15" type="text" /></td> <td width="100">Ingr. 16</td><td><input name="ingr16" type="text" /></td> </tr> <tr> <td width="100">Ingr. 17</td><td><input name="ingr17" type="text" /></td> <td width="100">Ingr. 18</td><td><input name="ingr18" type="text" /></td> <td width="100">Ingr. 19</td><td><input name="ingr19" type="text" /></td> <td width="100">Ingr. 20</td><td><input name="ingr20" type="text" /></td> </tr> <tr> <td width="100">Ingr. 21</td><td><input name="ingr21" type="text" /></td> <td width="100">Ingr. 22</td><td><input name="ingr22" type="text" /></td> <td width="100">Ingr. 23</td><td><input name="ingr23" type="text" /></td> <td width="100">Ingr. 24</td><td><input name="ingr24" type="text" /></td> </tr> <tr> <td width="100">Ingr. 25</td><td><input name="ingr25" type="text" /></td> </tr> <tr> <td width="100">Instructions</td> <td colspan="8"><textarea name="instructions" cols="104" rows="10"></textarea></td> </tr> <tr> <td width="100">Cals/serving</td><td><input name="cps" type="text" /></td> <td width="100">serving size</td><td><input name="ss" type="text" /></td> <td width="100">Calories</td><td><input name="cal" type="text" /></td> <td width="100">Total fat</td><td><input name="fat" type="text" /></td> </tr> <tr> <td width="100">Saturated fat</td><td><input name="satfat" type="text" /></td> <td width="100">Carbohydrates</td><td><input name="carbs" type="text" /></td> <td width="100">Sugar</td><td><input name="sugar" type="text" /></td> <td width="100">Sodium</td><td><input name="sodium" type="text" /></td> </tr> <tr> <td width="100">protein</td><td><input name="protein" type="text" /></td> <td width="100">fiber</td><td><input name="fiber" type="text" /></td> </tr> <tr> <td colspan="8" align="center"><input name="update" type="submit" value="add recipe" onclick="Javascript:move();" /></td> </tr> </table> </form> <?php if(isset($_POST['update'])) { $title=$_POST['title']; $desc=$_POST['desc']; $ingr1=$_POST['ingr1']; $ingr2=$_POST['ingr2']; $ingr3=$_POST['ingr3']; $ingr4=$_POST['ingr4']; $ingr5=$_POST['ingr5']; $ingr6=$_POST['ingr6']; $ingr7=$_POST['ingr7']; $ingr8=$_POST['ingr8']; $ingr9=$_POST['ingr9']; $ingr10=$_POST['ingr10']; $ingr11=$_POST['ingr11']; $ingr12=$_POST['ingr12']; $ingr13=$_POST['ingr13']; $ingr14=$_POST['ingr14']; $ingr15=$_POST['ingr15']; $ingr16=$_POST['ingr16']; $ingr17=$_POST['ingr17']; $ingr18=$_POST['ingr18']; $ingr19=$_POST['ingr19']; $ingr20=$_POST['ingr20']; $ingr21=$_POST['ingr21']; $ingr22=$_POST['ingr22']; $ingr23=$_POST['ingr23']; $ingr24=$_POST['ingr24']; $ingr25=$_POST['ingr25']; $instructions=$_POST['instructions']; $cps=$_POST['cps']; $ss=$_POST['ss']; $cal=$_POST['cal']; $fat=$_POST['fat']; $satfat=$_POST['satfat']; $carbs=$_POST['carbs']; $sugar=$_POST['sugar']; $sodium=$_POST['sodium']; $protein=$_POST['protein']; $fiber=$_POST['fiber']; if(!get_magic_quotes_gpc()) { $title=addslashes($title); $desc=addslashes($desc); $ingr1=addslashes($ingr1); $ingr2=addslashes($ingr2); $ingr3=addslashes($ingr3); $ingr4=addslashes($ingr4); $ingr5=addslashes($ingr5); $ingr6=addslashes($ingr6); $ingr7=addslashes($ingr7); $ingr8=addslashes($ingr8); $ingr9=addslashes($ingr9); $ingr10=addslashes($ingr10); $ingr11=addslashes($ingr11); $ingr12=addslashes($ingr12); $ingr13=addslashes($ingr13); $ingr14=addslashes($ingr14); $ingr15=addslashes($ingr15); $ingr16=addslashes($ingr16); $ingr17=addslashes($ingr17); $ingr18=addslashes($ingr18); $ingr19=addslashes($ingr19); $ingr20=addslashes($ingr20); $ingr21=addslashes($ingr21); $ingr22=addslashes($ingr22); $ingr23=addslashes($ingr23); $ingr24=addslashes($ingr24); $ingr25=addslashes($ingr25); $instructions=addslashes($instructions); $cps=addslashes($cps); $ss=addslashes($ss); $cal=addslashes($cal); $fat=addslashes($fat); $satfat=addslashes($satfat); $carbs=addslashes($carbs); $sugar=addslashes($sugar); $sodium=addslashes($sodium); $protein=addslashes($protein); $fiber=addslashes($fiber); } include 'config.php'; $query= "INSERT INTO recipes (title, description, ingr_1, ingr_2, ingr_3, ingr_4, ingr_5, ingr_6, ingr_7, ingr_8, ingr_9, ingr_10, ingr_11, ingr_12, ingr_13, ingr_14, ingr_15, ingr_16, ingr_17, ingr_18, ingr_19, ingr_20, ingr_21, ingr_22, ingr_23, ingr_24, ingr_25, instructions, cps, ss, cal, fat, satfat, carbs, sugar, sodium, protein, fiber)"."VALUES ('$title', '$description', '$ingr_1', '$ingr_2', '$ingr_3', '$ingr_4', '$ingr_5', '$ingr_6', '$ingr_7', '$ingr_8', '$ingr_9', '$ingr_10', '$ingr_11', '$ingr_12', '$ingr_13', '$ingr_14', '$ingr_15', '$ingr_16', '$ingr_17', '$ingr_18', '$ingr_19', '$ingr_20', '$ingr_21', '$ingr_22', '$ingr_23', '$ingr_24', '$ingr_25', '$instructions', '$cps', '$ss', '$cal', '$fat', '$satfat', '$carbs', '$sugar', '$sodium', '$protein', '$fiber')"; mysql_query($query) or die('Error ,query failed'); mysql_close($link); } ?>
×
×
  • 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.