vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   mysql_fetch_array() error (https://vborg.vbsupport.ru/showthread.php?t=55470)

corsacrazy 07-21-2003 10:36 AM

mysql_fetch_array() error
 
ok i am getting an error after having this query on my index

this is the error

Code:

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

this is the query


Code:

$newestsql=$DB_site->query("SELECT * FROM gal_Object where Freigabe='y' order by newat desc limit 1");
while($newObject=$DB_site->fetch_array($newestsql)) {
$getnewthumb=$DB_site->query_first("SELECT * FROM gal_Pictures where Object='$newObject[ID]' ORDER BY rand() DESC LIMIT 1");
 // get a random pic
        $tmpnew=explode(".",$getnewthumb[filename]);
        $newthumbfilename="gt_".$tmpnew[0].".jpg";
eval( '$newestsql = "' . gettemplate( 'home_newest' ) . '";' );
}


this is line 154

Code:

$this->record = mysql_fetch_array($this->query_id);

noppid 07-21-2003 02:38 PM

Try...

LIMIT 0,1

That's the only thing that jumps out to me.

NTLDR 07-21-2003 02:51 PM

Your only fetching one row, hence you should be using query_first and remove the while loop.

corsacrazy 07-22-2003 06:42 AM

ok so im now trying

Code:

$newestsql=$DB_site->query_first("SELECT * FROM gal_Object where Freigabe='y' order by newat desc limit 0,1");
{
$getnewthumb=$DB_site->query_first("SELECT * FROM gal_Pictures where Object='$newObject[ID]' ORDER BY rand() DESC LIMIT 1");
 // get a random pic
        $tmpnew=explode(".",$getnewthumb[filename]);
        $newthumbfilename="gt_".$tmpnew[0].".jpg";
eval( '$newestsql = "' . gettemplate( 'home_newest' ) . '";' );
}

but its not werking atall

if i remove the { i get a Parse error

NTLDR 07-22-2003 09:54 AM

Neither of the {} are needed as far as I can see with that code segment.

noppid 07-22-2003 01:08 PM

I see Limits which are not needed on query_first.

I see an array element with no single quotes around it.

I see order by rand, but rand() will not equate to a field name, just a number.

filburt1 07-22-2003 01:26 PM

Also, a side note: never, ever query in a loop :)

corsacrazy 07-22-2003 01:32 PM

Quote:

Today at 03:08 PM noppid said this in Post #6


I see an array element with no single quotes around it.


can u show me this please ?

NTLDR 07-22-2003 01:36 PM

Its not stricly needed, but heres what he means:

PHP Code:

$getnewthumb[filename];
$getnewthumb['filename']; 

The second being the prefered way to do it.

corsacrazy 07-22-2003 01:42 PM

:( @ Call to undefined function: mysql_fetch_array()


All times are GMT. The time now is 07:08 AM.

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.01100 seconds
  • Memory Usage 1,738KB
  • 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
  • (4)bbcode_code_printable
  • (1)bbcode_php_printable
  • (1)bbcode_quote_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