austin.mad Posted January 2, 2007 Share Posted January 2, 2007 [b][color=red]i could add a new record with the submit part but the update part is not working.i dont get an error message..i need an urgent help..[/color][/b]**************************************<HTML><?phpinclude "config.php";$con =@mysql_connect($server,$user,$pass);//connecting to serverif(!$con) { die("No connection to Database server");}mysql_select_db($db,$con);//select databaseif(isset($submit)){$article_name= $_REQUEST['name'] ;$article_price = $_REQUEST['preis'];$article_brandid = $_REQUEST['brand-name'];$article_text = $_REQUEST['message']; $sql ="INSERT INTO shop_article (article_id, article_brandid, article_name, article_price,article_text, article_image) VALUES ('', '$article_brandid', '$article_name', '$article_price', '$article_text','')"; $result = mysql_query($sql); if(!$result){ echo 'There was a problem inserting your data into the databse please try again later';}else { echo " 1 record added" ; echo "<br><a href=\"myviewdb.php\">Alle Produkte</a>"; } }else if(isset($update)){$article_id= $_REQUEST['article_id'] ;$article_name= $_REQUEST['name'] ;$article_price = $_REQUEST['preis'];$article_brandid =$_REQUEST['brand-name'];$article_text = $_REQUEST['message'];$sql="UPDATE shop_article SET article_name=''$article_name', article_price='$article_price', article_brandid='$article_brandid', article_text='$article_text', WHERE article_id='$article_id' "; $result = mysql_query($sql); echo "Thank you! Information updated.\n"; echo "<br><a href=\"myviewdb.php\">Alle Produkte</a>"; }else if(isset($article_id)){ $sql ="SELECT A.*,B.brand_name from shop_article AS A,shop_brand AS B WHERE A.article_brandid=B.brand_id and article_id='$article_id'"; $result =mysql_query($sql); $myrow = mysql_fetch_array($result);?><form method="post" action="myaddedit.php"> <input type="hidden" name="article_id" value="<?php echo $myrow["$article_id"]; ?>"/> <div align="center"> <table border="0" cellpadding="0" cellspacing="0"> <tr> <td align="right"><div class="txt" id="div2"><b> Name :</b></div></td> <td> </td> <td><input name="name" type="text" style="width: 150px" value="<?php echo $myrow["article_name"];?>" /></td> </tr> <tr> <td> </td> </tr> <tr> <td align="right"><div class="txt" id="div2"><b>Preis :</b></div></td> <td> </td> <td><input name="preis" type="text" style="width: 150px" value="<?php echo $myrow["article_price"];?>" /></td> </tr> <tr> <td> </td> </tr> <tr> <td align="right"><div class="txt" id="div2"><b>Hersteller : </b></div></td> <td> </td> <td><select name="brand-name" style="width: 150px;"> <option selected value=""><?php echo $myrow["brand_name"];?></option> <option value="1">Franzis</option> <option value="2">PowerQuest</option> <option value="3">Macromedia</option> <option value="4">McAfee</option> <option value="5">Suse</option> </select><br></td> </tr> <tr> <td> </td> </tr> <tr> <td width="110" align="right" valign="top"><div class="txt" id="div2"><b>Beschreibung :</b></div></td> <td> </td> <td><textarea name="message" rows="5" style="width: 150px; overflow: auto"><?php echo $myrow["article_text"];?></textarea></td> </tr> </table> <p> <input type="Submit" name="update" value="Update Artikel" /> </p> <p> </p> </div></form><?php}else{?><form method="post" action="myaddedit.php"> <div align="center"> <table border="0" cellpadding="0" cellspacing="0"> <tr> <td align="right"><div class="txt" id="div2"><b> Name :</b></div></td> <td> </td> <td><input name="name" type="text" style="width: 150px" /></td> </tr> <tr> <td> </td> </tr> <tr> <td align="right"><div class="txt" id="div2"><b>Preis :</b></div></td> <td> </td> <td><input name="preis" type="text" style="width: 150px" /></td> </tr> <tr> <td> </td> </tr> <tr> <td align="right"><div class="txt" id="div2"><b>Hersteller : </b></div></td> <td> </td> <td><select name="brand-name" style="width: 150px;"> <option selected value="No Value">---------</option> <option value="1">Franzis</option> <option value="2">PowerQuest</option> <option value="3">Macromedia</option> <option value="4">McAfee</option> <option value="5">Suse</option> </select><br></td> </tr> <tr> <td> </td> </tr> <tr> <td width="110" align="right" valign="top"><div class="txt" id="div2"><b>Beschreibung :</b></div></td> <td> </td> <td><textarea name="message" rows="5" style="width: 150px; overflow: auto"></textarea></td> </tr> </table> <p> <input type="Submit" name="submit" value="Add" /> </p> <p> </p> </div></form><?php}?></HTML> Link to comment https://forums.phpfreaks.com/topic/32614-updating-mysql-table/ Share on other sites More sharing options...
fert Posted January 2, 2007 Share Posted January 2, 2007 change[code]$result = mysql_query($sql);[/code]to[code]$result = mysql_query($sql) or die(mysql_error());[/code] Link to comment https://forums.phpfreaks.com/topic/32614-updating-mysql-table/#findComment-151697 Share on other sites More sharing options...
almightyegg Posted January 2, 2007 Share Posted January 2, 2007 [code=php:0]$sql="UPDATE shop_article SET article_name='$article_name',article_price='$article_price',article_brandid='$article_brandid',article_text='$article_text' WHERE article_id='$article_id'";[/code] Link to comment https://forums.phpfreaks.com/topic/32614-updating-mysql-table/#findComment-151700 Share on other sites More sharing options...
austin.mad Posted January 2, 2007 Author Share Posted January 2, 2007 this is the error returned with$result = mysql_query($sql) or die(mysql_error());You have an error in your SQL syntax near 'Hp colours', article_price='30', article_brandid='5', article_text=' at line 1 Link to comment https://forums.phpfreaks.com/topic/32614-updating-mysql-table/#findComment-151708 Share on other sites More sharing options...
almightyegg Posted January 2, 2007 Share Posted January 2, 2007 copy and paste this exactly:[code]$sql= "UPDATE shop_article SET article_name='$article_name',article_price='$article_price',article_brandid='$article_brandid',article_text='$article_text' WHERE article_id='$article_id'";$result = mysql_query($sql) or die(mysql_error());[/code] Link to comment https://forums.phpfreaks.com/topic/32614-updating-mysql-table/#findComment-151713 Share on other sites More sharing options...
austin.mad Posted January 2, 2007 Author Share Posted January 2, 2007 i have corrected the sql syntax..now i just record updated but when i view the article,its still the same Link to comment https://forums.phpfreaks.com/topic/32614-updating-mysql-table/#findComment-151715 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.