Jump to content

Recommended Posts

I have a table nordstromlisting with column datecreated filled with a unix timestamp of when the listing was created. I essentially want to delete all listings older than 5 days (432000 seconds), so I created the following sql. However, it's not working.

 

Anybody see what I'm doing wrong?

 

Thanks.

 

		$timenow = date("Y-m-d");
		$time = strtotime($timenow);

		$movetohistory = mysql_query("SELECT * INTO nordstromhistory FROM nordstromlisting WHERE '$time' - datecreated > 432000");
		$deltefromlisting = mysql_query("DELETE * FROM nordstromlisting WHERE '$time' - datecreated > 432000");	

Link to comment
https://forums.phpfreaks.com/topic/157031-solved-date-problem/
Share on other sites

There's no such thing as SELECT * INTO .... At least I don't think so.

 

Change this:

$movetohistory = mysql_query("SELECT * INTO nordstromhistory FROM nordstromlisting WHERE '$time' - datecreated > 432000");

 

To:

$movetohistory = mysql_query("SELECT * INTO nordstromhistory FROM nordstromlisting WHERE '$time' - datecreated > 432000") or die(mysql_error());

 

That should display some error if there is one.

Link to comment
https://forums.phpfreaks.com/topic/157031-solved-date-problem/#findComment-827278
Share on other sites

You're right, the syntax is messed up becuase for one INTO doesn't show up in the proper color, and the error it gives me is 'undefined variable: nordstromhistory'

 

However, the w3 http://www.w3schools.com/sql/sql_select_into.asp does it that way?

 

Thanks in advance.

Link to comment
https://forums.phpfreaks.com/topic/157031-solved-date-problem/#findComment-827296
Share on other sites

A strange bit is that ''undefined variable: nordstromhistory'' is a PHP notice, not a MySQL error... Is that all you get?

 

[edit]

Seems I was wrong about what SELECT INTO is about :P

http://dev.mysql.com/doc/refman/5.0/en/select-into-statement.html

 

What you need is  INSERT ... SELECT

 

INSERT INTO nordstromhistory SELECT ... FROM nordstromlisting WHERE '$time' - datecreated > 432000

 

http://dev.mysql.com/doc/refman/5.1/en/insert-select.html

Link to comment
https://forums.phpfreaks.com/topic/157031-solved-date-problem/#findComment-827308
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.