Page 1 of 1

problem w/ MySQL - works localy but not on web HELP

Posted: Sun Jun 04, 2006 11:21 pm
by alexus
Ok... im going to crash my monitor if its not goint t get working :evil:

Here what I have: dual layer SQL, works perfectly fine on local server, but when i uploade file to the web server nothing is working... grrr i alredy spend 3 days trying all possible things that i could and couldnt think of... and the worthest thing is that id doesnt return the error... well the problem is w. sendond SQL statement when i type select ID manually like "27" it works fine but not dinamocaly

So here is the code:

Code: Select all

<?
include("db_conn.php");
$db = mysql_connect($db_server, $db_user, $db_pass);
mysql_select_db($db_name, $db);

$i = "0";
$img_dir = "img_banners/";
$sql_banner = "select * from uc_front_banner WHERE active='Yes'";
$result_banner = mysql_query($sql_banner);
while ($row_banner = mysql_fetch_array($result_banner)) {
	$ddelay = $row_banner['rotate_time']; 
 	$banner_id = $row_banner['id'];
       echo "$banner_id<br>";
	$sql = "select * from uc_front_banner_file WHERE event='$banner_id'";
    $result = mysql_query($sql);
	while ($row_news = mysql_fetch_array($result)) {
    ?>  
 		fadeimages[<? echo $i; ?>]=["<? echo "$img_dir". $row_news['file'] .""; ?>", "", ""] //plain image syntax
        <?
        $i = $i+1;
    }
} 
$ddelay = $ddelay * 666; 
echo "var ddelay = '$ddelay'";

?>
Here is output on local server:

Code: Select all

27
fadeimages[0]=["img_banners/index-zzz_19.jpg", "", ""] //plain image syntax fadeimages[1]=["img_banners/bg_pink.jpg", "", ""] //plain image syntax var ddelay = '666'
And here is output on remore web server

Code: Select all

var ddelay = '0'

Apresiate any help, I wont survive 4th day w/ this! Please help!
Thanks!

Posted: Sun Jun 04, 2006 11:55 pm
by bdlang
I would assume your connection parameters are different for the remote server than they are for the local one, have you checked that (i.e. the values within db_conn.php) or that the included file actually exists on the remote system? A way to troubleshoot (since you have literally none in your code):

Code: Select all

require("db_conn.php"); // require() will kill the script if the file isn't found

$db = mysql_connect($db_server, $db_user, $db_pass)
    OR die('Connection error:<br />' .mysql_error());

mysql_select_db($db_name, $db)
    OR die('Database error:<br />'. mysql_error());
etc ad nauseum with your mysql_* function calls.

And BTW, there are alot of coders on the forum here that would be happy to build an application, script, help you troubleshoot in exchange for monetary compensation. If I was 3 days into something that I absolutely had to get done but couldn't figure out, I might consider it.


BTW, you're assigning the string "0" to the variable $i, not an integer value. May work, may not.

Posted: Mon Jun 05, 2006 6:24 pm
by alexus
Damn im going crazy, I opened my page today and it was working hmmmm now i opened the page and it doesnt :-(

How come?

Posted: Mon Jun 05, 2006 6:32 pm
by alexus
PHP is not an old lamp based TV come it either works or it dosnt :-(

also my bd_conn.php has this code, nothing to cause trouble:
(I took off passwords, but they are tere in the file :-P

Code: Select all

<?
//Database Vars Next:

$db_server="**********";
$db_user="********";
$db_pass="********";

$db_name="*********";

//Global Vars
$admin_email="alexus@alexus.com";
?>
Also I did add DIE statements for db connect and open, nerrors are therer




the only thing I could think of now is that MySQL server has to many connections open so it refuses to open new one... that what I have when I was writing VB programm, but then it should eithr feez or give back an error

eeeeeeeeee any ideas?

Posted: Mon Jun 05, 2006 6:38 pm
by alexus
Hey look it finally decided to give me an error on local server :-)
Warning: mysql_query(): Unable to save result set in c:\program files\apache group\apache\htdocs\template_9837_bu54w0isvwh26c90uh42\site\fp_banner.php on line 33

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in c:\program files\apache group\apache\htdocs\template_9837_bu54w0isvwh26c90uh42\site\fp_banner.php on line 34
var ddelay = '0'
Now what can couse to me to return not valid argument so that it cant save it?

Posted: Mon Jun 05, 2006 6:54 pm
by RobertGonzalez
Have no idea on problem number 1. Number 2 is because you are trying to fetch a dataset from a result variable that is not really a result, possibly caused by problem 1.

Posted: Mon Jun 05, 2006 6:56 pm
by alexus
damn i dont even know what to write...
let be ran them seperatly... lets see what will i get?

Posted: Mon Jun 05, 2006 7:06 pm
by RobertGonzalez
Easiest thing to do is start small. Script out a db connect and check it for errors. Then select a database and check for errors. Then run a select query that does not actually select data from a table (like "SELECT NOW()") and check for errors. Then hit a table and check for errors. Then loop through the result and check for errors.

It seems lengthy, but it might help identify the problem.

Posted: Mon Jun 05, 2006 7:09 pm
by alexus
how dp i do this:
Then loop through the result and check for errors.

Posted: Mon Jun 05, 2006 7:29 pm
by alexus
ok just tried this and it work, but it exactly the same code as i had before, I just add text output to see where we at.

Code: Select all

<?
//Parameters Setup
$enable_debug = 1;

//Connecting To DB
require("db_conn.php");
$db = mysql_connect($db_server, $db_user, $db_pass)
	OR die('Connection error:<br />' .mysql_error());
mysql_select_db($db_name, $db)
	OR die('Database error:<br />'. mysql_error()); 
    
//Debug Point #1
if($enable_debug ==1){ echo "1. Connected and Opened  DB<br>";}

//Selecting Layer 1
$sql_banner = "select * from uc_front_banner WHERE active='Yes'";
$result_banner = mysql_query($sql_banner);

//Debug Point #2
if($enable_debug ==1){ echo "2. I selected all banners where status active (should be one banner)<br>";}


while ($row_banner = mysql_fetch_array($result_banner)) {
	echo "Selected Row ID: ". $row_banner['id'] ."<br>";
    //$ddelay = $row_banner['rotate_time']; 
 	$banner_id = $row_banner['id'];
    echo "Assigning variable Banner_ID = $banner_id<br>";	
}
//Debug Point #3
if($enable_debug ==1){ echo "3. Just exited first while statement, carring Banner_ID assigned<br>";}

////////////////////////////////////////
//Second SQL HERE
////////////////////////////////////////

$sql_file = "select * from uc_front_banner_file WHERE event='$banner_id'";
$result_file = mysql_query($sql_file);

//Debug Point #4
if($enable_debug ==1){ echo "4. Selected second SQL statement using Banner ID ($banner_id) as event search parameter<br>";}

while ($row_file = mysql_fetch_array($result_file)) {
  //echo "Entered SECOND WHILE statement Trying to select file<br>";   
  echo "File: ". $row_file['file'] ."<br>";
}
echo "Exited SECOND while<br>";    

echo "=========================================<br>";
echo "Manual SELECT for event 27<br>";
$sql_file = "select * from uc_front_banner_file WHERE event='27'";
$result_file = mysql_query($sql_file);
while ($row_file = mysql_fetch_array($result_file)) {
  //echo "Entered SECOND WHILE statement Trying to select file<br>";   
  echo "File: ". $row_file['file'] ."<br>";
}
?>

Posted: Mon Jun 05, 2006 7:36 pm
by alexus
oh sorry update,,,, its fine on local server, but not fine on remote :oops:


here the remote served doesnt want to return me row ID

Code: Select all

while ($row_banner = mysql_fetch_array($result_banner)) {
	echo "Selected Row ID: ". $row_banner['id'] ."<br>";
    //$ddelay = $row_banner['rotate_time']; 
 	$banner_id = $row_banner['id'];
    echo "Assigning variable Banner_ID = $banner_id<br>";	
}
I dono why, its live we dont want to execute SELECT

(but the damn thing works on another page :roll: i hope? i didnt uload other pages

Posted: Mon Jun 05, 2006 11:35 pm
by RobertGonzalez
In the while loop that is not displaying what you want, try this to see if there are actually records getting retrieved...

Code: Select all

<?php
$counter = 0;
while ($row_banner = mysql_fetch_array($result_banner)) {
    $counter++;
    echo $counter . ": Selected Row ID: ". $row_banner['id'] ."<br>";
} 
?>

Posted: Mon Jun 05, 2006 11:44 pm
by alexus
counter gets to 1 but no data in original script, now what i did was took line by line from similar working script and I got it working to on remote (dont breath now, it might foll apart) but when I run the script locally I got this:

could it be because of the serttings or something?
What does it mean to SAVE RESULT
Why syplied argument is not valid

What is going on? and why am i secling around and this thing sometimes work sometimes doesnt?

Warning: mysql_query(): Unable to save result set in c:\program files\apache group\apache\htdocs\template_9837_bu54w0isvwh26c90uh42\site\sql4.php on line 10

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in c:\program files\apache group\apache\htdocs\template_9837_bu54w0isvwh26c90uh42\site\sql4.php on line 11

Notice: Undefined variable: ddelay in c:\program files\apache group\apache\htdocs\template_9837_bu54w0isvwh26c90uh42\site\sql4.php on line 22
var ddelay = '0'

Code: Select all

<?
$i = "0";
$img_dir = "img_banners/";

include("db_conn.php");
$db = mysql_connect($db_server, $db_user, $db_pass);
mysql_select_db($db_name, $db);

$sql = "select * from uc_front_banner WHERE active='Yes'";
$result = mysql_query($sql);
while ($row_news = mysql_fetch_assoc($result)) {
    $sql_file = "select * from uc_front_banner_file WHERE event='$row_news[id]'";
	$result_file = mysql_query($sql_file);
    $ddelay = $row_news['rotate_time'];
	while ($row_file = mysql_fetch_assoc($result_file)) {  
	?>  
 	fadeimages[<? echo $i; ?>]=["<? echo "$img_dir". $row_file['file'] .""; ?>", "", ""] 
    <?
    $i = $i+1;
 	}
}
$ddelay = $ddelay * 666; 
echo "var ddelay = '$ddelay'"; 
?>