Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions

Reply
 
Thread Tools Display Modes
  #11  
Old 05-07-2008, 08:21 AM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Thanks for the help but that bit of code gives me the error
Please post the entire part of the code where this query is executed and the rows are read.
Reply With Quote
  #12  
Old 05-07-2008, 09:48 AM
PhilMcKrackon PhilMcKrackon is offline
 
Join Date: Apr 2008
Posts: 47
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Eikinskjaldi View Post
"timecolumn" is whatever field in your database contains the dateline data

its kicking an error because you dont actually have a field called "timecolumn"


It looks like your field is called dateline, so the sql is

[sql]
SELECT linkid,linkurl FROM adv_links
ORDER by linkid ASC
WHERE unix_timestamp() - dateline <= 3600*48
[/sql]
That was my fault, I posted the code before I had edited it. Here is the code that I used and I still get the invalid MYSQL result resource in the fetch_array.

PHP Code:
//$urls = mysql_query("SELECT linkid,linkurl FROM adv_links ORDER by linkid ASC");
$urls mysql_query("SELECT linkid,linkurl FROM adv_links ORDER by linkid ASC WHERE unix_timestamp() - dateline <= 3600*48");
while (
$urlrow mysql_fetch_array($urls)) {
fwrite($file," ");
fwrite($file$urlrow[1]);
fwrite($file" | "); 
fwrite($file," ");
fwrite($file$urlrow[0]);
fwrite($file," \n");
}
fclose($file); 
?> 
And the error
Quote:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/*****/public_html/pagevisD.php on line 13
I'm wondering if I have the edquotes in the wrong postion? The commented '//' out line is the original query line that works. I made sure that there was new data in the table during the last 48 hours so that the query should always yield a result. If I add 'dateline' to the query and add a fwrite for $urlrow[2] the date in the table is written to the file so dateline is the correct field.

Quote:
Please post the entire part of the code where this query is executed and the rows are read.
Marco, I used the same code above with the SQL query you supplied.

Thanks,
Reply With Quote
  #13  
Old 05-07-2008, 10:00 AM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

PHP Code:
$urls mysql_query("SELECT linkid,linkurl FROM adv_links ORDER by linkid ASC WHERE dateline > " . (TIMENOW - (24 60 60))); 
while (
$urlrow mysql_fetch_array($urls)) { 
fwrite($file," "); 
fwrite($file$urlrow[1]); 
fwrite($file" | ");  
fwrite($file," "); 
fwrite($file$urlrow[0]); 
fwrite($file," \n"); 

fclose($file);  
?> 
Should work, providing that you have a valid MySQL database connection. (maybe post the entire script).
Reply With Quote
  #14  
Old 05-07-2008, 10:18 AM
PhilMcKrackon PhilMcKrackon is offline
 
Join Date: Apr 2008
Posts: 47
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks again but I still get the same error. I'm sure the DB connection is good as I can use the original query with no problems. I'm going to post the entire code also. Sorry to be of so much trouble.
Quote:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/*****/public_html/pagevisE.php on line 13
PHP Code:
<?php
#!/usr/lib/php
// Creates Text Input for PageVisualize
$host "localhost";
$mysql_user "*****";
$mysql_password "*****";
$sdatabase "******";
$slink mysql_connect("$host""$mysql_user""$mysql_password") or die('Database Connection Failed. Wait a moment.');
mysql_select_db ("$sdatabase"$slink);
$file fopen("TestPhpD.txt""w");
//$urls = mysql_query("SELECT linkid,linkurl FROM adv_links ORDER by linkid ASC");
$urls mysql_query("SELECT linkid,linkurl FROM adv_links ORDER by linkid ASC WHERE dateline > " . (TIMENOW - (24 60 60)));
while (
$urlrow mysql_fetch_array($urls)) {
fwrite($file," ");
fwrite($file$urlrow[1]);
fwrite($file" | ");
fwrite($file," ");
fwrite($file$urlrow[0]);
fwrite($file," \n");
}
fclose($file);
?>
Reply With Quote
  #15  
Old 05-07-2008, 10:48 AM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Lol, mistake (in all these examples!!) you get by editing code and not read good what the result is.

The following is valid:
PHP Code:
$urls mysql_query("SELECT linkid,linkurl FROM adv_links WHERE dateline > " . (time() - (24 60 60)) . " ORDER by linkid ASC"); 
- ORDER must be after the WHERE clause (can't believe everyone, including myself, made this same mistake)
- TIMENOW is only defined within a vBulletin environment, so replace by time()
Reply With Quote
  #16  
Old 05-07-2008, 10:57 AM
PhilMcKrackon PhilMcKrackon is offline
 
Join Date: Apr 2008
Posts: 47
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Sucess! I was not aware that ORDER must always follow WHERE. I thank you ALL very much!

Regards,
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:53 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05813 seconds
  • Memory Usage 2,234KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (4)bbcode_php
  • (5)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (6)post_thanks_box
  • (6)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (6)post_thanks_postbit_info
  • (6)postbit
  • (6)postbit_onlinestatus
  • (6)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete