Jump to content

problem with update syntax


redpedia

Recommended Posts

<?
include "config.php";

$id = $_GET['id'];

$query_update=mysql_query("UPDATE article SET article_name='$article_name', 
article_author='$article_author',article_date='$article_date', article_post='$article_post' WHERE id='$id'") 
or die("can't update");
?>

 

hi

i think there is no erorr in code , but it doesn't update or make anything ..

 

where is the problem please ?

Link to comment
Share on other sites

Try this please..........

<?php
include "config.php";

$id = $_GET['id'];
$id=mysql_real_escape_string($_POST['id']);
$article_name=mysql_real_escape_sting($_POST['article_name']);
$article_author=mysql_real_escape_string($_POST['article_author']);
$article_date=mysql_real_escape_string($_POST['article_date']);
$article_post=mysql_real_escape_string($_POST['article_post']);

$query_update="UPDATE article SET article_name='$article_name', 
article_author='$article_author',article_date='$article_date', article_post='$article_post' WHERE id='$id'";

$result=mysql_query($query_update)or die(mysql_error());
?>

Link to comment
Share on other sites

please print back what ur browser sees please........

 

try this should echo update query statement i think it wrong

<?php
include "config.php";

$id = $_GET['id'];
$id=mysql_real_escape_string($_POST['id']);
$article_name=mysql_real_escape_sting($_POST['article_name']);
$article_author=mysql_real_escape_string($_POST['article_author']);
$article_date=mysql_real_escape_string($_POST['article_date']);
$article_post=mysql_real_escape_string($_POST['article_post']);

$query_update="UPDATE article SET article_name='$article_name', 
article_author='$article_author',article_date='$article_date', article_post='$article_post' WHERE id='$id'";

echo $query;

$result=mysql_query($query_update)or die(mysql_error());
?>

Link to comment
Share on other sites

sorry try agin forgot a r lol

<?php
include "config.php";

$id = $_GET['id'];
$id=mysql_real_escape_string($_POST['id']);
$article_name=mysql_real_escape_string($_POST['article_name']);
$article_author=mysql_real_escape_string($_POST['article_author']);
$article_date=mysql_real_escape_string($_POST['article_date']);
$article_post=mysql_real_escape_string($_POST['article_post']);

$query_update="UPDATE article SET article_name='$article_name', 
article_author='$article_author',article_date='$article_date', article_post='$article_post' WHERE id='$id'";

echo $query;

$result=mysql_query($query_update)or die(mysql_error());
?>

Link to comment
Share on other sites

i've found a bug , its n't id , its article_id  ???

 

even this .. your code didn't show any erorr , but still didn't update the records

 

<?php
include "config.php";

//$id = $_GET['id'];
$id=mysql_real_escape_string($_POST['article_id']);
$article_name=mysql_real_escape_string($_POST['article_name']);
$article_author=mysql_real_escape_string($_POST['article_author']);
$article_date=mysql_real_escape_string($_POST['article_date']);
$article_post=mysql_real_escape_string($_POST['article_post']);

$query_update="UPDATE article SET article_name='$article_name', article_author='$article_author',article_date='$article_date', article_post='$article_post' WHERE article_id='$id'";

echo $query;

$result=mysql_query($query_update)or die(mysql_error());
?>

Link to comment
Share on other sites

<?php
include "config.php";

//$id = $_GET['id'];
$id=mysql_real_escape_string($_POST['article_id']);
$article_name=mysql_real_escape_string($_POST['article_name']);
$article_author=mysql_real_escape_string($_POST['article_author']);
$article_date=mysql_real_escape_string($_POST['article_date']);
$article_post=mysql_real_escape_string($_POST['article_post']);

$query_update="UPDATE article SET article_name='$article_name', article_author='$article_author',article_date='$article_date', article_post='$article_post' WHERE article_id='$id'";

echo $query_update;

$result=mysql_query($query_update)or die(mysql_error());
?>

Link to comment
Share on other sites

If you want help, then can you cooperate please.

 

If you post the actual query string generated by your code it will speed up solving what should be a trivial problem.

 

echo $query_update; is the magic line (which was recommended to you) that will display the query on your screen.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.