jasonborne Posted February 13, 2014 Share Posted February 13, 2014 Sorry guys I really need help. Have been staring and trying everything tio correct a (probably) obvious error here! My Update query wont fire. Results returned are exactly as strated out. I fear I may be missing the obvious because I have been trying for hours to see where I have gone wrong. The Form works and returns the correct data from the db. I make my changes to update and nothing happens, not even an error! //Sanitize the POST values $adposition = clean($_POST['adposition']); $advertarea = clean($_POST['advertarea']); $adclient = clean($_POST['adclient']); $advertdate = clean($_POST['advertdate']); $advertrate = clean($_POST['advertrate']); $advert = clean($_POST['advert']); $advertstatus = clean($_POST['advertstatus']); //Create update query $sql = "UPDATE vancancies SET adposition='$adposition', advertarea='$advertarea', adclient='$adclient', advertdate='$advertdate', advertrate='$advertrate', advert='$advert', advertstatus='$advertstatus' WHERE advertID='$id'"; $result = @mysql_query($sql); Link to comment Share on other sites More sharing options...
Ingolme Posted February 13, 2014 Share Posted February 13, 2014 An error won't be visible if you use the "@" error suppresor operator. Use mysql_error() to see if the query was badly constructed. It's preferable to use PHP's mysqli or PDO libraries rather than mysql Link to comment Share on other sites More sharing options...
divinedesigns1 Posted February 13, 2014 Share Posted February 13, 2014 you can go in your MySQL and use the sql section to make sure your query is working, or you can do as foxy said Link to comment Share on other sites More sharing options...
jasonborne Posted February 14, 2014 Author Share Posted February 14, 2014 Thanks for the replies. I have a new problem.. I may be dumb but I was getting an error "Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in" in my script. Couldnt figure it out so naturally I started to search for answers. I checked 2 other peoples scripts ran them and I get the same error in their scripts now. Could I have screwed something up in mysql or phpmyadmin that is causing this? Sample: $title=$_POST['title'] ; $author= $_POST['author'] ; $name=$_POST['name'] ; $copy=$_POST['copy'] ; mysql_query("INSERT INTO `books`(Title,Author,PublisherName,CopyrightYear) VALUES ('$title','$author','$name','$copy')"); }?></form><table border="1"> <?php include("db.php"); $result=mysql_query("SELECT * FROM books"); while($test = mysql_fetch_array($result)) <<<<----------ERROR-------------------- { $id = $test['BookID']; echo "<tr align='center'>"; echo"<td><font color='black'>" .$test['BookID']."</font></td>"; echo"<td><font color='black'>" .$test['Title']."</font></td>"; echo"<td><font color='black'>". $test['Author']. "</font></td>"; echo"<td><font color='black'>". $test['PublisherName']. "</font></td>"; echo"<td><font color='black'>". $test['CopyrightYear']. "</font></td>"; echo"<td> <a href ='view.php?BookID=$id'>Edit</a>"; echo"<td> <a href ='del.php?BookID=$id'><center>Delete</center></a>"; echo "</tr>"; } mysql_close($conn); ?> Link to comment Share on other sites More sharing options...
Ingolme Posted February 14, 2014 Share Posted February 14, 2014 We already have a thread addressing this error you have: http://w3schools.invisionzone.com/index.php?showtopic=44106 It comes up so often that there's no point repeating the same answer over and over. Your code is insecure, people could use it to hack your website, look up "SQL injection" to find more information. Link to comment Share on other sites More sharing options...
jasonborne Posted February 14, 2014 Author Share Posted February 14, 2014 Thanks appreciate.. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now