
scottreid1974
Members-
Posts
32 -
Joined
-
Last visited
Never
Profile Information
-
Gender
Not Telling
scottreid1974's Achievements

Newbie (1/5)
0
Reputation
-
mysql_fetch_array(): not a valid mysql result resource
scottreid1974 replied to scottreid1974's topic in PHP Coding Help
Yes i can access my database through my webserver control panel which uses php myadmin. I have created a table and put a user in there with a url for the login to retrieve. It all appeared to work well on my desktop local apache installatron. Scott -
mysql_fetch_array(): not a valid mysql result resource
scottreid1974 replied to scottreid1974's topic in PHP Coding Help
I still get a no database found message when i try and log into the user section of my website. www.goytvalleystriders.org.uk this is my connect.php file <?php $host = "localhost"; $user = "gvs_abc"; $pass = "password"; $db = "gvs_abc"; $dbh=mysql_connect ($host, $user, $pass) or die ('I cannot connect to the database because: ' . mysql_error()); $dbase = mysql_select_db ($db); ?> and this is ny code on the page index page ?php require_once("connect.php"); if($_POST['username']) { $loginUsername = $_POST['username']; $password = $_POST['password']; $sql="SELECT username, password, url, access FROM users WHERE username='$loginUsername' AND password='$password' LIMIT 1"; $db=mysql_query($sql) or die(mysql_error()); $user=mysql_fetch_array($db); if(mysql_num_rows($db)) { session_start(); $_SESSION['username'] = $loginUsername; session_write_close(); header('Location: '.$user['url']); } else { $warning = "Error logging in. Please check USERNAME and PASSWORD!"; } } ?> can any one help? -
mysql_fetch_array(): not a valid mysql result resource
scottreid1974 replied to scottreid1974's topic in PHP Coding Help
Still the same message no database selected. I am baffled! -
mysql_fetch_array(): not a valid mysql result resource
scottreid1974 replied to scottreid1974's topic in PHP Coding Help
This is my connect folder: do you think it look right? <?php $host = "localhost"; $user = "goytvall_gvs"; $pass = "2007"; $db = "goytvall_gvs"; $dbh=mysql_connect ($host, $user, $pass) or die ('I cannot connect to the database because: ' . mysql_error()); $dbase = mysql_select_db ($db); ?> scott -
mysql_fetch_array(): not a valid mysql result resource
scottreid1974 replied to scottreid1974's topic in PHP Coding Help
it still says no databse selected. It is no something like i have not called it its proper name? my webserver mysql db says it is called goytvall_gvs. do i have to put anything else in the name as it is on webserver ? i am new to this! scott -
mysql_fetch_array(): not a valid mysql result resource
scottreid1974 replied to scottreid1974's topic in PHP Coding Help
hi i added or die(mysql_error()) to the line $db=mysql_query($sql) so it now looks like this $db=mysql_query($sql) or die(mysql_error()); Now when i try an log in the via the login form on my home page it says 'no database selected' I cant see where i am going wrong? thanks -
mysql_fetch_array(): not a valid mysql result resource
scottreid1974 replied to scottreid1974's topic in PHP Coding Help
Hi added die(mysql_error()) to the line $db=mysql_query($sql) -
mysql_fetch_array(): not a valid mysql result resource
scottreid1974 replied to scottreid1974's topic in PHP Coding Help
it says no database selected when i open the page in the browser. Before it opened, it just did not let me log into the user pages. Ta Scott -
mysql_fetch_array(): not a valid mysql result resource
scottreid1974 replied to scottreid1974's topic in PHP Coding Help
What i dont understand, is that the script worked on my test server on my pc, yet does not work on my website hosting comapny server? -
mysql_fetch_array(): not a valid mysql result resource
scottreid1974 replied to scottreid1974's topic in PHP Coding Help
Here it is, thanks. <?php $host = "localhost"; $user = "goytvall_gvs"; $pass = "2007"; $db = "goytvall_gvs"; $dbh=mysql_connect ($host, $user, $pass) or die ('I cannot connect to the database because: ' . mysql_error()); $dbase = mysql_select_db ($db); ?> -
mysql_fetch_array(): not a valid mysql result resource
scottreid1974 replied to scottreid1974's topic in PHP Coding Help
hi ta, it is now saying no database selected? ta -
Hi, all, I have aproblem with a login script. it returns the message Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/goytvall/public_html/pages/eccles.php on line 9 and then Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/goytvall/public_html/pages/eccles.php on line 10 this is my login script <?php require_once("../connect.php"); if($_POST['username']) { $loginUsername = $_POST['username']; $password = $_POST['password']; $sql="SELECT username, password, url, access FROM users WHERE username='$loginUsername' AND password='$password' LIMIT 1"; $db = mysql_query ($sql); $user = mysql_fetch_array ($db); if (mysql_num_rows ($db)) { session_start(); $_SESSION['username'] = $loginUsername; session_write_close(); header('Location: '.$user['url']); } else { $warning = "Error logging in. Please check USERNAME and PASSWORD!"; } } ?> tghis code works when i test it with apache on my local test server Anyone know what might the problem be? ta scott
-
Hi What is this that dreamweaver user at the top of a php page, i cant find it anywhere else? thanks <?php require_once('Connections/testconn1.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; } } ?>
-
Tried the tutorials, but i still cant get it to work, The problem is, i can get sessons to work on one webpage, but i cant when trying to get it to work on a webpage retrieved from a database, when user logs in . The url is stored in a field in the database, and is specific to each log on (account) any help plllzzz
-
Hi, i have a logon page where users enter a password, and user name, and they then get redirected to another web page. What i want is to make all the pages they visit when logged on secure, presumably using sessions. I am not sure of the code to use to create the sessions on the logon page, and the validation type sessions on the following visited pages. The logon page code is below. Thanks <?php if (!isset($_SESSION)) { session_start(); } $loginUsername = $_POST['username']; $password = $_POST['password']; mysql_select_db($database_testconn1, $testconn1); $sql = "SELECT username, password, url, access FROM users WHERE username='$loginUsername' AND password='$password' LIMIT 1"; $user = mysql_fetch_assoc(mysql_query($sql, $testconn1)); if(count($user) > 0){ header('Location: '.$user['url']); }else{ header('Location: login.php'); } ?>