Help Needed in executing sql query

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
stanvy
Forum Newbie
Posts: 2
Joined: Mon Nov 10, 2008 4:18 am

Help Needed in executing sql query

Post 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!
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: Help Needed in executing sql query

Post 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.
There are 10 types of people in this world, those who understand binary and those who don't
stanvy
Forum Newbie
Posts: 2
Joined: Mon Nov 10, 2008 4:18 am

Re: Help Needed in executing sql query

Post 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! :)
Post Reply