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";
[COLOR="Red"] $MM_redirecttoReferrer = false;
mysql_select_db($database_jonathan, $jonathan[/COLOR]); (line 50 Jonathan Denwood)
$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));
[COLOR="Red"]
$LoginRS = mysql_query($LoginRS__query, $jonathan) or die(mysql_error());[/COLOR] (line 55 Jonthand Denwood)
$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.