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

Reply
 
Thread Tools Display Modes
  #1  
Old 10-14-2002, 11:00 AM
Entourage Entourage is offline
 
Join Date: Apr 2002
Posts: 42
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Strange Error on working PHP

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in www/htdocs/test/admin/db_mysql.php on line 154

PHP Code:
$currenthits=$DB_site->query_first("SELECT hits FROM main WHERE id=1");
$negertje=$currenthits['hits'] + 1;
$DB_site->query_first("UPDATE main SET hits=$negertje WHERE id=1"); 
TABLE main (
hits int(10) NOT NULL default '0',
id tinyint(4) NOT NULL default '1'
) TYPE=MyISAM;

It all works but gives that stupid error :/ why o why?
Reply With Quote
  #2  
Old 10-14-2002, 04:07 PM
DrkFusion's Avatar
DrkFusion DrkFusion is offline
 
Join Date: Nov 2001
Posts: 1,926
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ah Yes, I get this same error, are you running on a server with Ensim Administration?

-nOX
Reply With Quote
  #3  
Old 10-14-2002, 04:08 PM
Velocd's Avatar
Velocd Velocd is offline
 
Join Date: Mar 2002
Location: CA University
Posts: 1,696
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The error is probably caused because you are using query_first instead of query. Also, this method would be easier and save you a query:

PHP Code:
$DB_site->query("UPDATE main SET hits=hits+1 WHERE id=1"); 
Reply With Quote
  #4  
Old 10-14-2002, 04:08 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

if you run queries with no output you can't use query_first, just use query.
Because query_first is a call of query and then uses fetch_array once.

so correct it would be:
PHP Code:
$currenthits=$DB_site->query_first("SELECT hits FROM main WHERE id=1");
$negertje=$currenthits['hits'] + 1;
$DB_site->query("UPDATE main SET hits=$negertje WHERE id=1"); 
and if you don't need your $negertje and currenthits values anymore you can save a query by doing just this:
PHP Code:
$DB_site->query("UPDATE main SET hits=hits+1 WHERE id=1"); 
Reply With Quote
  #5  
Old 10-14-2002, 04:09 PM
DrkFusion's Avatar
DrkFusion DrkFusion is offline
 
Join Date: Nov 2001
Posts: 1,926
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yes, but Ensim has some sort of universal problem, with this fetch_array thing, its a continued problem for me as well.

-Arunan
Reply With Quote
  #6  
Old 10-14-2002, 04:12 PM
DrkFusion's Avatar
DrkFusion DrkFusion is offline
 
Join Date: Nov 2001
Posts: 1,926
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I get this error
Code:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/virtual/site19/fst/var/www/html/support/admin/db_mysql.php on line 149
Reply With Quote
  #7  
Old 10-14-2002, 04:13 PM
DrkFusion's Avatar
DrkFusion DrkFusion is offline
 
Join Date: Nov 2001
Posts: 1,926
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Here is the php
PHP Code:
if ($string!="") {
      
$condition.=" AND linkname LIKE '%".addslashes($string)."%' OR linkdesc LIKE '%".addslashes($string)."%'";
    }

$search=$DB_site->query_first("SELECT linkid,catagoryid,linkname,linkdesc FROM gportal_weblinkslink ORDER BY linkname");

while (
$results=$DB_site->fetch_array($search)) {
    
$linkid $results['linkid'];
    
$linkname $results['linkname'];
    
$linkdesc $results['linkdesc'];
    
$hits $results['hits'];

 eval(
"\$resultbits .= \"".gettemplate("drkslinks_linkbit")."\";");
}

eval(
"\$navigation = \"".gettemplate("drkslinks_navigation")."\";");
eval(
"dooutput(\"".gettemplate('drkslinks_searchresults')."\");");; 
Reply With Quote
  #8  
Old 10-14-2002, 04:55 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

arunan: also you have to cut out the _first of your query call..

you cannot use fetch_array with query_first
the outputtype of query is a mysql result, this is what you can use in fetch_array.
the outputtype of query_first is just a normal array not a mysql result so you can't use it with fetch_array
Reply With Quote
  #9  
Old 10-14-2002, 05:15 PM
DrkFusion's Avatar
DrkFusion DrkFusion is offline
 
Join Date: Nov 2001
Posts: 1,926
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks Xenon, worked great!

-Arunan
Reply With Quote
  #10  
Old 10-14-2002, 06:03 PM
DrkFusion's Avatar
DrkFusion DrkFusion is offline
 
Join Date: Nov 2001
Posts: 1,926
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hey Xenon, the stuff are getting listed, but they all get listed now, not just the ones with the key words :'(
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:00 AM.


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.04628 seconds
  • Memory Usage 2,261KB
  • 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
  • (1)bbcode_code
  • (5)bbcode_php
  • (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
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)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