vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Strange Error on working PHP (https://vborg.vbsupport.ru/showthread.php?t=44608)

Entourage 10-14-2002 11:00 AM

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? :(

DrkFusion 10-14-2002 04:07 PM

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

-nOX

Velocd 10-14-2002 04:08 PM

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"); 


Xenon 10-14-2002 04:08 PM

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"); 


DrkFusion 10-14-2002 04:09 PM

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

-Arunan

DrkFusion 10-14-2002 04:12 PM

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

DrkFusion 10-14-2002 04:13 PM

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')."\");");; 


Xenon 10-14-2002 04:55 PM

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

DrkFusion 10-14-2002 05:15 PM

Thanks Xenon, worked great!

-Arunan

DrkFusion 10-14-2002 06:03 PM

Hey Xenon, the stuff are getting listed, but they all get listed now, not just the ones with the key words :'(


All times are GMT. The time now is 03:52 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01027 seconds
  • Memory Usage 1,744KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (5)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete