Please login or register.

Login with username, password and session length
Advanced search  

News:

You need/want an older version of sNews ? Download an older/unsupported version here.

Author Topic: (SOLVED) Why do MySQL Queries work OK offline but not online?  (Read 7814 times)

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6020
  • Semantically Challenged
    • snews.ca
(SOLVED) Why do MySQL Queries work OK offline but not online?
« on: October 30, 2008, 04:19:43 pm »

I'm hoping someone might have an answer to this topic question.
Yesterday I uploaded my 1.6 Modules project to an online demo location. All mod queries to my "modules" table are working just fine offline.
For some reason... none of them are working in the online location... not one... which really bugs me to no end.
In each case... I bypassed the queries with direct, hard-coded links and they work fine.

Example... a routine to include all module langfile.php files using two variables:
$modules_root = 'modules'; - which is defined as a global near the top of snews.php
$module_title = $r['title']; - which is defined within the query.
Code: [Select]
<?php

function l($variable) {
global 
$modules_root;
if (s('language') != 'EN' && file_exists('snews_'.s('language').'.php')) {
   include('snews_'.s('language').'.php');
} else {
$l = array();

## MODULES: mod 2 - Adds in langfile.php files for Active modules. 
$result mysql_query("SELECT * FROM ".db('prefix')."modules ORDER BY title ASC");
while ($r mysql_fetch_array($result)) {
    $module_title $r['title'];
    if ($r['status'] == 'YES' && file_exists("$modules_root/$module_title/langfile.php")) {
include("$modules_root/$module_title/langfile.php");
    }
# END langfile.php inclusion

?>


Might the problem be because I am running the query before the  // STARTUP function runs?
« Last Edit: October 30, 2008, 07:01:14 pm by Keyrocks »
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

Joost

  • Guest
Re: Why do MySQL Queries work OK offline but not online?
« Reply #1 on: October 30, 2008, 04:49:56 pm »

Might the problem be because I am running the query before the  // STARTUP function runs?
Queries can only be executed (successfully) after function mysql_connect and function mysql_select_db. That's probably done inside //STARTUP.
Logged

jlhaslip

  • Sr. Member
  • ****
  • Karma: 16
  • Posts: 374
    • My snews with AEF Forum site
Re: Why do MySQL Queries work OK offline but not online?
« Reply #2 on: October 30, 2008, 04:52:56 pm »

turn error_reporting on and echo the query on an error.
then run the same query through phpmyadmin to see if there are results coming from it.
Logged
Yes! I have no siggy.

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6020
  • Semantically Challenged
    • snews.ca
Re: Why do MySQL Queries work OK offline but not online?
« Reply #3 on: October 30, 2008, 06:18:46 pm »

turn error_reporting on and echo the query on an error.
then run the same query through phpmyadmin to see if there are results coming from it.

I have error reporting on.
The first clue that queries are not functioning online is that functions... in the files to be included in the routines... are not available... as in "uknown function... in index.php...". The second... is that the language variables in the langfile.php files are not visible.

How does one run the same query through phpmyadmin to see if there are result coming from it...?

Queries can only be executed (successfully) after function mysql_connect and function mysql_select_db. That's probably done inside //STARTUP.

So... I tried relocating the // STARTUP function up to just under the dbase variables array... before any of the modules inclusion routines are executed... it functions OK offline but not online. And... online... any of the routines that come after the // STARTUP function (in its default location) still do not execute.

I tried replacing all the double-quotes in all "IF" and "INCLUDE" strings with single-quotes and wrapped the variables with ". - ." still no worky online but OK offline.
 :'(
« Last Edit: October 30, 2008, 06:23:33 pm by Keyrocks »
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

funlw65

  • Hero Member
  • *****
  • Karma: 96
  • Posts: 771
    • Country Lab
Re: Why do MySQL Queries work OK offline but not online?
« Reply #4 on: October 30, 2008, 06:42:18 pm »

Just put that function inside config.php with all things used in common by snews.php and files from modules and use "include" statement.
Logged

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6020
  • Semantically Challenged
    • snews.ca
Re: Why do MySQL Queries work OK offline but not online?
« Reply #5 on: October 30, 2008, 06:53:11 pm »

Just put that function inside config.php with all things used in common by snews.php and files from modules and use "include" statement.

I don't have a config.php file in this project.
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6020
  • Semantically Challenged
    • snews.ca
Re: (SOLVED) Why do MySQL Queries work OK offline but not online?
« Reply #6 on: October 30, 2008, 07:07:28 pm »

Mystery Solved...I had edited the folder-names in the Modules dbase table to capitalize their first letters... Businesses... for example... which was not recognized in the queries because they are matching up with the actual folder-names which are all lower-case. Once I edited them back to lower-case - all is well. Why did I capitalize their first letters in the modules table? Because I was also using the title from the table to generate the links... and wanted the links to show with Capital letters.

Whewww... had me worried there for a while...  ;D
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

jlhaslip

  • Sr. Member
  • ****
  • Karma: 16
  • Posts: 374
    • My snews with AEF Forum site
Re: (SOLVED) Why do MySQL Queries work OK offline but not online?
« Reply #7 on: October 30, 2008, 07:45:25 pm »

Ah!... the little things in Life...
Logged
Yes! I have no siggy.

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6020
  • Semantically Challenged
    • snews.ca
Re: (SOLVED) Why do MySQL Queries work OK offline but not online?
« Reply #8 on: November 04, 2008, 02:02:23 am »

@Keys.... check out ucwords() AND ucfirst()
Thanks Bob... man... those appear to be real time-savers to overcome what I just did the long way-round. I'll make note of them and try putting them to use.  ;)
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU