Page 1 of 1

Help Needed in executing sql query

Posted: Mon Nov 10, 2008 4:23 am
by stanvy
Hi there,

First of, I'm new to this forum and thanks so much for providing this wonderful forum.

I'm trying to develop a simple code to execute mysql query but it doesnt work, here's my code:


<?php
$con = mysql_connect('localhost', 'coach_wrdp1a', '12345');


if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("coach_wrdp1", $con);

mysql_query("UPDATE wp-posts SET post_status = 'publish'
WHERE post_status='future' AND post_date <= now()");

mysql_close($con);
?>

can someone tell me what did I do wrong here? when I run the files on browser, it doesn't show any error, but my database just didn't update at all.

I double check my login info, db name and user rights, there's no problem out there.

Really appreciate if someone can help here, thanks!

Re: Help Needed in executing sql query

Posted: Mon Nov 10, 2008 4:39 am
by VladSun
Your code looks good.

Run a select query:
[sql]SELECT     post_statusFROM    wp-postsWHERE     post_status='future' AND post_date <= now()[/sql]
in your front-end SQL client (e.g. PHPmyAdmin) to check whether there are records to be matched by your UPDATE query.

Re: Help Needed in executing sql query

Posted: Mon Nov 10, 2008 4:49 am
by stanvy
VladSun wrote:Your code looks good.

Run a select query:
[sql]SELECT     post_statusFROM    wp-postsWHERE     post_status='future' AND post_date <= now()[/sql]
in your front-end SQL client (e.g. PHPmyAdmin) to check whether there are records to be matched by your UPDATE query.

LOL, I make a mistake on column name, thanks so much VladSun, everything works wonders now! :)