[PHP] QUery success, but blank results/variables
Hello everyone..tryin to run this qry against a mysql db, but after it runs, it doesn't assign anything to the variables as it should. If i return all rows, and spit out each record in the result in an array, i have the same problem, but have 24 'blank' records instead of 1. Any ideas? Thanks for any input. I tried doing a print mysql_error(); after the query and the result, but it doesn't return anything. Column names, db name, and WHERE clause are all spelled correctly, and the $currenttaskid is populated (as 1)... $detailqry = SELECT id, parentitemid, itemtypeid, itemstatusid, itemlevelid, shortdescription, createdby_memberid, assignedto_memberid, completedby_memberid, createddate, assigneddate, estcompletiondate, completeddate, projectid, lastuserid, lastdate FROM item WHERE id=$currenttaskid; $result = mysql_query($detailqry) or die(Failed finding task details); $taskid = $result[id]; $taskparentitemid = $result[parentitemid]; $taskitemtypeid = $result[itemtypeid]; $taskitemstatusid = $result[itemstatusid]; $taskitemlevelid = $result[itemlevelid]; $taskshortdescription = $result[shortdescription]; $createdbyid = $result[createdby_memberid]; $assignedtoid = $result[assignedto_memberid]; $completedbyid = $result[completedby_memberid]; $taskcreateddate = $result[createddate]; $taskassigneddate = $result[assigneddate]; $taskestcompletiondate = $result[estcompletiondate]; $taskcompleteddate = $result[completeddate]; $taskprojectid = $result[projectid]; $tasklastuserid = $result[lastuserid]; $tasklastdate = $result[lastdate]; mysql_free_result($result); -IrishBiotch [EMAIL PROTECTED] _ Join the worlds largest e-mail service with MSN Hotmail. http://www.hotmail.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Login only to get stuck in infinite loop...what's missing?
After logging in successfully, i start an infinite loop between index.php and login.php, what's up? Please help. ? // index.php - secure page session_start(); if (!isset($PHP_AUTH_USER)) { // If empty, send header causing dialog box to appear //header(Location: http://dev.e-dbapps.com/customscripts/checklogin.php;); exit; } ? HTML HEAD TITLEe-DBapps.com: Home/TITLE /head body bgcolor=#ff font face=Palatino Linotype size=2 table border=0 cellpadding=0 cellspacing=0 width=750 tr!-- row 1 -- td colspan=2img src=img/development.jpg name=development3 width=750 height=100 border=0/td /tr tr **stuff** /tr /table /font /BODY CHECKLOGIN.php ?php session_start(); // File Name: checklogin.php // Check to see if $PHP_AUTH_USER already contains info if (!isset($PHP_AUTH_USER)) { // If empty, send header causing dialog box to appear header('WWW-Authenticate: Basic realm=Webmail Testing Area'); header('HTTP/1.0 401 Unauthorized'); exit; } else if (isset($PHP_AUTH_USER)) { mysql_connect(*, *, *) or die (Unable to connect to database.); // select database on MySQL server mysql_select_db(*) or die (Unable to select database.); $sql = SELECT id FROM users WHERE username='$PHP_AUTH_USER' and password= PASSWORD('$PHP_AUTH_PW'); $result = mysql_query($sql); // Get number of rows in $result. 0 if invalid, 1 if valid. $num = mysql_numrows($result); if ($num != 0) { // redirect to protected page session_register($PHP_AUTH_USER); session_register($PHP_AUTH_PW); header(Location: http://dev.e-dbapps.com/index.php;); exit(); } else { $status = 0; header(Location: http://dev.e-dbapps.com/customscripts/error.php?e=$status;); exit(); } } ? /HTML _ Send and receive Hotmail on your mobile device: http://mobile.msn.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Session Authentication error
After logging in, i end up in a continual loop between index.php and checklogin.php. Can someone give me a clue as to what is up and how to fix it? If i set the checklogin to go to a page that does not check authentication if the user/pass combo passed, it works fine, but whe i send it to a page that checks to see if $PHP_AUTH_USER is set, i get the infinite loop, which is funny the first time, but really Thanks in advance. *no, the comments aren't really there in the code (at least 99% of them ;) ) //index.php //? // index.php - secure page // session_start(); // if (!isset($PHP_AUTH_USER)) // { // // If empty, send header causing dialog box to appear // header(Location: http://dev.e-//dbapps.com/customscripts/checklogin.php;); // exit; // } //? //?php // session_start(); // // File Name: checklogin.php // // Check to see if $PHP_AUTH_USER already contains info if (!isset($PHP_AUTH_USER)) // { // // If empty, send header causing dialog box to appear // header('WWW-Authenticate: Basic realm=Webmail Testing Area'); // header('HTTP/1.0 401 Unauthorized'); // exit; // } // else if (isset($PHP_AUTH_USER)) // { // mysql_connect(***, ***, ***) or die (Unable to connect to database.); // // select database on MySQL server // mysql_select_db(***) or die (Unable to select database.); // $sql = SELECT id FROM users WHERE username='$PHP_AUTH_USER' and password= PASSWORD('$PHP_AUTH_PW'); // $result = mysql_query($sql); // // Get number of rows in $result. 0 if invalid, 1 if valid. // $num = mysql_numrows($result); // if ($num != 0) // { // // redirect to protected page // session_register($PHP_AUTH_USER); // session_register($PHP_AUTH_PW); // header(Location: http://dev.e-dbapps.com/index2.php;); // exit(); // } // else // { // $status = 0; // header(Location: http://dev.e-dbapps.com/customscripts/error.php?e=$status;); // exit(); // } // } //? -Patrick Hartnett toymaster e-dbapps.com _ MSN Photos is the easiest way to share and print your photos: http://photos.msn.com/support/worldwide.aspx -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] header() question
Is it possible to user the target=_top reference when using a header(Location = ...)? If so, anyone have an example. Thanks -patrick _ Join the worlds largest e-mail service with MSN Hotmail. http://www.hotmail.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] header() question
So any use of header(Location=...) automatically does what amounts to a target=_top? If so, then ignore this entire post, cuz that answers the question. If not, does anyone know how to force a target=_top when using header(Location=...)? From: George Nicolae [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: Re: [PHP] header() question Date: Mon, 1 Apr 2002 21:11:00 +0300 The _top option send you to the top of a page. When you open a new location you go on top by default.Maybe you ask about _blank? I don't have the answer for this last question. -- Best regards, George Nicolae IT Manager ___ PaginiWeb.com - Professional Web Design www.PaginiWeb.com Patrick Hartnett [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Is it possible to user the target=_top reference when using a header(Location = ...)? If so, anyone have an example. Thanks -patrick _ Join the world's largest e-mail service with MSN Hotmail. http://www.hotmail.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php _ Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Connecting to multiple DB's
Not sure about the multiple connections side, but to kill a connection: mysql_close($link); where $link is your connection variable/string hope this helps. -Patrick From: James Taylor [EMAIL PROTECTED] Reply-To: [EMAIL PROTECTED] To: PHP List [EMAIL PROTECTED] Subject: [PHP] Connecting to multiple DB's Date: Mon, 01 Apr 2002 10:47:45 -0800 I host a few sites, and on usually each site will have it's own MySQL database in the background. I've decided that I want to link one site to another, and need to connect to more than one database at a time. I've found that when I try to connect to 2 or more, even if I assign the other database to another variable (ie . $db1 = @mysql_connect($dbhost, $dbuser, $dbpass); $db2 = @mysql_connect($dbhost2, $dbuser, $dbpass); ) , the last connect called is the only one that is active. Any work arounds to this? I've been having to do it where I connect to one when needed, then connect to the other, etc. I'm thinking there has to be a better way to do this. Also, what is the function to kill a connection to a db? Thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php _ Send and receive Hotmail on your mobile device: http://mobile.msn.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] MySQL Connection Error - mysql_select_db
here is a function used to authenticate users against mysql database. Problem is, I am not connecting for some reason. I have the db variables: $db_host $db_user $db_pass $db_name They are populated from an include (x.php) in the beginning of the php section. It is getting past the connect statement, but it is not selecting the proper database, and gives a: Error in query: No Database Selected in the error trap below (die). Any ideas what is wrong? Am I missing some syntax, or what? Thanks. Patrick ## function authenticate($user, $pass) { // check login and password // connect and execute query $connection = mysql_connect($db_host, $db_user, $db_pass) or die (Unable to connect!); $query = SELECT id from users WHERE username = '$user' AND password = PASSWORD('$pass'); mysql_select_db($db_name); //mysql_select_db(devweb); --what it should be, from file $result = mysql_query($query, $connection) or die (Error in query: . mysql_error()); // if row exists - user/pass combination is correct if (mysql_num_rows($result) == 1) { return 1; } // user/pass combination is wrong else { return 0; } } _ Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] MySQL Connection Error - mysql_select_db
Thanks for all the help so far, great to have others out there helping. Only way it will let me connect is to explicitly use the connection information in the connect statement and the select_db statements, can't pass in the variables. This seems a little on the insecure side, and a pain. Is it supposed to be like this, or is it just something that is wrong on my php implementation? It would just be nice to have the connection information in 1 file, so that if it is updated or changed, it can be modified in one file, instead of all files that need it. Thanks for the help! -Patrick _ Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Case Statements - lil help please
Are case statements not implemented in PHP4? If so, can someone help me debug this one, I seem to have some syntax incorrect, and am not sure what exactly is wrong with the statement. I get a parse error on the first line, but can't find any documentation on case statements in PHP4, so I am kinda stuck. thanks -Patrick # // check the error code and generate an appropriate error message switch ($e) { case -1: $message = No such user.; break; case 0: $message = Invalid username and/or password.; break; case 2: $message = Unauthorized access.; break; default: $message = An unspecified error occurred.; break; } _ Send and receive Hotmail on your mobile device: http://mobile.msn.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sql results
try this, it sees if there is a result, and you can then proceed to do what you need to do. if (mysql_num_rows($result) == 1) //match found { //do something here; } // no match found else { //do something here; } From: Alberto Wagner [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: Re: [PHP] Sql results Date: Sat, 30 Mar 2002 21:44:29 -0300 But I Want a way to do something if there isn't any result 31/03/2002 01:52:10, Jason Wong [EMAIL PROTECTED] wrote: On Sunday 31 March 2002 07:29, Alberto Wagner wrote: $Sql_Query_Login Returns an empty mysql array like: $Sql_Query_Login = Mysql_Query(SELECT Nome FROM users WHERE User = 'Anyone') There isn't a user if name Anyone... Why If (!$Sql_Query_Login) { Echo Ninguem; } Is returning False? mysql_query() returns a resource id, which is a *pointer* to the results and not the actual results themselves. To get at the actual results you need to follow up with one of: mysql_fetch_array() mysql_fetch_row() mysql_fetch_assoc() See manual for details and examples. Also you should put some error-checking in your code as per the examples in the manual. -- Jason Wong - Gremlins Associates - www.gremlins.com.hk /* Bennett's Laws of Horticulture: (1) Houses are for people to live in. (2) Gardens are for plants to live in. (3) There is no such thing as a houseplant. */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php _ MSN Photos is the easiest way to share and print your photos: http://photos.msn.com/support/worldwide.aspx -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sql results
use it after your query to see if there is a result set. Like follows: $result = mysql_query($query) or die (Error in query: . mysql_error()); // if row exists - user/pass combination is correct if (mysql_num_rows($result) == 1) { return 1; } // user/pass combination is wrong else { return 0; } From: Jason Wong [EMAIL PROTECTED] Reply-To: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: Re: [PHP] Sql results Date: Sun, 31 Mar 2002 13:17:29 +0800 On Sunday 31 March 2002 08:44, Alberto Wagner wrote: But I Want a way to do something if there isn't any result mysql_num_rows() ? -- Jason Wong - Gremlins Associates - www.gremlins.com.hk /* The road to Hades is easy to travel. -- Bion */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php _ MSN Photos is the easiest way to share and print your photos: http://photos.msn.com/support/worldwide.aspx -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Get Current Filename
Trying to build a database which uses the webpage name as one of the selection criteria. (building page specific menus). How do I get the current file name? Can't seem to find any help on this. -Patrick _ MSN Photos is the easiest way to share and print your photos: http://photos.msn.com/support/worldwide.aspx -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Get Current Filename HOWTO
It seems I spoke to quick...here is how to get the current file name. $this_file = $_SERVER['REQUEST_URI']; echo( $this_file ); the result is formatted as follows: /applications.php _ MSN Photos is the easiest way to share and print your photos: http://photos.msn.com/support/worldwide.aspx -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php