Help needed

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Cayote75
Forum Newbie
Posts: 6
Joined: Sat Mar 08, 2014 5:16 pm

Help needed

Post by Cayote75 »

Hi i'm a first time php website designer i've done a website which i like and looks good locally on my pc, i've uploaded my files on the server and the page is blank I've narrowed the problem down to my code but I can't see what the problem is and how to fix it;

here is my code;

Code: Select all

<?php 
require_once('Connections/PhoenixDB.php'); 
?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $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;
}
}

if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$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;
}
}

if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 

{
  $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_PhoenixDB, $PhoenixDB);
$query_Recordset1 = "SELECT * FROM website_members";
$Recordset1 = mysql_query($query_Recordset1, $PhoenixDB) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
<?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
  session_start();
}

$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
  $_SESSION['PrevUrl'] = $_GET['accesscheck'];
}

if (isset($_POST['username'])) {
  $loginUsername=$_POST['username'];
  $password=$_POST['password'];
  $MM_fldUserAuthorization = "";
  $MM_redirectLoginSuccess = "Index2.php";
  $MM_redirectLoginFailed = "Failure.php";
  $MM_redirecttoReferrer = false;
  mysql_select_db($database_PhoenixDB, $PhoenixDB);
  
  $LoginRS__query=sprintf("SELECT username, password FROM website_members WHERE username=%s AND password=%s",
    GetSQLValueString($loginUsername, "-1"), GetSQLValueString($password, "-1")); 
   
  $LoginRS = mysql_query($LoginRS__query, $PhoenixDB) or die(mysql_error());
  $loginFoundUser = mysql_num_rows($LoginRS);
  if ($loginFoundUser) {
     $loginStrGroup = "";
    
    //declare two session variables and assign them
    $_SESSION['MM_Username'] = $loginUsername;
    $_SESSION['MM_UserGroup'] = $loginStrGroup;	      

    if (isset($_SESSION['PrevUrl']) && false) {
      $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];	
    }
    header("Location: " . $MM_redirectLoginSuccess );
  }
  else {
    header("Location: ". $MM_redirectLoginFailed );
  }
}
?>
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Help needed

Post by Celauran »

Is error reporting enabled? Have you checked your error logs? Any idea where the code fails?
Cayote75
Forum Newbie
Posts: 6
Joined: Sat Mar 08, 2014 5:16 pm

Re: Help needed

Post by Cayote75 »

at the top from what i can make out it says;
E_WARNING : type 2 -- require_once(Connections\PhoenixDB.php) [function.require-once]: failed to open stream: No such file or directory -- at line 1
E_COMPILE_ERROR : type 64 -- require_once() [function.require]: Failed opening required 'Connections\PhoenixDB.php' (include_path='.:/usr/lib/php:/usr/local/lib/php53:main/inclibs') -- at line 1

im utterly confused as to what is wrong and how to fix it!
gooney0
Forum Commoner
Posts: 56
Joined: Fri Jan 21, 2011 1:40 pm
Location: Reston, VA

Re: Help needed

Post by gooney0 »

It is complaining that Connections\PhoenixDB.php doesn't exist. If it does exist it isn't being found.

Is your web server Windows? If not you're using the wrong slash. Unix-like server use / to separate folder names.

You could also be more specific as to the files location:

\directory\another\Connections\PhoenixDB.php

Also be sure that the file name has the exact spelling and case.
Cayote75
Forum Newbie
Posts: 6
Joined: Sat Mar 08, 2014 5:16 pm

Re: Help needed

Post by Cayote75 »

E_NOTICE : type 8 -- Undefined variable: database_PhoenixDB -- at line 92
E_NOTICE : type 8 -- Undefined variable: PhoenixDB -- at line 92
E_WARNING : type 2 -- mysql_select_db() expects parameter 2 to be resource, null given -- at line 92
E_NOTICE : type 8 -- Undefined variable: PhoenixDB -- at line 94
E_WARNING : type 2 -- mysql_query() expects parameter 2 to be resource, null given -- at line 94

is my new error message im getting - my database is called phoenix_members i gave id of PhoenixDB when making the connection in dreamweaver cs3 is that relavent - php code design is confusing me a little
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Help needed

Post by Celauran »

Is this in addition to the earlier errors, or instead of? If those variables are defined in a file that the server can't read, then this behaviour is expected.

Code: Select all

E_WARNING : type 2 -- require_once(Connections\PhoenixDB.php) [function.require-once]: failed to open stream: No such file or directory -- at line 1
E_COMPILE_ERROR : type 64 -- require_once() [function.require]: Failed opening required 'Connections\PhoenixDB.php' (include_path='.:/usr/lib/php:/usr/local/lib/php53:main/inclibs') -- at line 1
Is this still happening?
Cayote75
Forum Newbie
Posts: 6
Joined: Sat Mar 08, 2014 5:16 pm

Re: Help needed

Post by Cayote75 »

no i have got past that now this is next error
jon
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Help needed

Post by Celauran »

Can you post the contents of the required filed, then? (Obfuscate username/password, obviously)
Cayote75
Forum Newbie
Posts: 6
Joined: Sat Mar 08, 2014 5:16 pm

Re: Help needed

Post by Cayote75 »

contents of PhoenixDB.php

<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_PhoenixDB = "localhost";
$database_PhoenixDB = "phoenix_members";
$username_PhoenixDB =
$password_PhoenixDB =
$PhoenixDB = mysql_pconnect($hostname_PhoenixDB, $username_PhoenixDB, $password_PhoenixDB) or trigger_error(mysql_error(),E_USER_ERROR);
?>
Cayote75
Forum Newbie
Posts: 6
Joined: Sat Mar 08, 2014 5:16 pm

Re: Help needed

Post by Cayote75 »

all code now listed really need to sort this issue out its doing my head in for a php newbie
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Help needed

Post by Celauran »

I'm not seeing any syntax errors in there and the variables are indeed defined. Given the notices, I have to surmise there's something wrong with the require itself; either the path is incorrect or the web server does not have permission to read the file.
Post Reply