Board index   FAQ   Search  
Register  Login
Board index PHP PHP Scripts

SQL UPDATE VIA PHP

Links for php scripts

Moderators: macek, egami, gesf

SQL UPDATE VIA PHP

Postby montv3 » Wed Jul 03, 2013 3:57 am

Hi i have small problem and i hope that someone goan help me :D. I cant update mysql database via php, adn when i try to UPDATE i get only new row. All i want is to delete old data after update, but this code keep it. WHy???


elseif(isset($_POST["update_post"]))
{

$a = $db->prepare("UPDATE BLOG_NEWS SET Post_Title = :title, Post_Text = :text WHERE Post_Id = :id");
$a->bindValue(":title",$_SESSION["post_title"], PDO::PARAM_STR);
$a->bindValue(":text",$_SESSION["post_text"], PDO::PARAM_STR);

$a->bindValue(":id",$_SESSION["post_id"], PDO::PARAM_STR);
try{
$a->execute();
}
catch (PDOException $e)
{
die('Connection failed: ' . $e->getMessage());
}
}
montv3
New php-forum User
New php-forum User
 
Posts: 7
Joined: Wed May 15, 2013 3:46 am

Re: SQL UPDATE VIA PHP

Postby johnj » Mon Jul 08, 2013 6:29 am

...when i try to UPDATE i get only new row.

What do you mean by "new row".? When you update a row, certain fields will be changed, else it will not be updated. Other option for you is to manually delete and insert a new row.
johnj
php-forum Super User
php-forum Super User
 
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm


Return to PHP Scripts

Who is online

Users browsing this forum: Majestic-12 [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron