• You are not logged in. | Login

Post a reply

January 18, 2007 1:00 pm

mastaweb99
Member
Ranks

Data changing

I need to add some changes to the database. I'm trying to do this using the following code:

<?php
if(isset($_POST['reg'])) {
$id=$_POST['id'];
$name=$_POST['name'];
$author=$_POST['author'];
$news=$_POST['news'];
$date=$_POST['date'];

}


$dbhost ="localhost";
$dbuser ="root";
$dbpassword ="root";
$dbname ="db";
$link = mysql_connect($dbhost, $dbuser, $dbpassword);


$query = "update news set name='$name', author='$author', news='$news', date='$date' where id='$id'";

$result = mysql_query($query, $link) or die(mysql_error());


?>

But nothing happens


 

 

January 18, 2007 1:03 pm

IBdaMac
Member
Ranks

Re: Data changing

mysql_select_db


 

 

January 18, 2007 1:05 pm

mdwb
Member
Ranks

Re: Data changing

Try to insert in the beginning of the script:

error_reporting(E_ALL);


Don't be afraid of life, it is yours!

 

 

January 18, 2007 1:16 pm

cplusplus
Member
Ranks

Re: Data changing

Database isn't selected in the code


 

 

January 18, 2007 1:17 pm

mastaweb99
Member
Ranks

Re: Data changing

IBdaMac, I added it but nothing happens


 

 

January 18, 2007 1:20 pm

mdwb
Member
Ranks

Re: Data changing

Have you set the error_reporting()?
Does anything happen?
Show print ($query);


Don't be afraid of life, it is yours!

 

 

January 18, 2007 1:20 pm

mastaweb99
Member
Ranks

Re: Data changing

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'where id='1'' at line 1


 

 

January 18, 2007 1:22 pm

mastaweb99
Member
Ranks

Re: Data changing

Oh, I've done it! updown
Thanks for everybody

Last edited by mastaweb99 (January 18, 2007 1:26 pm)


 

 
  • Actions
  • Top
ITCrimea. Ukraine Web Development Company. Professional Developers and Web Designers Team
Custom Web Designs, Internet Applications, E-Commerce Websites, Interactive Sites, Database-Driven Sites and Services