jdenwood@gmail.com Posted October 4, 2007 Share Posted October 4, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/71855-problem-with-my-php-and-mysql-application-can-you-help/ Share on other sites More sharing options...
MmmVomit Posted October 4, 2007 Share Posted October 4, 2007 Code tags, please. Quote Link to comment https://forums.phpfreaks.com/topic/71855-problem-with-my-php-and-mysql-application-can-you-help/#findComment-361926 Share on other sites More sharing options...
darkfreaks Posted October 4, 2007 Share Posted October 4, 2007 please put your code in code tags and comment out the problem lines. Quote Link to comment https://forums.phpfreaks.com/topic/71855-problem-with-my-php-and-mysql-application-can-you-help/#findComment-361932 Share on other sites More sharing options...
MmmVomit Posted October 4, 2007 Share Posted October 4, 2007 It doesn't look like you're ever actually connecting to the database. I also don't see anywhere $jonathan is being assigned a value. Quote Link to comment https://forums.phpfreaks.com/topic/71855-problem-with-my-php-and-mysql-application-can-you-help/#findComment-361951 Share on other sites More sharing options...
darkfreaks Posted October 4, 2007 Share Posted October 4, 2007 i know i saw the same thing Quote Link to comment https://forums.phpfreaks.com/topic/71855-problem-with-my-php-and-mysql-application-can-you-help/#findComment-361955 Share on other sites More sharing options...
Barand Posted October 4, 2007 Share Posted October 4, 2007 I'd guess the connection is being attempted, and failing, in 'Connections/jonathan.php' Quote Link to comment https://forums.phpfreaks.com/topic/71855-problem-with-my-php-and-mysql-application-can-you-help/#findComment-362041 Share on other sites More sharing options...
hemlata Posted October 5, 2007 Share Posted October 5, 2007 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, Quote Link to comment https://forums.phpfreaks.com/topic/71855-problem-with-my-php-and-mysql-application-can-you-help/#findComment-362365 Share on other sites More sharing options...
jdenwood@gmail.com Posted October 5, 2007 Author Share Posted October 5, 2007 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); ?> Quote Link to comment https://forums.phpfreaks.com/topic/71855-problem-with-my-php-and-mysql-application-can-you-help/#findComment-362655 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.