MySQL Forums
Forum List  »  PHP

Trouble with updating Mysql table data
Posted by: Oliver Snyder
Date: March 21, 2012 01:15PM

Any help will really make my day

<!-- form to get key detail of record in database -->
<form name="form" method="POST" action="library_search.php">
Puplication ID number <input type="text" name="search"> <br><br>
<input type="submit" value="submit">
</form>

I have no problem passing the variable from above to the search file below.

$search=$_POST['search'];

$data = 'SELECT * FROM `library` WHERE `index` = "'.$search.'"';
$query = mysql_query($data) or die("Couldn't execute query. ". mysql_error());
$data2 = mysql_fetch_array($query);

But I keep getting this error

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/mdwvo/public_html/aabees.org/library_results.php on line 12

when trying to pass it to the results file below which should update the table.

$Index=$_POST['indexfield'];
$Title=$_POST['titlefield'];
$Arthor=$_POST['authorfield'];


$data = "UPDATE `library` SET title='$Title', author='$Author', WHERE "'.$search.'"';
$query = mysql_query($data) or die("Couldn't execute query. ". mysql_error());

I never get the die message.

Options: ReplyQuote


Subject
Written By
Posted
Trouble with updating Mysql table data
March 21, 2012 01:15PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.