azezah Posted February 9, 2010 Share Posted February 9, 2010 I have a code line which is function register_update_image( $ITEM ){ $imagetitle = htmlspecialchars(strip_tags(nl2br($_POST["imagetitle"]))); $imagedesc = htmlspecialchars(strip_tags(nl2br($_POST["imagedesc"]))); $imagecredit = htmlspecialchars(strip_tags(nl2br($_POST["imagecredit"]))); $imagekeys = htmlspecialchars(strip_tags(nl2br($_POST["imagekeys"]))); $collectionurl = htmlspecialchars(strip_tags(nl2br($_POST["collectionurl"]))); $imageurl = htmlspecialchars(strip_tags(nl2br($_POST["imageurl"]))); if ($imageurl != "") { if (!preg_match("/^http/",$imageurl)) { $imageurl = "http://".$imageurl; } $imagefile = $imageurl; $success = $imageurl; } global $userid; $query = "UPDATE items SET url = '$collectionurl' where item = '$ITEM';"; $database->setQuery($query); $database->query(); the html form is function image_form1( $ITEM ) { echo "<form enctype='multipart/form-data' action='index.php?option=com_classification&task=register_image1' method='post' name='imageuploader' onsubmit='return validate1(this);'> <input type='hidden' name='MAX_FILE_SIZE' value='5242880' /> <table width='90%' border='0' cellspacing='1' cellpadding='1' align='center'> <td valign='top'>"; $itemval = $_GET['item']; echo "$itemval"; echo "</td> <tr><td colspan='2'>Fields marked with an asterisk (*) are required.</td></tr> <tr><td width='30%'><label for='editedimage'>Image path: *</label></td> <td><input name='editedimage' type='file' class='inputbox'/></td></tr> <tr><td colspan='2'>OR</td></tr> <tr><td><label for='imageurl'>Image URL: *</label></td> <td><input type='text' name='imageurl' value='' size='58' maxlength='150' class='inputbox'/></td></tr> <tr><td><label for='imagetitle'>Title: *</td> <td><input type='text' name='imagetitle' size='58' maxlength='150' class='inputbox'/></td></tr> <tr><td>Description:</td> <td><textarea name='imagedesc' rows='5' cols='50'></textarea></td></tr> <tr><td>Credit:</td> <td><input type='text' name='imagecredit' value='' size='58' maxlength='150' class='inputbox'/></td></tr> <tr><td>Keyword(s):</td> <td><input type='text' name='imagekeys' value='' size='58' maxlength='150' class='inputbox'/></td></tr> <tr><td>Collection URL:</td> <td><input type='text' name='collectionurl' size='58' maxlength='150' class='inputbox' /></td></tr> <tr><td colspan='2' align='center'><input type='submit' name='Edit Image' class='button' value='Edit'/> </td></tr> <tr><td> </td></tr></table> </form> <script type='text/javascript'> function validate1(frm) { if ((frm.uploadedimage.value == '') && (frm.imageurl.value == '')) { alert('Please, enter the image path or URL.'); return false; } if (frm.imagetitle.value=='') { alert('Please, enter title.'); return false; } return true; } the update query is not working. Link to comment https://forums.phpfreaks.com/topic/191555-update-database-with-php-forms/ Share on other sites More sharing options...
Hussam Posted February 10, 2010 Share Posted February 10, 2010 I think you can't expect much answers from people with this kind of question: The code is missing alot of things as far as I am concerned, there should be a class file and other code seems to be missing, also try to put your code in php bbcode tags in the forum so we can see better. The first thing I can see wrong, is using methods of a class without instantiating an object from the class, unless you did that somewhere else in the code and didn't post it. $database->setQuery($query); $database->query(); good luck! Link to comment https://forums.phpfreaks.com/topic/191555-update-database-with-php-forms/#findComment-1009801 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.