Jump to content

PHP with Mysql using AND problem.


sx

Recommended Posts

Hi again.  I have the following statement.

 

$query2 = "SELECT title,tid,start_date,last_post FROM ibf_topics WHERE (forum_id = '$forums') AND (start_date > '$beginstamped') AND (start_date < '$endstamped') ORDER BY start_date DESC";

 

It works fine. But I want to add another where after the forum_id.  I want it to get the rows from ibf_topics where forum id is $forums OR parent_id is $forums, like this.

 

$query2 = "SELECT title,tid,start_date,last_post FROM ibf_topics WHERE (forum_id = '$forums') && (parent_id = '$forums') AND (start_date > '$beginstamped') AND (start_date < '$endstamped') ORDER BY start_date DESC";

 

But when I make the change I get this error.

 

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/wherewes/public_html/backup/linkbot/linkbot.php on line 73

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/wherewes/public_html/backup/linkbot/linkbot.php on line 74

 

The only thing that changes is the addition of hte parent_id.  If I remove it that error goes away. What am I doing wrong??

Link to comment
Share on other sites

try:

$query2 = "SELECT title,tid,start_date,last_post FROM ibf_topics WHERE (forum_id = '$forums') AND (parent_id = '$forums') AND (start_date > '$beginstamped') AND (start_date < '$endstamped') ORDER BY start_date DESC";

 

?? you dont make much sense

 

 

Link to comment
Share on other sites

Ok.  here is what this is.  This is LinkBOT.  This program is for a couple of sites that use Invision Power Boards forums.  The user selects a forum and a beginning date and end date.  Then hits "go".  The script goes into their database and gets the topics that were started within the selected dates.  It then goes into the posts table and gets all posts associated with those topics.  Then it extracts the links from those posts and checks them to see if they are live links or dead links.  LinkBOT supports many file host services. If ALL links within a post are live and supported it will insert a tag within the post that the links were checked by LinkBOT on such and such date ran by such and such user.  If dead links are found it inserts a report in the report forum with the problem so that staff can fix it.  I already have it fully functional EXCEPT for being able to select parent forums.  You must select each individual forum you want checked.  If you select a forum and there are subforums in it, LinkBOT will not check the subforums.  I am trying to enable the subforums in it.  Here is a rundown of the vairables.

 

$forums = The forum ID number of the forum that the staff member wanted to check.

$beginstamped =  Unix time stamp ( 1 minute after midnight morning of date selected to begin check on.

$endstmaped = Unix time stamp (1 minute before midnight night of date selected to end check on.

start_date = the Mysql table colum that has teh date the topic was started stored.

parent_id = the mysql table column that has the id of the forum that that the current forum is a subforum of.

 

I am wanting the user to select a forum.

 

When LinkBOT checks for topcis within that forum I want it to also get topics that are within forums that are SUBFORUMS (whre the selected forum is in the parent_id column) effectively including any subforums in the check if there are any subforums.

 

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.