Help my php page to load

My site has a user section and and demo section. I have almost mirrored the coding so newcomers can try the demo before subscribing. I have a main page with a couple of links, however, one of the links is broken and displays a blank page. The weird thing is that this only happens on the remote site and not the local testing site. If someone can direct me to the error…please?
I can not send the complete code so if someone can PM me, I can send more code.

Thanks…cracker

This code is in a table with a link to dm_NewOrder.php. Which works fine.

This code is also in the same table but does not work. The page does not render.

Do you get any error messages?

Also, doesn’t look like you have much (any) PHP.

Can you show us the MM_goToURL function?

Thanks for the replies.
JimL
I get no error messages, just a blank page. If I view the source code, it is blank.

Topcoder
Here is that function.
function MM_goToURL() { //v3.0
var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location=’"+args[i+1]+"’");
}

It pulls data from mysql database and displays the results in a table. Some more info for you. Remember I have a user section with the same code and function. Only difference is that this page is using a different database to display its results…if that makes sense.

Does anyone think it may have something to do the the session_start()? The thing that baffles me is that it all works okay on my local site, but not on the remote.

If you’re getting a blank page then the re-direct is working. On your server do you have error reporting turned on?

You can add these two lines to the top of the page that is blank

[php]ini_set(‘display_errors’,1);
error_reporting(E_ALL)[/php]

And see if it gives you any clues.

Thanks Topcoder,
I inserted the code and got this error message

error_reporting(E_ALL) Warning: mysql_select_db() expects parameter 2 to be resource, null given in /hermes/bosoraweb017/b215/ipw.trophymastercomau/public_html/demo/dm_ExistingOrderSearch.php on line 82 Warning: mysql_query() expects parameter 2 to be resource, null given in /hermes/bosoraweb017/b215/ipw.trophymastercomau/public_html/demo/dm_ExistingOrderSearch.php on line 84

This is the code in it refers to
mysql_select_db($database_demo, $demo);
$query_Recordset1 = “SELECT * FROM tbl_Suppliers”;
$Recordset1 = mysql_query($query_Recordset1, $demo) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);

Thanks again for your help.

You should check for errors when creating the connection to the db, there’s obviously something wrong with it.

Hi JimL,
I thought maybe it was a connection problem as well, but can’t figure out why the other links connect to the DB without any problem. All the coding to the connection is the same on the other pages. This is the only page that doesn’t load…weird.

Without any code it’s pretty much guesswork here. But it might be some sort of scope issue, are you sure you actually have the $demo variable in scope? It seems like you are in some file in some function, it might be worth checking.

JimL,
This is the code for that particular page.

Trophy Master <?php include_once("../template_header.php");?>

Search for Order

Date of Order:
From: <?php do { ?> <?php echo $row_Recordset1['SupplierName']?> <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); $rows = mysql_num_rows($Recordset1); if($rows > 0) { mysql_data_seek($Recordset1, 0); $row_Recordset1 = mysql_fetch_assoc($Recordset1); } ?>
Beng sent by: Road Air

 

<?php echo $_Session['MM_Username']?>

<?php mysql_free_result($Recordset1);

mysql_free_result($Clients);
?>

that’s not where you have the error, the error is somewhere before this line (where you create the db connection)

[php]mysql_select_db($database_demo, $demo);[/php]

Sorry JimL,
This is the beginning section of that last code snippet. I need that first line for the session variables? Right? The second line is my db connection. I normally would expect to have …/Connections/demo.php, however that wasn’t working locally for some reason so i place the demo.php connection file into the demo directory. Ideally I would prefer to have this connection file in the root directory Connections folder.

<?php session_start();?> <?php require_once('Connections/demo.php');?> <?php if (!isset($_SESSION)) { session_start(); } $MM_authorizedUsers = ""; $MM_donotCheckaccess = "true"; // *** Restrict Access To Page: Grant or deny access to this page function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { // For security, start by assuming the visitor is NOT authorized. $isValid = False; // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. // Therefore, we know that a user is NOT logged in if that Session variable is blank. if (!empty($UserName)) { // Besides being logged in, you may restrict access to only certain users based on an ID established when they login. // Parse the strings into arrays. $arrUsers = Explode(",", $strUsers); $arrGroups = Explode(",", $strGroups); if (in_array($UserName, $arrUsers)) { $isValid = true; } // Or, you may restrict access to only certain users based on their username. if (in_array($UserGroup, $arrGroups)) { $isValid = true; } if (($strUsers == "") && true) { $isValid = true; } } return $isValid; } $MM_restrictGoTo = "login_fail.php"; if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) { $MM_qsChar = "?"; $MM_referrer = $_SERVER['PHP_SELF']; if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&"; if (isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0) $MM_referrer .= "?" . $_SERVER['QUERY_STRING']; $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer); header("Location: ". $MM_restrictGoTo); exit; } ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } mysql_select_db($database_demo, $demo); $query_Recordset1 = "SELECT * FROM tbl_Suppliers"; $Recordset1 = mysql_query($query_Recordset1, $demo) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); $totalRows_Recordset1 = mysql_num_rows($Recordset1); $colname_Clients = "-1"; if (isset($_SESSION['MM_Username'])) { $colname_Clients = $_SESSION['MM_Username']; } mysql_select_db($database_demo, $demo); $query_Clients = sprintf("SELECT * FROM tbl_Clients WHERE ClientEmail = %s", GetSQLValueString($colname_Clients, "text")); $Clients = mysql_query($query_Clients, $demo) or die(mysql_error()); $row_Clients = mysql_fetch_assoc($Clients); $totalRows_Clients = mysql_num_rows($Clients); ?>

A couple of things

[php]<?php session_start();?>

<?php require_once('Connections/demo.php');?> <?php if (!isset($_SESSION)) { session_start(); }[/php] You don't need to do the session_twice call twice. Also you don't need to wrap everything in PHP tags. This should be enough: [php]<?php session_start(); require_once('Connections/demo.php');[/php] Now the code I/we need is here -> Connections/demo.php Please remove login information before posting.
I normally would expect to have ../Connections/demo.php, however that wasn't working locally for some reason so i place the demo.php connection file into the demo directory. Ideally I would prefer to have this connection file in the root directory Connections folder.
So is it in the Connections directory or the demo directory? Because you are not trying to include a file in a demo directory...

I’ve cleaned up the php tags and the extra session_start().

I have 2 separate DB. One for registered user who have access to the complete DB data and a demo DB for visitors to test and sample. The demo DB is a small sample. My site is split into two sections. One for registered user and the demo side. If someone wants to try the site, then they click the demo link which lets them log in using my username and pwd I have set up in the demo DB. It then allows them to use the demo site as if they were a registered user but on a different DB. This is so any orders they create will not affect the main DB as well as not allow them to use the site under the demo login.
So I have a DB connection folder inside the root directory. WIthin this connection folder I have placed the mainDB.php file and then a demo.php for the demo connection. In the root directory there is a demo folder that holds all the demo files hence the …/Connection/demo.php line that links back a level to the root directory Connections folder.

You can go to the site and see how it’s set up if you like. You may get a better idea of the structure. www.trophymaster.com

This is the code from my demo.php connection file. I have this file in the root directory in a folder named Connections
[php]

FileName=“Connection_php_mysql.htm”

Type=“MYSQL”

HTTP=“true”

$hostname_TrophyMaster = “myhost”;
$database_TrophyMaster = “myDB”;
$username_TrophyMaster = “myloginname”;
$password_TrophyMaster = “mypwd”;
$TrophyMaster = mysql_pconnect($hostname_TrophyMaster, $username_TrophyMaster, $password_TrophyMaster) or trigger_error(mysql_error(),E_USER_ERROR);
[/php]

Where are these two values set?
[php]mysql_select_db($database_demo, $demo);[/php]

Not exactly sure. Can you re-phrase the question for me?

There is a list of Suppliers in the demoDB. The page has an dynamic list that gets populated. The demo user chooses from the drop down list and continues to fill in the other fields. Once completed the form is submitted and the results displayed in a new page.

Thanks

JimL,
I may have figured it out. Your ini_set() trick showed me the errors and where to look. When I copied the main files to the demo files, DM asked if I need to update the links and some of them I opted for NO, however, I should have chosen the YES option. This is why the parameters in the my_select_db did not makes sense to you.

All working as it should now.

Thanks for all you help.

cracker

Happy you got it working :slight_smile:

Sponsor our Newsletter | Privacy Policy | Terms of Service