Jump to content

Problem with my PHP and MySQL application can you help


jdenwood@gmail.com

Recommended Posts

Hi Folks, I wonder if you might be able to give me some advice. I have an small e-commence application which I developed about 3 to 4 years ago using PHP and MySQL. I have returned to it recently, to use it as part of my personal portfolio site. I did have some troubles getting the site to work on a newer versions of MySQL . This was mostly connected to the changes between MySQL version 4 and version 5 connected to password usage. However, I managed to overcome this problems. I have managed to get the application to work on a mixture of local development environments on Windows and Mac plus I have got the application to work on an my small test Linux server running Fedora which I can view outside my local loop.

 

However, when I have transferred this application to my main external website which is run on by an Internet Provider. I get this message which I find very puzzling

 

Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in /home/digita47/public_html/stridesdrycleaners/default.php on line 50

 

Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/digita47/public_html/stridesdrycleaners/default.php on line 55

 

Here is the code from the page

 

<?php setcookie("username_cookie", $HTTP_POST_VARS["username"], time()+86400*90); ?>
<?php require_once('Connections/jonathan.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;
}
}
?><?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 = "welcome.php";
  $MM_redirectLoginFailed = "search.php";
  $MM_redirecttoReferrer = false;
  mysql_select_db($database_jonathan, $jonathan);
  
  $LoginRS__query=sprintf("SELECT username, password FROM login WHERE username='%s' AND password='%s'",
    get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password)); 
   
  $LoginRS = mysql_query($LoginRS__query, $jonathan) 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 );
  }
}
?>

 

I don’t really understand why I am getting this warning message when I have tested on the application on an local environment using the same version of PHP and MySQL. I thought it could be that my external website provider was using the latest versions of PHP and MySQL the company offered to transfer me to different server which was running MySQL 4.1 and PHP 4 however, I still get the same warning message. I wonder if you can give me some advice on why I am having this problems.

 

Take care

 

 

Jonathan Denwood

 

p.s. if you go to www.jonathandenwood.com and click the link on the right for Strides you can see the application working. The website is running on my small test server.

Link to comment
Share on other sites

Hello,

 

This kind of error usually comes if no database connection is established. In your code to i didnot saw the db connection code.

 

Try to add following code before 'mysql_select_db' command and see if you get your problem solved..

 

 

$jonathan = mysql_connect($hostname, $username, $password);

 

Regards,

Link to comment
Share on other sites

Hi Folks and thanks for your help. I’m little bit confused because I used Dreamweaver and I did modify the Connect file that Dreamweaver uses from its local settings to live setting see below. Each page has an include section that pulls these file into the head of the file. 

 

<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_jonathan = "localhost";
$database_jonathan = "digita47_products";
$username_jonathan = "digita47_jonathan";
$password_jonathan = "*********";
$jonathan = mysql_pconnect($hostname_jonathan, $username_jonathan, $password_jonathan) or trigger_error(mysql_error(),E_USER_ERROR); 
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.