Current location: Hot Scripts Forums » Programming Languages » PHP » Can't connect to mysql in include file when included in forums


Can't connect to mysql in include file when included in forums

Reply
  #1 (permalink)  
Old 07-11-04, 11:29 PM
Forse Forse is offline
New Member
 
Join Date: Jul 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Unhappy Can't connect to mysql in include file when included in forums

Hello folks. I am sorry for weird description in topic, but I dunno how else to describe it. I have an include file (navigation menu) where I must establish connection to local mysql server and get couple of rows...everything works fine when file is included on normal pages, but when I include it in my forum code (which is invision power board 1.3) I get this message:

Quote:
Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /configure/config.php on line 540

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /configure/config.php on line 541
Here is my connect code which is nothing unusual:
Code:
$db = mysql_pconnect($varz['settings']['mysql']['host'], $varz['settings']['mysql']['user'], $varz['settings']['mysql']['pass']) or report_msql_error(mysql_error,true);
mysql_select_db($varz['settings']['mysql']['database'],$db) or report_msql_error(mysql_error,true);
Forums and website use same database and same username/login. I use persistent connection coz I server is dedicated to that site and it's mysql driven so it reduces the load a little. I also tried using different login/password (2 accounts for website and one for forums), but it's no go. It seems as php can't connect to mysql if code I am trying to run is in forums.

This must be confusing, sorry. But it's been pain in you know where. I have read mysql docs, googled and searched many forums...still nothing.

Any help is welcome, I thank you in advance!
Reply With Quote
  #2 (permalink)  
Old 07-12-04, 06:34 AM
georgian georgian is offline
New Member
 
Join Date: Jul 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Is the $db getting reinitalized somewhere in the forum code.....

Try echo $db; the line after you make the database connectioin and the line before you need it in the mysql_query....

See if the value are the same.... If there not, that's why you sql querys are working.... To fix it, rename your $db to something different....

Hope this helps..
Reply With Quote
  #3 (permalink)  
Old 07-12-04, 07:39 PM
Forse Forse is offline
New Member
 
Join Date: Jul 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Unhappy

Quote:
Originally Posted by georgian
Is the $db getting reinitalized somewhere in the forum code.....

Try echo $db; the line after you make the database connectioin and the line before you need it in the mysql_query....

See if the value are the same.... If there not, that's why you sql querys are working.... To fix it, rename your $db to something different....

Hope this helps..
Tried renaming it...no go But thxn for reply
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP and MySQL ? rob2132 Hot Scripts Forum Questions, Suggestions and Feedback 4 08-29-08 02:22 AM
Excel document containing records, need to save as a text file to upload to mysql bearslife PHP 1 06-05-04 03:24 AM
Error while creating database (Errornumber 2002: "Can't connect to local MySQL server lylesback2 PHP 5 04-11-04 01:37 PM
how to import a png file from mysql database. rani PHP 1 01-16-04 03:34 AM
Upload file to table so ONLY files tied to primary key are displayed in record? grafixDummy PHP 4 12-20-03 04:28 PM


All times are GMT -5. The time now is 05:11 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.