GIDForums  

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 07-Jul-2008, 20:12
sidekick sidekick is offline
New Member
 
Join Date: Jul 2008
Posts: 3
sidekick is on a distinguished road

Warning: mysql_query():supplied argument is not a valid MySQL-Link resource


Hi everyone
Please help me. I'm trying to install a script but it comes up with this error message:
"Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in D:\www\www.test4.co.za\....\lang\lang.php on line 35"

This is on lines 35 and 57 which are identical, in red below:

PHP Code:

<?php

//if(!empty($_GET)) extract($_GET);
//if(!empty($_POST)) extract($_POST);

if (isset($_REQUEST['lang'])) {
    $sql = "SELECT * FROM lang WHERE `lang_code`='".$_REQUEST['lang']."'";
    $result = mysql_query($sql, $jb_mysql_link) or die (mysql_error());
    if (mysql_num_rows($result)>0) {
        $_SESSION["LANG"] = strtoupper($_REQUEST["lang"]);
        // save the requested language
        setcookie("SAVED_LANG", strtoupper($_REQUEST["lang"]), 2147483647);
        
    } else {

        $sql = "SELECT * FROM lang WHERE `is_default`='Y'";
        $result = mysql_query($sql, $jb_mysql_link) or die (mysql_error());
        $row = mysql_fetch_array($result, MYSQL_ASSOC);
        $_SESSION["LANG"] = strtoupper($row["lang_code"]);
        // save the requested language
        setcookie("SAVED_LANG", strtoupper($row["lang_code"]), 2147483647);
        echo "Invalid language. Reverting to default language.";
    }
} elseif (!isset($_SESSION["LANG"])) {
    // get the default language, or saved language

    if ($_COOKIE['SAVED_LANG']!='') {
        $_SESSION["LANG"] = strtoupper($_COOKIE['SAVED_LANG']);

    } else {

        $sql = "SELECT * FROM lang WHERE `is_default`='Y' ";
        [b][color="Red"]if ($result = mysql_query ($sql, $jb_mysql_link)) {[/color][/b]
            $row = mysql_fetch_array($result, MYSQL_ASSOC);
            $_SESSION["LANG"] = strtoupper($row['lang_code']);
            if ($row['charset']!='') {
                setlocale(LC_TIME, $row['charset']);
            }
        } else {
            $_SESSION["LANG"] = 'EN';

        }
    }
    
}

global $AVAILABLE_LANGS;
global $LANG_FILES;
global $FCK_LANG_FILES;

// load languages into array.. map the language code to the filename
// if mapping didn't work, default to english..

$sql = "SELECT * FROM lang ";
[b][color="Red"]if ($result = mysql_query ($sql, $jb_mysql_link)) {[/color][/b]
    while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
        $lang_code = strtoupper($row['lang_code']);
        $AVAILABLE_LANGS [$lang_code] = $row['name'];
        $LANG_FILES[$lang_code] = $row['lang_filename'];
        $FCK_LANG_FILES[$lang_code] = $row['fckeditor_lang'];
    }
    
    if (($_SESSION["LANG"] != '') ) {
        include ($LANG_FILES[$_SESSION["LANG"]]);
        
    } else {
        include ("english.php");
    }

} else {
    $DB_ERROR = mysql_error();

}


?>


PLEASE help me

Thanking you in advance
Last edited by admin : 07-Jul-2008 at 20:21. Reason: Please insert your example PHP codes between [PHP] and [/PHP] tags
  #2  
Old 08-Jul-2008, 01:21
Howard_L Howard_L is online now
Regular Member
 
Join Date: Apr 2007
Location: Maryland/PA, USA
Posts: 801
Howard_L is a jewel in the roughHoward_L is a jewel in the roughHoward_L is a jewel in the rough

Re: Warning: mysql_query():supplied argument is not a valid MySQL-Link resource


...So , the error says that on line 35 a "supplied argument is not a valid MySQL-Link resource in D:\www\www.test4.co.za\...."
The line is: $row = mysql_fetch_array($result, MYSQL_ASSOC);

...the arguments are: '$result' and 'MYSQL_ASSOC'

I have only seen mysql_fetch_array( $result ); run without the 'MYSQL_ASSOC' constant in there.
From this: http://www.php.net/mysql_fetch_array I see that it specifies the array type to be returned.
Did you put the MYSQL_ASSOC in there or did it come like that? That may be a problem , but I don't think so.

Something's comming up with that: D:\www\www.test4.co.za we see in the warning.
You can check the values leading up to those arguments to see if they all are as expected.
Try inserting the echo statement below into the corresponding location of your code and see what output you get:
PHP Code:

{      $sql = "SELECT * FROM lang WHERE `is_default`='Y' ";      if ($result = mysql_query ($sql, $jb_mysql_link))        {          echo "\sql='". $sql ."', $jb_mysql_link='". $jb_mysql_link ."', \$result='". $result ."' MYSQL_ASSOC='". MYSQL_ASSOC ."' <br />";         $row = mysql_fetch_array($result, MYSQL_ASSOC);  /*<--problem L35 ****/ 


post back what you get.
Last edited by Howard_L : 08-Jul-2008 at 01:52.
  #3  
Old 19-Jul-2008, 10:36
sidekick sidekick is offline
New Member
 
Join Date: Jul 2008
Posts: 3
sidekick is on a distinguished road

Re: Warning: mysql_query():supplied argument is not a valid MySQL-Link resource


Hi
Thanx for replying. Was away for a while, so sorry for taking so long to post back.
As you may have noticed, this error occurred on my local pc server (windows). I decided to upload the script into a subdomain of one of my live sites, and all worked 100%. It installed perfectly and I could further configure and use it without any issues. The site is linux.
I'm thinking that it maybe configuration of the local server. I have no clue....I usually do everything locally, then upload to live site once I'm ready to launch the site.
Could it be windows?
  #4  
Old 19-Jul-2008, 14:05
Howard_L Howard_L is online now
Regular Member
 
Join Date: Apr 2007
Location: Maryland/PA, USA
Posts: 801
Howard_L is a jewel in the roughHoward_L is a jewel in the roughHoward_L is a jewel in the rough

Re: Warning: mysql_query():supplied argument is not a valid MySQL-Link resource


Your home server is a Windows? Which one?
Can you run other php scripts?
...ones that can manipulate mysql?
I think you can but as you say something is not set up right.
Code:
The error came from something invalid comming back from: $result = mysql_query($sql, $jb_mysql_link) or die (mysql_error()); ...so then the value in $result was invalid and when this line executed: $row = mysql_fetch_array($result, MYSQL_ASSOC); You got an error. To see what it is try printing the value of '$result echo "result= '". $result ." <br /> "; I suspect it will have something sto do with: D:\www\www.test4.co.za\.... Does that file exsist? What is the value in: $jb_mysql_link ? That might be another one to print...
I do not have a home server (especially windows) and so can not be of much help.
But I imagine there are some default file searching parameters which might be a cause... what do you think?
  #5  
Old 19-Jul-2008, 18:28
sidekick sidekick is offline
New Member
 
Join Date: Jul 2008
Posts: 3
sidekick is on a distinguished road

Re: Warning: mysql_query():supplied argument is not a valid MySQL-Link resource


Hi Howard,
My home server is windows xp. All php scripts run, this is the first to give me problems. Mysql works fine with php.
I tried what you suggested, but results still the same: "Warning: mysql_query():supplied argument is not a valid MySQL-Link resource"
I have no clue what's the issue is. I've just about checked everything I suspected.
So frustrating...
Thanks so much for your time and input.
  #6  
Old 19-Jul-2008, 20:27
Howard_L Howard_L is online now
Regular Member
 
Join Date: Apr 2007
Location: Maryland/PA, USA
Posts: 801
Howard_L is a jewel in the roughHoward_L is a jewel in the roughHoward_L is a jewel in the rough

Re: Warning: mysql_query():supplied argument is not a valid MySQL-Link resource


You didn't get any values for either of those variables?
Try putting this echo before the section that errors.
HTML Code:
echo "sql= jb_'". $sql ."' , mysql_link= '". $jb_mysql_link ."' <br /> "; $result = mysql_query($sql, $jb_mysql_link) or die (mysql_error());
...you need to find out what $jb_mysql_link holds,, I don't see it assigned in the code.
What does it hold on the server where you get this script to work?
Last edited by Howard_L : 19-Jul-2008 at 21:43.
 
 

Recent GIDBlogProgramming ebook direct download available by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
run script command on ns2.26 newbie06 Computer Software Forum - Linux 65 19-Aug-2009 08:50
Str_Misaligned in Double Link List Peter_APIIT C Programming Language 1 29-Feb-2008 21:50
Cpanel downgrade MYSQL 4.1.X to MySQL 4.0.xx Webhosting-live Web Hosting Forum 1 01-Sep-2006 03:54
[Include] Doubly-linked List dsmith C Programming Language 6 14-Apr-2006 14:12
gzwrite(): supplied argument is not a valid stream resource in JdS MySQL / PHP Forum 2 24-Mar-2003 08:57

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 10:34.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.