Re: [PHP-DB] PHP/MySQL Library Catalog System
On Thursday 10 January 2002 22:26, you wrote: > Hi all, > I've noted that a least a couple of people on this list work with > library catalog systems - I'm interested in finding out whether any of > these systems are open-source or are available for a nominal fee. I'm > familiar enough with PHP/MySQL to make one, but I'd also like to avoid > re-inventing the wheel if possible, particularly since I'm not a > librarian :-). The non-profit that I work for has a significant > biological science library that we would like to create a/use an > existing web-based catalog system for. > Also, I'm aware that there is specific funding available for doing > this @ non-profits... I was wondering if anyone else had endeavored > along these lines. Well, as soon as I get my database over magazines that we have in our storage, i'll release it under GPL, most probably on the http://lib.vaasa.fi server. Not that I know if anyone has got any use of it whatsoever, but... Cheers, Markus -- Markus Lervik Linux-administrator with a kungfoo grip Vaasa City Library - Regional Library [EMAIL PROTECTED] +358-6-325 3589 / +358-40-832 6709 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] display text in screen
Hi, I have easy problem to ask someone. I wrote PHP to update data with many step and need to display comment or detail in each step. But I got all comment or detail display after it finished update all step. How could I display each step comment immediately?? Sommai Fongnamthip -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] MySQL Result Resource
On Friday 11 January 2002 10:33, Necro wrote: > Ok, > > > I have tried to go to PASSWORD after none of the suggestions worked out. > > The current statement is: > $arg = "select password, 1 as auth from acl where username='$username' and > password = 'PASSWORD($password)'"; > > But the error I get now is: > select password, 1 as auth from acl where username='andrewd' and password = > 'PASSWORD(madonna)'Resource id #2 > > Any ideas? > > Andrew Both PASSWORD and MD5 expect a *string* as an argument so you need to enclose the argument in either single quotes or double quotes. $arg = "SELECT password, 1 AS auth FROM acl WHERE username = '$username' AND password = PASSWORD('$password')"; Hopefully that should work ;-) -- Jason Wong -> Gremlins Associates -> www.gremlins.com.hk /* Love is the process of my leading you gently back to yourself. -- Saint Exupery */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP-DB] MySQL Result Resource
http://www.hotscripts.com/Detailed/4219.html <<--- that is the script But I cannot use crypt() on a winodws system. So I tried MD5, now I try PASSWORD. Any one got any idea how to make the script work with either of those?? Andrew -Original Message- From: Necro [mailto:[EMAIL PROTECTED]] Sent: Friday, 11 January 2002 3:30 PM To: [EMAIL PROTECTED] Subject: RE: [PHP-DB] MySQL Result Resource Daniel, I had tried both with and without quotes. Neither work. Without quotes I get: select password, 1 as auth from acl where username='andrewd' and password = PASSWORD(madonna)1054 : Unknown column 'madonna' in 'where clause' Notice that madonna has not been crypted by the PASSWORD call either. Andrew -Original Message- From: Daniel Barton [mailto:[EMAIL PROTECTED]] Sent: Friday, 11 January 2002 2:40 PM To: Necro Cc: [EMAIL PROTECTED] Subject: Re: [PHP-DB] MySQL Result Resource Andrew: Don't put quotes around your MySQL function call. i.e. PASSWORD($password) not 'PASSWORD($password)' p.s. Looking at this thread, it seems like most of the errors you're encountering have nothing to do with md5() or password(), but with syntax, like placement of quotes, or whether they are single quotes or double quotes. I would suggest experimenting with the syntax a bit, to check out what's kosher, and what's not? Check out the PHP manual's sections on 'Resource id's - I think you may find it to be very important to understanding how PHP interacts with databases. Resource ids, which are returned by quite a few function calls, are not classic variables - they need to be manipulated or interpreted before you use them. Cheers, db Necro wrote: > Ok, > > I have tried to go to PASSWORD after none of the suggestions worked out. > > The current statement is: > $arg = "select password, 1 as auth from acl where username='$username' and > password = 'PASSWORD($password)'"; > > But the error I get now is: > select password, 1 as auth from acl where username='andrewd' and password = > 'PASSWORD(madonna)'Resource id #2 > > Any ideas? > > Andrew > > -Original Message- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] > Sent: Friday, 11 January 2002 8:56 AM > To: Necro; [EMAIL PROTECTED] > Subject: RE: [PHP-DB] MySQL Result Resource > > Addressed to: "Necro" <[EMAIL PROTECTED]> > [EMAIL PROTECTED] > > ** Reply to note from "Necro" <[EMAIL PROTECTED]> Fri, 11 Jan 2002 > 03:41:43 +1100 > > select password, 1 as auth from acl where (username='andrewd' and > > password=(163e06103a371fd95b21b4a849bb4b91))1064 : You have an error in > your > > SQL syntax near 'a371fd95b21b4a849bb4b91))' at line 1 > > > > Does that help give any idea at all as to what the problem is? > > > > There are no quotes around "163e06103a371fd95b21b4a849bb4b91" The > error occurs where it does because '163e06103' is a valid exponential > notation value for a nubmer, but having an 'a' follow it is not valid. > > My solution would be: > > $Pass = md5( whatever ); # I don't care if you hash just the password > # or the username and password as long as > # you do it the same way as you entered > # the passwords. > > mysql_query( "SELECT password, 1 AS auth " . > "FROM acl " . > "WHERE username = '$username' " . > " AND password = '$Pass' " ); > > But I question what you are doing returning password, so it might work > as well as: > > mysql_query( "SELECT count(*) as Authorized " . > "FROM acl " . > "WHERE username = '$username' " . > " AND password = '$Pass' " ); > > This returns 0 or 1 in a field named Authorized depending on if the > password matches or not. > > You might also want to look at the MySQL PASSWORD() function and not > mess with md5 at all. > > Rick > > Rick Widmer > Internet Marketing Specialists > http://www.developersdesk.com > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] -- -- Dan Barton Terrestrial Program Biologist Asst. Data Manager Point Reyes Bird Observatory http://www.prbo.org [EMAIL PROTECTED] [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database
RE: [PHP-DB] MySQL Result Resource
Daniel, I had tried both with and without quotes. Neither work. Without quotes I get: select password, 1 as auth from acl where username='andrewd' and password = PASSWORD(madonna)1054 : Unknown column 'madonna' in 'where clause' Notice that madonna has not been crypted by the PASSWORD call either. Andrew -Original Message- From: Daniel Barton [mailto:[EMAIL PROTECTED]] Sent: Friday, 11 January 2002 2:40 PM To: Necro Cc: [EMAIL PROTECTED] Subject: Re: [PHP-DB] MySQL Result Resource Andrew: Don't put quotes around your MySQL function call. i.e. PASSWORD($password) not 'PASSWORD($password)' p.s. Looking at this thread, it seems like most of the errors you're encountering have nothing to do with md5() or password(), but with syntax, like placement of quotes, or whether they are single quotes or double quotes. I would suggest experimenting with the syntax a bit, to check out what's kosher, and what's not? Check out the PHP manual's sections on 'Resource id's - I think you may find it to be very important to understanding how PHP interacts with databases. Resource ids, which are returned by quite a few function calls, are not classic variables - they need to be manipulated or interpreted before you use them. Cheers, db Necro wrote: > Ok, > > I have tried to go to PASSWORD after none of the suggestions worked out. > > The current statement is: > $arg = "select password, 1 as auth from acl where username='$username' and > password = 'PASSWORD($password)'"; > > But the error I get now is: > select password, 1 as auth from acl where username='andrewd' and password = > 'PASSWORD(madonna)'Resource id #2 > > Any ideas? > > Andrew > > -Original Message- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] > Sent: Friday, 11 January 2002 8:56 AM > To: Necro; [EMAIL PROTECTED] > Subject: RE: [PHP-DB] MySQL Result Resource > > Addressed to: "Necro" <[EMAIL PROTECTED]> > [EMAIL PROTECTED] > > ** Reply to note from "Necro" <[EMAIL PROTECTED]> Fri, 11 Jan 2002 > 03:41:43 +1100 > > select password, 1 as auth from acl where (username='andrewd' and > > password=(163e06103a371fd95b21b4a849bb4b91))1064 : You have an error in > your > > SQL syntax near 'a371fd95b21b4a849bb4b91))' at line 1 > > > > Does that help give any idea at all as to what the problem is? > > > > There are no quotes around "163e06103a371fd95b21b4a849bb4b91" The > error occurs where it does because '163e06103' is a valid exponential > notation value for a nubmer, but having an 'a' follow it is not valid. > > My solution would be: > > $Pass = md5( whatever ); # I don't care if you hash just the password > # or the username and password as long as > # you do it the same way as you entered > # the passwords. > > mysql_query( "SELECT password, 1 AS auth " . > "FROM acl " . > "WHERE username = '$username' " . > " AND password = '$Pass' " ); > > But I question what you are doing returning password, so it might work > as well as: > > mysql_query( "SELECT count(*) as Authorized " . > "FROM acl " . > "WHERE username = '$username' " . > " AND password = '$Pass' " ); > > This returns 0 or 1 in a field named Authorized depending on if the > password matches or not. > > You might also want to look at the MySQL PASSWORD() function and not > mess with md5 at all. > > Rick > > Rick Widmer > Internet Marketing Specialists > http://www.developersdesk.com > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] -- -- Dan Barton Terrestrial Program Biologist Asst. Data Manager Point Reyes Bird Observatory http://www.prbo.org [EMAIL PROTECTED] [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] Re: Saving sessions info in MySql DB
Thanks! Saved me a huge headache! "Yasuo Ohgaki" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Your save handler has some problem... > > Except read functin, all return values from handler is converted to > boolean and you should return TRUE for success, FALSE for failure. > > For read function, you MUST return string *always*. Return "" (null > string) if there is nothing to read. > > I've updated manual page, it'll be in manual shortly, also. > > > John Branstad wrote: > > > We recently upgraded to php4.1.0 from 4.0.6 and now our custom session > > handling doesn't work! We are running on linux with apache, attempting to > > save session info to a MySQL database (I have session.save_handler=user). > > There are a couple issues: > > > > 1) Occassionally (can't seem to pin down exactly when) I try and access my > > site and get a "The page cannot be displayed" error in IE. > > a. The session_start() command seems to be causing this error - If i put > > die("here"); before session_start(), I see the message. If I move > > die("here"); after session_start(), I get the error. > > b. Clicking refresh (sometimes 1 time, sometimes 10 times) will > > eventually allow me to access my page. > > > > 2) The first time I access my page, I attempt to set a session variable > > ($_SESSION["foo"] = "bar;). When the page finishes loading, the session > > write handler is called which puts the session information in the database. > > However, there is nothing written to the value field! (It's still blank!) > > a. If I refresh the page, the session information is updated in the > > database, and now the value field has the correct entry (foo|s:3:"bar";) > > > > My session save handler is based on > href="http://www.onlamp.com/pub/a/php/2001/05/10/sessions.html?page=2";>this > > article I read: > > I'm attaching a copy of my sesssions.php file in case that will help anyone. > > The only modifications I made were to the read handler - I put in a return > > of the value from the SELECT. If I take that statement out, problem 1) goes > > away, but I would NEVER get session information saved into the database!??! > > (only the SessionID would be stored) > > > > Did something change in session handling from 4.0.6 to 4.1.0? If I can't > > figure this out, we have no choice but to roll back to 4.0.6, but I really > > love the security additions of 4.1.0 - Help!!! MUCH THANKS IN ADVANCE. > > > > John > > > > > > > > > > > /* > > > > ** > > ** Name: template.php > > ** > > ** Author: Cory Factor > > ** > > > > */ > > > > // These variables are set in the database_settings.php file > > // which is included using the auto_prepend_file PHP configuration > > // > > $SESS_DBHOST = $Global_DBHOST; /* database server hostname */ > > $SESS_DBNAME = $Global_DBNAME; /* database name */ > > $SESS_DBUSER = $Global_DBUSER; /* database user */ > > $SESS_DBPASS = $Global_DBPASS; /* database password */ > > // > > // End of auto_prepend_file variables > > > > > > $SESS_TABLE = "sessions"; > > $SESS_LIFE = get_cfg_var("session.gc_maxlifetime"); > > $SESS_DB = ""; > > > > /* > > print("host: $SESS_DBHOST"); > > print("name: $SESS_DBNAME"); > > print("user: $SESS_DBUSER"); > > print("pass: $SESS_DBPASS"); > > print("sessid: $PHPSESSID"); > > print("life: $SESS_LIFE"); > > //die(); > > */ > > > > function sess_open($save_path, $session_name) { > > global $SESS_DBHOST, $SESS_DBUSER, $SESS_DBPASS, $SESS_DBNAME, $SESS_DB; > > > > if ( !mysql_pconnect($SESS_DBHOST, $SESS_DBUSER, $SESS_DBPASS)) { > > echo "Can't connect to $SESS_DBHOST as $SESS_DBUSER"; > > echo "MySQL Error: ", mysql_error(); > > die; > > } > > if ( ! mysql_select_db($SESS_DBNAME)) { > > echo "Unable to select database $SESS_DBNAME"; > > die; > > } > > } > > > > function sess_close() { > > return true; > > } > > > > function sess_read($SID) { > > global $SESS_DB, $SESS_TABLE; > > > > $qry = "SELECT value FROM $SESS_TABLE WHERE sesskey = '$SID' AND expiry > " . time(); > > $result = mysql_query($qry); > > > > > > if (list($value) = mysql_fetch_row($result)) { > > return $value; > > } > > } > > > > function sess_write($SID, $val) { > > global $SESS_DB, $SESS_TABLE, $SESS_LIFE; > > > > $expiry = time() + $SESS_LIFE; > > > > $qry = "INSERT INTO $SESS_TABLE VALUES ('$SID', '$expiry', '$value')"; > > $result = mysql_query($qry); > > > > if (! $result) { > > $qry = "UPDATE $SESS_TABLE SET expiry = '$expiry', value = '$value' WHERE sesskey = '$SID' AND expiry > " . time(); > > $result = mysql_query($qry); > > } > > } > > > > function sess_destroy($SID) { > > global $SESS_TABLE; > > > > $qry = "DELETE FROM $SESS_TABLE WHERE sesskey = '$SID'"; > > $result = mysql_query($qry); > > } > > > > function sess_gc($SESS_LIFE) { > > global $SESS_TABLE; > > > > $qry = "DELETE FROM $SESS_TABLE WHERE expiry < " . time() - $SESS_LIFE; > > $result = mysql_query($qry); > > > > ret
[PHP-DB] RE: Pulling a long list of data stalls PHP
At 08:03 AM 1/9/2002 -0800, Max wrote: >Just curious, but which version of PHP are you using, the ISAPI or CGI. >I've tried the isapi version before and had problems like this. PHP >would crash and leave orphaned instances of php. If your using the >isapi version try the cgi and see if it works for you. Actually, this was using the CGI version. I haven't had a single problem since I went back to php-ini-dist. Lightning fast response too. Anyone know what setting might have caused the weirdness? Someday I'll go through and figure it out. -P -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] Re: Saving sessions info in MySql DB
Your save handler has some problem... Except read functin, all return values from handler is converted to boolean and you should return TRUE for success, FALSE for failure. For read function, you MUST return string *always*. Return "" (null string) if there is nothing to read. I've updated manual page, it'll be in manual shortly, also. John Branstad wrote: > We recently upgraded to php4.1.0 from 4.0.6 and now our custom session > handling doesn't work! We are running on linux with apache, attempting to > save session info to a MySQL database (I have session.save_handler=user). > There are a couple issues: > > 1) Occassionally (can't seem to pin down exactly when) I try and access my > site and get a "The page cannot be displayed" error in IE. > a. The session_start() command seems to be causing this error - If i put > die("here"); before session_start(), I see the message. If I move > die("here"); after session_start(), I get the error. > b. Clicking refresh (sometimes 1 time, sometimes 10 times) will > eventually allow me to access my page. > > 2) The first time I access my page, I attempt to set a session variable > ($_SESSION["foo"] = "bar;). When the page finishes loading, the session > write handler is called which puts the session information in the database. > However, there is nothing written to the value field! (It's still blank!) > a. If I refresh the page, the session information is updated in the > database, and now the value field has the correct entry (foo|s:3:"bar";) > > My session save handler is based on href="http://www.onlamp.com/pub/a/php/2001/05/10/sessions.html?page=2";>this > article I read: > I'm attaching a copy of my sesssions.php file in case that will help anyone. > The only modifications I made were to the read handler - I put in a return > of the value from the SELECT. If I take that statement out, problem 1) goes > away, but I would NEVER get session information saved into the database!??! > (only the SessionID would be stored) > > Did something change in session handling from 4.0.6 to 4.1.0? If I can't > figure this out, we have no choice but to roll back to 4.0.6, but I really > love the security additions of 4.1.0 - Help!!! MUCH THANKS IN ADVANCE. > > John > > > > > /* > > ** > **Name: template.php > ** > **Author: Cory Factor > ** > > */ > > // These variables are set in the database_settings.php file > // which is included using the auto_prepend_file PHP configuration > // > $SESS_DBHOST = $Global_DBHOST;/* database server hostname */ > $SESS_DBNAME = $Global_DBNAME;/* database name */ > $SESS_DBUSER = $Global_DBUSER;/* database user */ > $SESS_DBPASS = $Global_DBPASS;/* database password */ > // > // End of auto_prepend_file variables > > > $SESS_TABLE = "sessions"; > $SESS_LIFE = get_cfg_var("session.gc_maxlifetime"); > $SESS_DB = ""; > > /* > print("host: $SESS_DBHOST"); > print("name: $SESS_DBNAME"); > print("user: $SESS_DBUSER"); > print("pass: $SESS_DBPASS"); > print("sessid: $PHPSESSID"); > print("life: $SESS_LIFE"); > //die(); > */ > > function sess_open($save_path, $session_name) { > global $SESS_DBHOST, $SESS_DBUSER, $SESS_DBPASS, $SESS_DBNAME, $SESS_DB; > > if ( !mysql_pconnect($SESS_DBHOST, $SESS_DBUSER, $SESS_DBPASS)) { > echo "Can't connect to $SESS_DBHOST as $SESS_DBUSER"; > echo "MySQL Error: ", mysql_error(); > die; > } > if ( ! mysql_select_db($SESS_DBNAME)) { > echo "Unable to select database $SESS_DBNAME"; > die; > } > } > > function sess_close() { > return true; > } > > function sess_read($SID) { > global $SESS_DB, $SESS_TABLE; > > $qry = "SELECT value FROM $SESS_TABLE WHERE sesskey = '$SID' AND expiry > " . >time(); > $result = mysql_query($qry); > > > if (list($value) = mysql_fetch_row($result)) { > return $value; > } > } > > function sess_write($SID, $val) { > global $SESS_DB, $SESS_TABLE, $SESS_LIFE; > > $expiry = time() + $SESS_LIFE; > > $qry = "INSERT INTO $SESS_TABLE VALUES ('$SID', '$expiry', '$value')"; > $result = mysql_query($qry); > > if (! $result) { > $qry = "UPDATE $SESS_TABLE SET expiry = '$expiry', value = '$value' >WHERE sesskey = '$SID' AND expiry > " . time(); > $result = mysql_query($qry); > } > } > > function sess_destroy($SID) { > global $SESS_TABLE; > > $qry = "DELETE FROM $SESS_TABLE WHERE sesskey = '$SID'"; > $result = mysql_query($qry); > } > > function sess_gc($SESS_LIFE) { > global $SESS_TABLE; > > $qry = "DELETE FROM $SESS_TABLE WHERE expiry < " . time() - $SESS_LIFE; > $result = mysql_query($qry); > > return mysql_affected_rows($result); > } > > session_se
Re: [PHP-DB] MySQL Result Resource
Andrew: Don't put quotes around your MySQL function call. i.e. PASSWORD($password) not 'PASSWORD($password)' p.s. Looking at this thread, it seems like most of the errors you're encountering have nothing to do with md5() or password(), but with syntax, like placement of quotes, or whether they are single quotes or double quotes. I would suggest experimenting with the syntax a bit, to check out what's kosher, and what's not? Check out the PHP manual's sections on 'Resource id's - I think you may find it to be very important to understanding how PHP interacts with databases. Resource ids, which are returned by quite a few function calls, are not classic variables - they need to be manipulated or interpreted before you use them. Cheers, db Necro wrote: > Ok, > > I have tried to go to PASSWORD after none of the suggestions worked out. > > The current statement is: > $arg = "select password, 1 as auth from acl where username='$username' and > password = 'PASSWORD($password)'"; > > But the error I get now is: > select password, 1 as auth from acl where username='andrewd' and password = > 'PASSWORD(madonna)'Resource id #2 > > Any ideas? > > Andrew > > -Original Message- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] > Sent: Friday, 11 January 2002 8:56 AM > To: Necro; [EMAIL PROTECTED] > Subject: RE: [PHP-DB] MySQL Result Resource > > Addressed to: "Necro" <[EMAIL PROTECTED]> > [EMAIL PROTECTED] > > ** Reply to note from "Necro" <[EMAIL PROTECTED]> Fri, 11 Jan 2002 > 03:41:43 +1100 > > select password, 1 as auth from acl where (username='andrewd' and > > password=(163e06103a371fd95b21b4a849bb4b91))1064 : You have an error in > your > > SQL syntax near 'a371fd95b21b4a849bb4b91))' at line 1 > > > > Does that help give any idea at all as to what the problem is? > > > > There are no quotes around "163e06103a371fd95b21b4a849bb4b91" The > error occurs where it does because '163e06103' is a valid exponential > notation value for a nubmer, but having an 'a' follow it is not valid. > > My solution would be: > > $Pass = md5( whatever ); # I don't care if you hash just the password > # or the username and password as long as > # you do it the same way as you entered > # the passwords. > > mysql_query( "SELECT password, 1 AS auth " . > "FROM acl " . > "WHERE username = '$username' " . > " AND password = '$Pass' " ); > > But I question what you are doing returning password, so it might work > as well as: > > mysql_query( "SELECT count(*) as Authorized " . > "FROM acl " . > "WHERE username = '$username' " . > " AND password = '$Pass' " ); > > This returns 0 or 1 in a field named Authorized depending on if the > password matches or not. > > You might also want to look at the MySQL PASSWORD() function and not > mess with md5 at all. > > Rick > > Rick Widmer > Internet Marketing Specialists > http://www.developersdesk.com > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] -- -- Dan Barton Terrestrial Program Biologist Asst. Data Manager Point Reyes Bird Observatory http://www.prbo.org [EMAIL PROTECTED] [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] Saving sessions info in MySql DB
We recently upgraded to php4.1.0 from 4.0.6 and now our custom session handling doesn't work! We are running on linux with apache, attempting to save session info to a MySQL database (I have session.save_handler=user). There are a couple issues: 1) Occassionally (can't seem to pin down exactly when) I try and access my site and get a "The page cannot be displayed" error in IE. a. The session_start() command seems to be causing this error - If i put die("here"); before session_start(), I see the message. If I move die("here"); after session_start(), I get the error. b. Clicking refresh (sometimes 1 time, sometimes 10 times) will eventually allow me to access my page. 2) The first time I access my page, I attempt to set a session variable ($_SESSION["foo"] = "bar;). When the page finishes loading, the session write handler is called which puts the session information in the database. However, there is nothing written to the value field! (It's still blank!) a. If I refresh the page, the session information is updated in the database, and now the value field has the correct entry (foo|s:3:"bar";) My session save handler is based on http://www.onlamp.com/pub/a/php/2001/05/10/sessions.html?page=2";>this article I read: I'm attaching a copy of my sesssions.php file in case that will help anyone. The only modifications I made were to the read handler - I put in a return of the value from the SELECT. If I take that statement out, problem 1) goes away, but I would NEVER get session information saved into the database!??! (only the SessionID would be stored) Did something change in session handling from 4.0.6 to 4.1.0? If I can't figure this out, we have no choice but to roll back to 4.0.6, but I really love the security additions of 4.1.0 - Help!!! MUCH THANKS IN ADVANCE. John begin 666 sessions.php.txt M/#]P:' -"@T*+RH-"BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ M*BHJ*BHJ*BH-"BHJ#0HJ*@E.86UE.B!T96UP;&%T92YP:' -"BHJ#0HJ*@E! M=71H;W(Z($-O&QI9F5T:6UE(BD[#0HD4T534U]$0B ]("(B.PT*#0HO*@T*<')I M;G0H(FAOPT*"6=L;V)A M;" D4T534U]$0DA/4U0L("1315-37T1"55-%4BP@)%-%4U-?1$)005-3+" D M4T534U]$0DY!344L("1315-37T1".PT*#0H):68@*" A;7ES<6Q?<&-O;FYE M8W0H)%-%4U-?1$)(3U-4+" D4T534U]$0E5315(L("1315-37T1"4$%34RDI M('L-"@D)96-H;R B/&QI/D-A;B=T(&-O;FYE8W0@=&\@)%-%4U-?1$)(3U-4 M(&%S("1315-37T1"55-%4B([#0H)"65C:&\@(CQL:3Y->5-13"!%2 ](")314Q%0U0@=F%L M=64@1E)/32 D4T534U]404),12!72$5212!S97-S:V5Y(#T@)R13240G($%. M1"!E>'!I7-Q;%]Q=65R M>2@D<7)Y*3L-"@T*#0H):68@*&QIPT*"0ER971U'!I2D[#0H-"@EI M9B H(2 D'!I22 ]("7-Q;%]Q=65R>2@D M<7)Y*3L-"GT-"@T*9G5N8W1I;VX@2 ](")$14Q%5$4@1E)/32 D M4T534U]404),12!72$5212!E>'!I2D[#0H-"@ER971U M
RE: [PHP-DB] MySQL Result Resource
Ok, I have tried to go to PASSWORD after none of the suggestions worked out. The current statement is: $arg = "select password, 1 as auth from acl where username='$username' and password = 'PASSWORD($password)'"; But the error I get now is: select password, 1 as auth from acl where username='andrewd' and password = 'PASSWORD(madonna)'Resource id #2 Any ideas? Andrew -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Friday, 11 January 2002 8:56 AM To: Necro; [EMAIL PROTECTED] Subject: RE: [PHP-DB] MySQL Result Resource Addressed to: "Necro" <[EMAIL PROTECTED]> [EMAIL PROTECTED] ** Reply to note from "Necro" <[EMAIL PROTECTED]> Fri, 11 Jan 2002 03:41:43 +1100 > select password, 1 as auth from acl where (username='andrewd' and > password=(163e06103a371fd95b21b4a849bb4b91))1064 : You have an error in your > SQL syntax near 'a371fd95b21b4a849bb4b91))' at line 1 > > Does that help give any idea at all as to what the problem is? > There are no quotes around "163e06103a371fd95b21b4a849bb4b91" The error occurs where it does because '163e06103' is a valid exponential notation value for a nubmer, but having an 'a' follow it is not valid. My solution would be: $Pass = md5( whatever ); # I don't care if you hash just the password # or the username and password as long as # you do it the same way as you entered # the passwords. mysql_query( "SELECT password, 1 AS auth " . "FROM acl " . "WHERE username = '$username' " . " AND password = '$Pass' " ); But I question what you are doing returning password, so it might work as well as: mysql_query( "SELECT count(*) as Authorized " . "FROM acl " . "WHERE username = '$username' " . " AND password = '$Pass' " ); This returns 0 or 1 in a field named Authorized depending on if the password matches or not. You might also want to look at the MySQL PASSWORD() function and not mess with md5 at all. Rick Rick Widmer Internet Marketing Specialists http://www.developersdesk.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] PHP/MySQL Library Catalog System
Hi again everyone, Alnisa Allgood wrote: > You may want to check HotScripts, or the PHP Resource Index > (http://www.hotscripts.com) and (http://php.resourceindex.com). These > locations will most likely have an array of free or low-cost library > solutions. > Thanks all for the HotScripts etc. references. > > The biggest issue is despite the thought that a library is a library, > not all solutions are the same or that similar. Many work for > specific purposes. A good example is I've just finished the first > phase development of a library system. The solution will eventually > be open source, but serves a limited need. This is more of the issue I'm dealing with. The several "HotScripts" for this purpose may or may not be useful, all will probably require some modification (which can be easy or very very hard depending on the quality/style of coding...) > > The primary goal is for the solution to track materials (books, > articles, media), and software for our various client and users. To > that regard the library and software tables store any reference of a > particular material. From this base, clients and users an then build > their own personal libraries for viewing and tracking purposes. So > each client can have a library, as well as each user at a client > site. Ultimately, I hope to add a lending component to it, and work > with some of our nonprofits to do cross-organizational check-outs > and returns. The system is highly geared for technology-based > libraries, since this is of course our primary purpose for providing > the service. > I wrote a (PHP-based) CVS-type system that we use - same general idea. Your project probably has more database table fields. > > So before you go searching, you may want to think a bit more about > what your needs are. Are you just tracking books? What about > articles? Journals? Magazines? Media? Do you need categories? How > many categories can an item be stored in? Single? Multiple? This are > just some issues. But once you've gone through them, you may have a > better idea of which pre-built systems will work for you or not. > We are tracking journals, books, our own publications (about 1,200+), audio recordings, perhaps also some electronic media (although most of this is private, and is already in the CVS-type system we use.) We'd like to be able to integrate the system with other library catalogs easily and efficiently, another reason why any old solution might not work... In terms of categories, there's the general need to follow natural groupings (journals with journals etc.) or subject groupings, in the same way a library catalog would. I have yet to come across a system that can do all of this. (Yes, I did "Google" it before I asked on the list for all of the folks who adamantly suggest we do that.) Thanks, db -- -- Dan Barton Terrestrial Program Biologist Asst. Data Manager Point Reyes Bird Observatory http://www.prbo.org [EMAIL PROTECTED] [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] Re: Record Page Through sqlServer Woes
Hello, Lerp wrote: > > Hi all, I have a small php app where I'd like to incorporate page throughs > of records, say 10 at a time. > > I'm using sqlServer and have run into a problem using the LIMIT statement > within my query. > > Code: > $sqls = "SELECT consultantid, firstname, lastname, city, country, category, > yearsexp FROM CONSULTANT ORDER BY consultantid DESC LIMIT $var1, $var2" ; > > So how the heck do I get around this problem since I've discovered that the > LIMIT statement will not work with sqlServer??? :) You may want to use TOP clause if you are using MS SQL server 7 or better, but I recommend that you use server side cursors, to skip any initial rows thus avoiding returning them from the server. You may also want to try Metabase that is a PHP database abstraction package that simplifies your problem by just making simple call before executing a limited query to specify the row range limits. There is also a ready to use class that displays paged queries in HTML tables already with links to go back and forth, next, previous, first and last pages. Metabase is freely available here: http://phpclasses.upperdesign.com/browse.html/package/20 and the query paging class is here: http://phpclasses.upperdesign.com/browse.html/package/130 An example of output of this class can be seen here: http://phpclasses.upperdesign.com/browse.html/file/414/view/1/name/test_database_table_page.html Regards, Manuel Lemos -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Concept help required
Hi Rick, > many people have a very shallow understanding of SQL - particularly > [he says generalising like crazy] people who 'fall into it' from > (say) PHP programming... This shallow understanding means that > 'they' will tend to do too much in PHP (assuming they know it better) > in preference to SQL - at a cost of efficiency/execution time. WOW! I was beginning to think I was the only one around here who thought that way. Here is a sample query that does most of the work on generating invoices for a job search site. Lines in the code that don't have "" around them are comments I just added... =Thank you for the kind words. It has been an interesting day, and Brian's problem has certainly caused me to revisit the above claim. I'm hoping I've got a solution for him (dependent upon assumptions about 'business rules'), but he will be the judge of that. Thereafter, knowing the db/tbl is so badly set up, it would be quite interesting to run a comparison between 'problem fixed using PHP' and 'problem fixed using MySQL' to see what the relative efficiencies/speed really is. Of course we would then have to 'correct' the db structure and re-try the tests, too. If you're interested perhaps we could cook up some ideas between us? =I have read through the impressive query below. It is an excellent example of code that (I suspect) many would have implemented partly/substantially in PHP. Well done! =I think that it causes me to suggest that my earlier comment (per top of this msg) was only partly thought through, in that having clearly thought out/documented 'business rules' coming out of your design phase has enabled you to collect together the query. In other words, it is likely to be all-but impossible to conceive of such a query unless one uses a top-down design approach. What would be your comment? =I particularly liked the way that the 'business rules' have been embodied into the query. You say "comments I just added", do you mean that these are not actually present in the PHP code? Many people don't realise that you can embed comments in MySQL queries, both the /*...*/ and the #-from-here-to-the-end-of-the-line conventions work. Accordingly all of those comments could be permanently built-in as in-line documentation. =Well done! =dn PS there's a small offering at the end of this msg $R = query( "SELECT Managers.ManagerID, NameFirst, NameLast, " . " Managers.Email, Managers.Phone, Managers.Fax, " . " PayDesc, PayApproved, " . " Employers.EmployerID, Name, Motif, " . " Positions.PositionID, PONumber, Memo, " . "IF( Title = '', 'No Title', Title ) AS Title, " . if the title field is blank, replace it with 'No Title' "IF( ''=Managers.Mail, Managers.Phys, Managers.Mail ) " . "AS Address, " . if the manager has a mailing address use it, else use the physical address. "DATE_FORMAT( DateActive, '%b-%e-%y' ) AS DateActive, " . "IF( DateClosed, " . "DATE_FORMAT( DateClosed, '%b-%e-%y' ), " . "'--Cont--' ) AS DateClosed, " . If DateClosed is blank, say the position is continuing in the closed field. "TO_DAYS( DateActive ) AS Active, " . "TO_DAYS( DateClosed ) AS Closed " . "COUNT(*) AS Count " . Count how many job seekers have responded to the ad so we can brag about it on the bill. "FROM PaymentMethods " . "LEFT JOIN Managers USING( PayMethod ) " . "LEFT JOIN Employers USING( ManagerID ) " . "LEFT JOIN Positions USING( EmployerID ) " . "LEFT JOIN Links USING( PositionID ) " . "WHERE PayMethod = 1 " . Don't bill credit card custmers. (Bill Me only) " AND (( TO_DAYS( Positions.DateCreate ) <= $EOM " . " AND TO_DAYS( DateClosed ) >= $BOM ) " . Only bill for positions that were visible this month. BOM = TO_DAYS() of the first of this month, EOM = end of month. I do a query before this one just to get these values as I didn't want to try to reverse engineer the TO_DAYS() function in MySQL. " OR ( PositionID IS NULL ) " . Ignore entries which have no positions at all " OR ( Employers.EmployerID IS NULL )) "; Ignore entries with no employer record "GROUP BY NameLast, NameFirst, Name, Title " . "ORDER BY NameLast, NameFirst, Name, Title " . '' ); I like the way this is coded into PHP because it allows me to look at the SQL and ignore the PHP code around it very easily. After this query I run thru the data with control breaks on Manager (NameLast, NameFirst), the employers they manage (Name) and the name of the position I am billing on. The data is formatted as an IIF file for import into QuickBooks which prints fancy invoices for each manager. Earlier when we billed by the days the ad was up and calculated the bill
[PHP-DB] Updating a value usins MsAccess db?
I was just wondering if anybody knew how to update values using an access db? (using odbc_exec()?). I have it all setup to display the results, just cant seem to update it, I always get errors. Heres my code: if($da != 0) { $cnx = odbc_connect( 'a' , $u, $p ); if( ! $cnx ) { echo "Error in odbc connect"; } $cur= odbc_exec( $cnx, "UPDATE weekno SET Date=$da" ); if( ! $cur ) { echo "Couldnt return curser"; } odbc_close( $cnx); $dat = $da; } I get Warning: SQL error: [Microsoft][ODBC Microsoft Access Driver] Syntax error in UPDATE statement., SQL state 37000 in SQLExecDirect in c:\inetpub\wwwroot\dbtest.php on line 19 thanks --tom -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] Re: Query Optimizing on sum() function
Hello, Nomor Satu Bajingan wrote: > > Hello Friends, > I've some performance problem, when I do sum() functions on my tables it > took 5-7 minutes to return the results.. here is my story: > I've table with 2461566 rows here is my table structure: > mysql> describe imp_log; > +--+--+--+-+-++ > | Field| Type | Null | Key | Default | Extra > | > +--+--+--+-+-++ > | sno | bigint(10) | | PRI | NULL| > auto_increment | > | advt_id | varchar(20) | | | | > | > | timestamp| datetime | | MUL | -00-00 00:00:00 | > | > | hostname | varchar(120) | | | | > | > | remoteip | varchar(15) | | | | > | > | username | varchar(20) | | MUL | | > | > | camp_id | varchar(8) | | MUL | | > | > | browser_os | varchar(100) | | | | > | > | impressions | int(11) | | | 0 | > | > | cookiestring | varchar(128) | | MUL | | > | > | status | char(1) | | | N | > | > +--+--+--+-+-++ > the problem is I want to sum the impressions from advt_id number 17 (this > advt_id has 855517 records on imp_log table).. I want to sum the > impressions..here is my query: > select sum(impressions) impr from imp_log where camp_id='17'; > but it took 5 minutes for me to do the query... but if I use > count(impressions) it only tooks under 10 sec > mysql> select count(impressions) from imp_log; > ++ > | count(impressions) | > ++ > |2461566 | > ++ > 1 row in set (0.06 sec) This is obvious, when you use count on a key field the server only accesses the respective index. If you do sum() it has to traverse the actual table. Keep in mind that in practice, the table and the indexes are separate things. Actually, if you did count(*) it would be faster than count(field) when the field may be NULL, because count(field) still has to exclude entries where field is NULL. > How to optimize the query ? the strange things is MySQL only uses a little > of cpu time when I did sum() functions...Can I force MySQL to use all the > cpu time ? If MySQL is not using the CPU all the time that means that it is the process is doing non CPU based IO, like disk access to non cached data. This may be a consequence of the fact that your table may have many fields, so to traverse it, MySQL has to do a lot of disk seeking. The solution for this may be splitting the table with the fields that you want to account into child tables. Watch out for joins with more than two tables. > Can I more optimize the query ? I already try to use indexing..but the query > still slow.. Indexes do not make miracles to queries that still have to traverse long tables. > Any help, comments, critics would be very appreciated Do you appreciate it? Database consulting is $200/hour, credit cards or paypal are accepted. Just kidding! :-) Regards, Manuel Lemos -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Concept help required
At 12:53 PM + 1/7/02, George Pitcher wrote: > >One of the features of the FMPro solution is that when a user is looking at >a list of resources (in fact, university course packs) each row will display >the number of associated records from the 'books' database. Now which is the >best method to do this (speed/efficiency)? I have tried performing a >row-level query on the related db but its very slow and times out before the >second row can be displayed. Alternately, I could set the main db to >increase/decrease a number field when adding or deleting books from the >list. Which is recommended? Not to interrupt with the current discussion, because some of the issues brought up, will eventually be needed by you. But for the issue at hand, what you want is SQL. I, too, am an avid FileMaker Developer, who uses PHP/MySQL or FileMaker/Lasso, FileMaker/PHP for web-based solutions. I very much miss my FileMaker calculations, but SQL can handle many of them. I actually find Filemaker's handling of string functions (Filemaker calls them text functions) more flexible, and full-featured then SQL. But with a lot of practice in SQL, you can replicated (recreate FileMaker level functionality) by using SQL. For your situation, it sounds like a calculation like the one below will work. Not knowing what you considered resources, I've basically mentally associated to categories. Lets state that you have a library table that stores books, articles, etc. A category table that stores categories. And a join table called media_cat that stores all relations between library and category. That being true every library_item can have one or more categories, and you wish to create a count of the number of items in each category. The following query will suffice, and should be adaptable for your situation: SELECT library.type, media_cat.category, categories.description, COUNT(library.type) AS count FROM categories, media_cat LEFT JOIN library ON library.libraryID=media_cat.fileID WHERE categories.category=media_cat.category GROUP BY media_cat.category ORDER BY media_cat.category The results from this could be formatted to display like so: Communications (with 9 documents) Donor Relations (with 3 documents) or like so: * databases (with 2 items) applications, query languages, theory, and implementation * networking (with 1 items) networks, telecommunications, protocols, routers, etc. The above explains the more complicated query between three tables, but you can also do this with a single table, or two tables. Alnisa -- . Alnisa Allgood Executive Director Nonprofit Tech (ph) 415.337.7412 (fx) 415.337.7927 (url) http://www.nonprofit-techworld.org (url) http://www.nonprofit-tech.org (url) http://www.tech-library.org . Nonprofit Tech E-Update mailto:[EMAIL PROTECTED] . transforming nonprofits through technology . -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] PHP blocks
On these web portals they have things call blocks that arrange the layout of the site. Where can one go to learn how to do this sort of layout.
Re: [PHP-DB] Query Optimizing on sum() function
Addressed to: "Nomor Satu Bajingan" <[EMAIL PROTECTED]> [EMAIL PROTECTED] ** Reply to note from "Nomor Satu Bajingan" <[EMAIL PROTECTED]> Thu, 10 Jan 2002 13:51:06 + > > Hello Friends, > I've some performance problem, when I do sum() functions on my tables it > took 5-7 minutes to return the results.. here is my story: > I've table with 2461566 rows here is my table structure: > mysql> describe imp_log; > +--+--+--+-+-++ > | Field| Type | Null | Key | Default | Extra > | > +--+--+--+-+-++ > | sno | bigint(10) | | PRI | NULL| > auto_increment | > | advt_id | varchar(20) | | | | > | > | timestamp| datetime | | MUL | -00-00 00:00:00 | > | > the problem is I want to sum the impressions from advt_id number 17 (this > advt_id has 855517 records on imp_log table).. I want to sum the > impressions..here is my query: If you want to look things up by advt_id make it a key, as it is now MySQL must search thru over 24 MILLION records to find the ones belonging to 17 while it is doing the sum. As far as trying to get higher CPU use from the system, you would probably need to buy more(RAID) and/or faster disk drives since your machine is probably banging the disks as fast as it can and the CPU doesn't have much to do but wait for the disks. Try the index first. Rick Widmer Internet Marketing Specialists http://www.developersdesk.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP-DB] MySQL Result Resource
Addressed to: "Necro" <[EMAIL PROTECTED]> [EMAIL PROTECTED] ** Reply to note from "Necro" <[EMAIL PROTECTED]> Fri, 11 Jan 2002 03:41:43 +1100 > select password, 1 as auth from acl where (username='andrewd' and > password=(163e06103a371fd95b21b4a849bb4b91))1064 : You have an error in your > SQL syntax near 'a371fd95b21b4a849bb4b91))' at line 1 > > Does that help give any idea at all as to what the problem is? > There are no quotes around "163e06103a371fd95b21b4a849bb4b91" The error occurs where it does because '163e06103' is a valid exponential notation value for a nubmer, but having an 'a' follow it is not valid. My solution would be: $Pass = md5( whatever ); # I don't care if you hash just the password # or the username and password as long as # you do it the same way as you entered # the passwords. mysql_query( "SELECT password, 1 AS auth " . "FROM acl " . "WHERE username = '$username' " . " AND password = '$Pass' " ); But I question what you are doing returning password, so it might work as well as: mysql_query( "SELECT count(*) as Authorized " . "FROM acl " . "WHERE username = '$username' " . " AND password = '$Pass' " ); This returns 0 or 1 in a field named Authorized depending on if the password matches or not. You might also want to look at the MySQL PASSWORD() function and not mess with md5 at all. Rick Rick Widmer Internet Marketing Specialists http://www.developersdesk.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Concept help required
** Reply to note from "DL Neil" <[EMAIL PROTECTED]> Thu, 10 Jan 2002 14:48:02 - > many people have a very shallow understanding of SQL - particularly > [he says generalising like crazy] people who 'fall into it' from > (say) PHP programming... This shallow understanding means that > 'they' will tend to do too much in PHP (assuming they know it better) > in preference to SQL - at a cost of efficiency/execution time. WOW! I was beginning to think I was the only one around here who thought that way. Here is a sample query that does most of the work on generating invoices for a job search site. Lines in the code that don't have "" around them are comments I just added... $R = query( "SELECT Managers.ManagerID, NameFirst, NameLast, " . " Managers.Email, Managers.Phone, Managers.Fax, " . " PayDesc, PayApproved, " . " Employers.EmployerID, Name, Motif, " . " Positions.PositionID, PONumber, Memo, " . "IF( Title = '', 'No Title', Title ) AS Title, " . if the title field is blank, replace it with 'No Title' "IF( ''=Managers.Mail, Managers.Phys, Managers.Mail ) " . "AS Address, " . if the manager has a mailing address use it, else use the physical address. "DATE_FORMAT( DateActive, '%b-%e-%y' ) AS DateActive, " . "IF( DateClosed, " . "DATE_FORMAT( DateClosed, '%b-%e-%y' ), " . "'--Cont--' ) AS DateClosed, " . If DateClosed is blank, say the position is continuing in the closed field. "TO_DAYS( DateActive ) AS Active, " . "TO_DAYS( DateClosed ) AS Closed " . "COUNT(*) AS Count " . Count how many job seekers have responded to the ad so we can brag about it on the bill. "FROM PaymentMethods " . "LEFT JOIN Managers USING( PayMethod ) " . "LEFT JOIN Employers USING( ManagerID ) " . "LEFT JOIN Positions USING( EmployerID ) " . "LEFT JOIN Links USING( PositionID ) " . "WHERE PayMethod = 1 " . Don't bill credit card custmers. (Bill Me only) " AND (( TO_DAYS( Positions.DateCreate ) <= $EOM " . " AND TO_DAYS( DateClosed ) >= $BOM ) " . Only bill for positions that were visible this month. BOM = TO_DAYS() of the first of this month, EOM = end of month. I do a query before this one just to get these values as I didn't want to try to reverse engineer the TO_DAYS() function in MySQL. " OR ( PositionID IS NULL ) " . Ignore entries which have no positions at all " OR ( Employers.EmployerID IS NULL )) "; Ignore entries with no employer record "GROUP BY NameLast, NameFirst, Name, Title " . "ORDER BY NameLast, NameFirst, Name, Title " . '' ); I like the way this is coded into PHP because it allows me to look at the SQL and ignore the PHP code around it very easily. After this query I run thru the data with control breaks on Manager (NameLast, NameFirst), the employers they manage (Name) and the name of the position I am billing on. The data is formatted as an IIF file for import into QuickBooks which prints fancy invoices for each manager. Earlier when we billed by the days the ad was up and calculated the billing amount in the query, but we changed to billing with a two week block followed by exess days and it ended up being easier to figure that out with PHP. I wish I could find a copy of the old query, it was about a page and a half (36 lines) long. It sure makes the PHP code simple! Note: managers can have more than one Employer they control, and Employers can have more than one position on the site, and they can create and close them at any time they want. Query() is a little function I wrote that wraps mysql_query() and error handling code so I don't have to look at it whem I'm writing programs. Rick Rick Widmer Internet Marketing Specialists http://www.developersdesk.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] PHP/MySQL Library Catalog System
At 12:26 PM -0800 1/10/02, Daniel Barton wrote: >Hi all, > I've noted that a least a couple of people on this list work with >library catalog systems - I'm interested in finding out whether any of >these systems are open-source or are available for a nominal fee. I'm >familiar enough with PHP/MySQL to make one, but I'd also like to avoid >re-inventing the wheel if possible, particularly since I'm not a >librarian :-). The non-profit that I work for has a significant >biological science library that we would like to create a/use an >existing web-based catalog system for. > Also, I'm aware that there is specific funding available for doing >this @ non-profits... I was wondering if anyone else had endeavored >along these lines. > Hi Daniel: You may want to check HotScripts, or the PHP Resource Index (http://www.hotscripts.com) and (http://php.resourceindex.com). These locations will most likely have an array of free or low-cost library solutions. The biggest issue is despite the thought that a library is a library, not all solutions are the same or that similar. Many work for specific purposes. A good example is I've just finished the first phase development of a library system. The solution will eventually be open source, but serves a limited need. The primary goal is for the solution to track materials (books, articles, media), and software for our various client and users. To that regard the library and software tables store any reference of a particular material. From this base, clients and users an then build their own personal libraries for viewing and tracking purposes. So each client can have a library, as well as each user at a client site. Ultimately, I hope to add a lending component to it, and work with some of our nonprofits to do cross-organizational check-outs and returns. The system is highly geared for technology-based libraries, since this is of course our primary purpose for providing the service. So before you go searching, you may want to think a bit more about what your needs are. Are you just tracking books? What about articles? Journals? Magazines? Media? Do you need categories? How many categories can an item be stored in? Single? Multiple? This are just some issues. But once you've gone through them, you may have a better idea of which pre-built systems will work for you or not. Alnisa -- . Alnisa Allgood Executive Director Nonprofit Tech (ph) 415.337.7412 (fx) 415.337.7927 (url) http://www.nonprofit-techworld.org (url) http://www.nonprofit-tech.org (url) http://www.tech-library.org . Nonprofit Tech E-Update mailto:[EMAIL PROTECTED] . transforming nonprofits through technology . -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] PHP/MySQL Library Catalog System
I just saw this which is new on Hotscripts PhpMyLibrary http://www.hotscripts.com/Detailed/13279.html On Thursday 10 January 2002 15:26, Daniel Barton wrote: > Hi all, > I've noted that a least a couple of people on this list work with > library catalog systems - I'm interested in finding out whether any of > these systems are open-source or are available for a nominal fee. I'm > familiar enough with PHP/MySQL to make one, but I'd also like to avoid > re-inventing the wheel if possible, particularly since I'm not a > librarian :-). The non-profit that I work for has a significant > biological science library that we would like to create a/use an > existing web-based catalog system for. > Also, I'm aware that there is specific funding available for doing > this @ non-profits... I was wondering if anyone else had endeavored > along these lines. > > Thanks, > db > > -- > -- > Dan Barton > Terrestrial Program Biologist > Asst. Data Manager > Point Reyes Bird Observatory > http://www.prbo.org > [EMAIL PROTECTED] > [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] PHP/MySQL Library Catalog System
Hi all, I've noted that a least a couple of people on this list work with library catalog systems - I'm interested in finding out whether any of these systems are open-source or are available for a nominal fee. I'm familiar enough with PHP/MySQL to make one, but I'd also like to avoid re-inventing the wheel if possible, particularly since I'm not a librarian :-). The non-profit that I work for has a significant biological science library that we would like to create a/use an existing web-based catalog system for. Also, I'm aware that there is specific funding available for doing this @ non-profits... I was wondering if anyone else had endeavored along these lines. Thanks, db -- -- Dan Barton Terrestrial Program Biologist Asst. Data Manager Point Reyes Bird Observatory http://www.prbo.org [EMAIL PROTECTED] [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] simultaneous dual table entry
Marc, You just use two separate insert statements, one for each table. Miles Thompson At 12:47 PM 1/10/2002 -0500, Marc S. Bragg wrote: >Hi, > >Is there a process / command for inserting information from one form one >input into two separate tables in the same database? Anyone have the >basic command statement? > >thanx mucho' > >Marc >-- >Marc S. Bragg >[EMAIL PROTECTED] >Bialecki & Bragg, PC >p: 610-444-7508 >f: 610-444-7548 > >http://www.chescolawyers.com/BB >"Legal Directory, Services & Consumer Information for Chester County" > > > >-- >PHP Database Mailing List (http://www.php.net/) >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] >To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] simultaneous dual table entry
Hi, Is there a process / command for inserting information from one form one input into two separate tables in the same database? Anyone have the basic command statement? thanx mucho' Marc -- Marc S. Bragg [EMAIL PROTECTED] Bialecki & Bragg, PC p: 610-444-7508 f: 610-444-7548 http://www.chescolawyers.com/BB "Legal Directory, Services & Consumer Information for Chester County" -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] simultaneous dual table entry
Hi, Is there a process for entry from one form to -- Marc S. Bragg [EMAIL PROTECTED] Bialecki & Bragg, PC p: 610-444-7508 f: 610-444-7548 http://www.chescolawyers.com/BB "Legal Directory, Services & Consumer Information for Chester County" -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP-DB] MySQL Result Resource
Well, strip the brackets from around the hash value. Miles At 03:41 AM 1/11/2002 +1100, Necro wrote: >On further investigation it appears to get the correct MD5 value the correct >synatx is: > >$passhash = MD5("$username.$password"); <<--- needs the " > >The the error resulting from this is: > >select password, 1 as auth from acl where (username='andrewd' and >password=(163e06103a371fd95b21b4a849bb4b91))1064 : You have an error in your >SQL syntax near 'a371fd95b21b4a849bb4b91))' at line 1 > >Does that help give any idea at all as to what the problem is? > >Andrew > >-Original Message- >From: Necro [mailto:[EMAIL PROTECTED]] >Sent: Friday, 11 January 2002 3:35 AM >To: [EMAIL PROTECTED] >Subject: RE: [PHP-DB] MySQL Result Resource > > >Miles, > >You must MD5 the value outside of mysql for it to evaluate it, from the >error I just got. >i have tried >$passhash = MD5($username.$password); >$arg = "select password, 1 as auth from acl where (username='andrewd' and >password=($passhash))"; > >And get the following error... >select password, 1 as auth from acl where (username='andrewd' and >password=(c59d088cd3d873af5239cfac1234f370))1054 : Unknown column >'c59d088cd3d873af5239cfac1234f370' in 'where clause' > >So at least the MD5 is now evaluated. But there is still and error in there. > >Andrew > > >-Original Message- >From: Miles Thompson [mailto:[EMAIL PROTECTED]] >Sent: Friday, 11 January 2002 3:29 AM >To: Necro; [EMAIL PROTECTED] >Subject: RE: [PHP-DB] MySQL Result Resource > > > >LIGHT just came on!!! Why does ittake so long. > >MD5(andrew.madonna) - I think you're goint to have to do this >$passhash = $username . $password > >and use MD5($passhash). > >MySQL is looking for a table "andrewd" with the field "madonna" in the way >the MD5() is presently structured. > >Go to it - Miles > >At 03:09 AM 1/11/2002 +1100, Necro wrote: > >Yep, > > > >andrewd is the username im trying to get this script to work with, its an > >authentication script.. > > > >The result of echo $arg is the following: > > > >select password, 1 as auth from acl where username='andrewd' and > >password=MD5(andrewd.madonna)1109 : Unknown table 'andrewd' in where clause > > > >Andrew > > > >-Original Message- > >From: Miles Thompson [mailto:[EMAIL PROTECTED]] > >Sent: Friday, 11 January 2002 3:08 AM > >To: Necro; [EMAIL PROTECTED] > >Subject: RE: [PHP-DB] MySQL Result Resource > > > > > >Can you try this puppy at the MySQL console? I'd dearly love to know where > >"andrewd" is coming from, it sounds like your username. > > > >Before executing mysql_query(), echo $arg and see what it prints. > > > >This is strange, but better than what we had - Miles Thompson > > > >At 02:54 AM 1/11/2002 +1100, Necro wrote: > > >Ok, > > >I have tried a few things now. I finally got it to echo the errors, >firstly > > >there was still a prob with MD5 values being in the apostrophes. > > >Then next error was no db was selected. So i added a mysql_select_db > > >statement. > > >Now i get this: > > > > > >1109 : Unknown table 'andrewd' in where clause > > > > > >andrewd being the username I am trying to get it to accept. > > > > > >Following lines are the current bit: > > > $arg = "select password, 1 as auth from acl where > > > username='$username' and > > >password=MD5($username.$password)"; > > > $result = mysql_query( $arg ) or die(mysql_errno()." : ". > > > mysql_error() ); > > > $row = mysql_fetch_array($result); > > > > > >Andrew > > > > > >-Original Message- > > >From: Miles Thompson [mailto:[EMAIL PROTECTED]] > > >Sent: Friday, 11 January 2002 2:36 AM > > >To: [EMAIL PROTECTED] > > >Subject: RE: [PHP-DB] MySQL Result Resource > > > > > > > > >Break up the code. > > > > > >I assume you are connecting to the database with mysql_connect() or > > >mysql_pconnect(). If not, do that. > > > > > >Echo your query so that you know it contains valid values. > > > > > >Break $row = mysql_fetch_array(mysql_db_query( DATABASE, $arg )); > > >into > > >$result = mysql_query( $arg ) or die(mysql_errno()." : ". >mysql_error() ); > > >$row = mysql_fetch_array($result) ) > > >then do whatever processing you need with the array $row. > > > > > >Miles > > > > > >PS Just reply to the list, if you reply directly to me I have one more > > >message to delete. /mt > > > > > >At 02:10 AM 1/11/2002 +1100, Necro wrote: > > > >Yeh, I notice now the MD5 was wrong. > > > > > > > >But I still get the same error on line 104. If I try and replace it >with > > >the > > > >current query function then I get two errors. > > > > > > > >e.g. > > > >Warning: Supplied argument is not a valid MySQL-Link resource in > > > >d:\htdocs\infekt\packages\auth.inc on line 104 > > > > > > > >Warning: Supplied argument is not a valid MySQL result resource in > > > >d:\htdocs\infekt\packages\auth.inc on line 104 > > > > > > > >Andrew > > > > > > > > > > > >-Original Message- > > > >From: Miles Thompson [mailto:[EMAIL PROTECTED]] > > > >Sent
Re: [PHP-DB] MySQL Result Resource
try : $arg = "select password, 1 as auth from acl where (username='andrewd') and password=MD5(concat(username,password))"; HTH Andrey - Original Message - From: "Necro" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, January 10, 2002 6:29 PM Subject: RE: [PHP-DB] MySQL Result Resource > Parse error: parse error in d:\htdocs\infekt\packages\auth.inc on line 104 > > $arg = "select password, 1 as auth from acl where (username='andrewd' and > password=MD5("andrewd.madonna"))"; > > Nope :( > > > > -Original Message- > From: Andrey Hristov [mailto:[EMAIL PROTECTED]] > Sent: Friday, 11 January 2002 3:28 AM > To: Necro > Cc: [EMAIL PROTECTED] > Subject: Re: [PHP-DB] MySQL Result Resource > > > try this : > > select password, 1 as auth from acl where (username='andrewd' and > password=MD5("andrewd.madonna")); > - Original Message - > From: "Necro" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Thursday, January 10, 2002 6:18 PM > Subject: RE: [PHP-DB] MySQL Result Resource > > > > Same error... > > > > select password, 1 as auth from acl where (username='andrewd' and > > password=MD5(andrewd.madonna))1109 : Unknown table 'andrewd' in where > clause > > > > Andrew > > > > -Original Message- > > From: George Pitcher [mailto:[EMAIL PROTECTED]] > > Sent: Friday, 11 January 2002 3:10 AM > > To: Necro; [EMAIL PROTECTED] > > Subject: Re: [PHP-DB] MySQL Result Resource > > > > > > I was having something similar and solved it by wrapping the column names > in > > parentheses: > > > > select password, 1 as auth from acl where (username='andrewd' and > > password=MD5(andrewd.madonna)); > > > > It might help. or eliminate something if I'm not right. > > > > George > > - Original Message - > > From: "Necro" <[EMAIL PROTECTED]> > > To: <[EMAIL PROTECTED]> > > Sent: Thursday, January 10, 2002 4:09 PM > > Subject: RE: [PHP-DB] MySQL Result Resource > > > > > > > Yep, > > > > > > andrewd is the username im trying to get this script to work with, its > an > > > authentication script.. > > > > > > The result of echo $arg is the following: > > > > > > select password, 1 as auth from acl where username='andrewd' and > > > password=MD5(andrewd.madonna)1109 : Unknown table 'andrewd' in where > > clause > > > > > > Andrew > > > > > > -Original Message- > > > From: Miles Thompson [mailto:[EMAIL PROTECTED]] > > > Sent: Friday, 11 January 2002 3:08 AM > > > To: Necro; [EMAIL PROTECTED] > > > Subject: RE: [PHP-DB] MySQL Result Resource > > > > > > > > > Can you try this puppy at the MySQL console? I'd dearly love to know > where > > > "andrewd" is coming from, it sounds like your username. > > > > > > Before executing mysql_query(), echo $arg and see what it prints. > > > > > > This is strange, but better than what we had - Miles Thompson > > > > > > At 02:54 AM 1/11/2002 +1100, Necro wrote: > > > >Ok, > > > >I have tried a few things now. I finally got it to echo the errors, > > firstly > > > >there was still a prob with MD5 values being in the apostrophes. > > > >Then next error was no db was selected. So i added a mysql_select_db > > > >statement. > > > >Now i get this: > > > > > > > >1109 : Unknown table 'andrewd' in where clause > > > > > > > >andrewd being the username I am trying to get it to accept. > > > > > > > >Following lines are the current bit: > > > > $arg = "select password, 1 as auth from acl where > > > > username='$username' and > > > >password=MD5($username.$password)"; > > > > $result = mysql_query( $arg ) or die(mysql_errno()." : ". > > > > mysql_error() ); > > > > $row = mysql_fetch_array($result); > > > > > > > >Andrew > > > > > > > >-Original Message- > > > >From: Miles Thompson [mailto:[EMAIL PROTECTED]] > > > >Sent: Friday, 11 January 2002 2:36 AM > > > >To: [EMAIL PROTECTED] > > > >Subject: RE: [PHP-DB] MySQL Result Resource > > > > > > > > > > > >Break up the code. > > > > > > > >I assume you are connecting to the database with mysql_connect() or > > > >mysql_pconnect(). If not, do that. > > > > > > > >Echo your query so that you know it contains valid values. > > > > > > > >Break $row = mysql_fetch_array(mysql_db_query( DATABASE, $arg )); > > > >into > > > >$result = mysql_query( $arg ) or die(mysql_errno()." : ". > > mysql_error() ); > > > >$row = mysql_fetch_array($result) ) > > > >then do whatever processing you need with the array $row. > > > > > > > >Miles > > > > > > > >PS Just reply to the list, if you reply directly to me I have one more > > > >message to delete. /mt > > > > > > > >At 02:10 AM 1/11/2002 +1100, Necro wrote: > > > > >Yeh, I notice now the MD5 was wrong. > > > > > > > > > >But I still get the same error on line 104. If I try and replace it > > with > > > >the > > > > >current query function then I get two errors. > > > > > > > > > >e.g. > > > > >Warning: Supplied argument is not a valid MySQL-Link resource in > > > > >d:\htdocs\infekt\packages\auth.inc on line 104 > > > >
RE: [PHP-DB] MySQL Result Resource
On further investigation it appears to get the correct MD5 value the correct synatx is: $passhash = MD5("$username.$password"); <<--- needs the " The the error resulting from this is: select password, 1 as auth from acl where (username='andrewd' and password=(163e06103a371fd95b21b4a849bb4b91))1064 : You have an error in your SQL syntax near 'a371fd95b21b4a849bb4b91))' at line 1 Does that help give any idea at all as to what the problem is? Andrew -Original Message- From: Necro [mailto:[EMAIL PROTECTED]] Sent: Friday, 11 January 2002 3:35 AM To: [EMAIL PROTECTED] Subject: RE: [PHP-DB] MySQL Result Resource Miles, You must MD5 the value outside of mysql for it to evaluate it, from the error I just got. i have tried $passhash = MD5($username.$password); $arg = "select password, 1 as auth from acl where (username='andrewd' and password=($passhash))"; And get the following error... select password, 1 as auth from acl where (username='andrewd' and password=(c59d088cd3d873af5239cfac1234f370))1054 : Unknown column 'c59d088cd3d873af5239cfac1234f370' in 'where clause' So at least the MD5 is now evaluated. But there is still and error in there. Andrew -Original Message- From: Miles Thompson [mailto:[EMAIL PROTECTED]] Sent: Friday, 11 January 2002 3:29 AM To: Necro; [EMAIL PROTECTED] Subject: RE: [PHP-DB] MySQL Result Resource LIGHT just came on!!! Why does ittake so long. MD5(andrew.madonna) - I think you're goint to have to do this $passhash = $username . $password and use MD5($passhash). MySQL is looking for a table "andrewd" with the field "madonna" in the way the MD5() is presently structured. Go to it - Miles At 03:09 AM 1/11/2002 +1100, Necro wrote: >Yep, > >andrewd is the username im trying to get this script to work with, its an >authentication script.. > >The result of echo $arg is the following: > >select password, 1 as auth from acl where username='andrewd' and >password=MD5(andrewd.madonna)1109 : Unknown table 'andrewd' in where clause > >Andrew > >-Original Message- >From: Miles Thompson [mailto:[EMAIL PROTECTED]] >Sent: Friday, 11 January 2002 3:08 AM >To: Necro; [EMAIL PROTECTED] >Subject: RE: [PHP-DB] MySQL Result Resource > > >Can you try this puppy at the MySQL console? I'd dearly love to know where >"andrewd" is coming from, it sounds like your username. > >Before executing mysql_query(), echo $arg and see what it prints. > >This is strange, but better than what we had - Miles Thompson > >At 02:54 AM 1/11/2002 +1100, Necro wrote: > >Ok, > >I have tried a few things now. I finally got it to echo the errors, firstly > >there was still a prob with MD5 values being in the apostrophes. > >Then next error was no db was selected. So i added a mysql_select_db > >statement. > >Now i get this: > > > >1109 : Unknown table 'andrewd' in where clause > > > >andrewd being the username I am trying to get it to accept. > > > >Following lines are the current bit: > > $arg = "select password, 1 as auth from acl where > > username='$username' and > >password=MD5($username.$password)"; > > $result = mysql_query( $arg ) or die(mysql_errno()." : ". > > mysql_error() ); > > $row = mysql_fetch_array($result); > > > >Andrew > > > >-Original Message- > >From: Miles Thompson [mailto:[EMAIL PROTECTED]] > >Sent: Friday, 11 January 2002 2:36 AM > >To: [EMAIL PROTECTED] > >Subject: RE: [PHP-DB] MySQL Result Resource > > > > > >Break up the code. > > > >I assume you are connecting to the database with mysql_connect() or > >mysql_pconnect(). If not, do that. > > > >Echo your query so that you know it contains valid values. > > > >Break $row = mysql_fetch_array(mysql_db_query( DATABASE, $arg )); > >into > >$result = mysql_query( $arg ) or die(mysql_errno()." : ". mysql_error() ); > >$row = mysql_fetch_array($result) ) > >then do whatever processing you need with the array $row. > > > >Miles > > > >PS Just reply to the list, if you reply directly to me I have one more > >message to delete. /mt > > > >At 02:10 AM 1/11/2002 +1100, Necro wrote: > > >Yeh, I notice now the MD5 was wrong. > > > > > >But I still get the same error on line 104. If I try and replace it with > >the > > >current query function then I get two errors. > > > > > >e.g. > > >Warning: Supplied argument is not a valid MySQL-Link resource in > > >d:\htdocs\infekt\packages\auth.inc on line 104 > > > > > >Warning: Supplied argument is not a valid MySQL result resource in > > >d:\htdocs\infekt\packages\auth.inc on line 104 > > > > > >Andrew > > > > > > > > >-Original Message- > > >From: Miles Thompson [mailto:[EMAIL PROTECTED]] > > >Sent: Friday, 11 January 2002 2:05 AM > > >To: Necro; [EMAIL PROTECTED] > > >Subject: Re: [PHP-DB] MySQL Result Resource > > > > > > > > > > > >The use of the MD5 function in the query doesn't look quite right. > > >Shouldn't it be MD5('$password') or MD5('$username'.'$password') if > > >concatenating? > > > > > >Also, mysql_db_query() has been a deprec
RE: [PHP-DB] MySQL Result Resource
Miles, You must MD5 the value outside of mysql for it to evaluate it, from the error I just got. i have tried $passhash = MD5($username.$password); $arg = "select password, 1 as auth from acl where (username='andrewd' and password=($passhash))"; And get the following error... select password, 1 as auth from acl where (username='andrewd' and password=(c59d088cd3d873af5239cfac1234f370))1054 : Unknown column 'c59d088cd3d873af5239cfac1234f370' in 'where clause' So at least the MD5 is now evaluated. But there is still and error in there. Andrew -Original Message- From: Miles Thompson [mailto:[EMAIL PROTECTED]] Sent: Friday, 11 January 2002 3:29 AM To: Necro; [EMAIL PROTECTED] Subject: RE: [PHP-DB] MySQL Result Resource LIGHT just came on!!! Why does ittake so long. MD5(andrew.madonna) - I think you're goint to have to do this $passhash = $username . $password and use MD5($passhash). MySQL is looking for a table "andrewd" with the field "madonna" in the way the MD5() is presently structured. Go to it - Miles At 03:09 AM 1/11/2002 +1100, Necro wrote: >Yep, > >andrewd is the username im trying to get this script to work with, its an >authentication script.. > >The result of echo $arg is the following: > >select password, 1 as auth from acl where username='andrewd' and >password=MD5(andrewd.madonna)1109 : Unknown table 'andrewd' in where clause > >Andrew > >-Original Message- >From: Miles Thompson [mailto:[EMAIL PROTECTED]] >Sent: Friday, 11 January 2002 3:08 AM >To: Necro; [EMAIL PROTECTED] >Subject: RE: [PHP-DB] MySQL Result Resource > > >Can you try this puppy at the MySQL console? I'd dearly love to know where >"andrewd" is coming from, it sounds like your username. > >Before executing mysql_query(), echo $arg and see what it prints. > >This is strange, but better than what we had - Miles Thompson > >At 02:54 AM 1/11/2002 +1100, Necro wrote: > >Ok, > >I have tried a few things now. I finally got it to echo the errors, firstly > >there was still a prob with MD5 values being in the apostrophes. > >Then next error was no db was selected. So i added a mysql_select_db > >statement. > >Now i get this: > > > >1109 : Unknown table 'andrewd' in where clause > > > >andrewd being the username I am trying to get it to accept. > > > >Following lines are the current bit: > > $arg = "select password, 1 as auth from acl where > > username='$username' and > >password=MD5($username.$password)"; > > $result = mysql_query( $arg ) or die(mysql_errno()." : ". > > mysql_error() ); > > $row = mysql_fetch_array($result); > > > >Andrew > > > >-Original Message- > >From: Miles Thompson [mailto:[EMAIL PROTECTED]] > >Sent: Friday, 11 January 2002 2:36 AM > >To: [EMAIL PROTECTED] > >Subject: RE: [PHP-DB] MySQL Result Resource > > > > > >Break up the code. > > > >I assume you are connecting to the database with mysql_connect() or > >mysql_pconnect(). If not, do that. > > > >Echo your query so that you know it contains valid values. > > > >Break $row = mysql_fetch_array(mysql_db_query( DATABASE, $arg )); > >into > >$result = mysql_query( $arg ) or die(mysql_errno()." : ". mysql_error() ); > >$row = mysql_fetch_array($result) ) > >then do whatever processing you need with the array $row. > > > >Miles > > > >PS Just reply to the list, if you reply directly to me I have one more > >message to delete. /mt > > > >At 02:10 AM 1/11/2002 +1100, Necro wrote: > > >Yeh, I notice now the MD5 was wrong. > > > > > >But I still get the same error on line 104. If I try and replace it with > >the > > >current query function then I get two errors. > > > > > >e.g. > > >Warning: Supplied argument is not a valid MySQL-Link resource in > > >d:\htdocs\infekt\packages\auth.inc on line 104 > > > > > >Warning: Supplied argument is not a valid MySQL result resource in > > >d:\htdocs\infekt\packages\auth.inc on line 104 > > > > > >Andrew > > > > > > > > >-Original Message- > > >From: Miles Thompson [mailto:[EMAIL PROTECTED]] > > >Sent: Friday, 11 January 2002 2:05 AM > > >To: Necro; [EMAIL PROTECTED] > > >Subject: Re: [PHP-DB] MySQL Result Resource > > > > > > > > > > > >The use of the MD5 function in the query doesn't look quite right. > > >Shouldn't it be MD5('$password') or MD5('$username'.'$password') if > > >concatenating? > > > > > >Also, mysql_db_query() has been a deprecated function for some time now, > > >mysql_query() is recommended. > > > > > >Hope this gets you going - Miles Thompson > > > > > >At 01:33 AM 1/11/2002 +1100, Necro wrote: > > > >Lo all, > > > > > > > >Slight problem on an auth script... > > > > > > > > > > > >Warning: Supplied argument is not a valid MySQL result resource in > > > >d:\htdocs\infekt\packages\auth.inc on line 104 > > > > > > > > > > > >Line 26: define( "DATABASE", "imanager" ); > > > >Line 103: $arg = "select password, 1 as auth from acl where > > > >username='$username' and password=MD5('$username','$password')"; > > > >Line 104: $row = mysql_fetch_array
AW: [PHP-DB] Problem with PHP, MySQL and Apache System
Hi Miles, First of all: THANK YOU! It seems, that the header() was causing the problem. After disabeling some "foreign" code used for Banner mamangement i could not reproduce the hang (hopefully...) What is the problem with the header() - just curious... Anyway, here what would have been my answers to your prior mail (->): - let me see, if i can get all answere here: Is it possible to go upload an earlier version of one of the pages and hit it repeatedly to see if you get the same behaviour? -> they work all right, as far, as I can see ... When you get the blank page, what do you see in "View Source"? -> while loading the page, I see the correct links & var display in the status line at the bottom, then after a while it show the MS "site not found" stuff... What are browser settings for reloading the page? -> ??? As the vars change all the time, i guess it is a reload always? I did not change the setting in the last serveral months and it always worked ... What happens with other browsers, NS 4.x, NS 6.2, Opera? -> it seems that it works fine with NS 4.7 -> correction - it just took longer to reproduce :-( I tend to suspect the browser. Is there another system you can use to patch/apply MSFT's updates? -> my browser ist 5.5 SP-I plus Sec.Patch Are you trying to deliver files directly to the browser using header() calls, IE 5.5, w/o SP2 doesnt' handle them well. -> header() calls ??? -> Yes, we included a piece of GPL for a poll system and another for Banners. These use header(). will try to disable! ---> there is an admin section, which access the same data - no problem with this, so i guess the mysql DB is ok ---> Is there a way, i can see on the server, what requests are coming in from the browser? ---> I am quite shure, that some log files will have more information on whats going on. What log files should I look at (Apache, MySQL, ?)(and where to find them in a standard install under Linux?) -Ursprungliche Nachricht- Von: Miles Thompson [mailto:[EMAIL PROTECTED]] Gesendet: Donnerstag, 10. Januar 2002 16:25 An: Christian Krzywicki; '[EMAIL PROTECTED]' Betreff: Re: [PHP-DB] Problem with PHP, MySQL and Apache System Is it possible to go upload an earlier version of one of the pages and hit it repeatedly to see if you get the same behaviour? When you get the blank page, what do you see in "View Source"? What are browser settings for reloading the page? What happens with other browsers, NS 4.x, NS 6.2, Opera? I tend to suspect the browser. Is there another system you can use to patch/apply MSFT's updates? Are you trying to deliver files directly to the browser using header() calls, IE 5.5, w/o SP2 doesnt' handle them well. Good luck - Miles Thompson At 04:06 PM 1/10/2002 +0100, Christian Krzywicki wrote: >Hi all! > >I do not know, if this is the right forum, but I need help . > >We have a stable Website, that handeled several thousand visitors a day >before xmas. We did some additional programming (mostly PHP) and are running >into problems right now, that can be reproduced, but we do not know where >they come from: > >Server-side: Linux, Apache, PHP, MySQL >Client: Windows 2000, IE 5.5 > >Surfing the site is fast and traffic is very low today. After surfing around >for some minutes and trying to open a new page i just get back a blank page, >the browser tries to load the page but finally, a "site not found" appears. >This happens with all pages ... When i Restat my browser after closing all >windows, everything is fine. > >Does anybody have a clue, what could be wrong? My knowledge on PHP and MySQL >is medium, on Apache it is almost zero... Any tips are appreciated! > >Thanks > >Christian > >-- >PHP Database Mailing List (http://www.php.net/) >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] >To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP-DB] MySQL Result Resource
Parse error: parse error in d:\htdocs\infekt\packages\auth.inc on line 104 $arg = "select password, 1 as auth from acl where (username='andrewd' and password=MD5("andrewd.madonna"))"; Nope :( -Original Message- From: Andrey Hristov [mailto:[EMAIL PROTECTED]] Sent: Friday, 11 January 2002 3:28 AM To: Necro Cc: [EMAIL PROTECTED] Subject: Re: [PHP-DB] MySQL Result Resource try this : select password, 1 as auth from acl where (username='andrewd' and password=MD5("andrewd.madonna")); - Original Message - From: "Necro" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, January 10, 2002 6:18 PM Subject: RE: [PHP-DB] MySQL Result Resource > Same error... > > select password, 1 as auth from acl where (username='andrewd' and > password=MD5(andrewd.madonna))1109 : Unknown table 'andrewd' in where clause > > Andrew > > -Original Message- > From: George Pitcher [mailto:[EMAIL PROTECTED]] > Sent: Friday, 11 January 2002 3:10 AM > To: Necro; [EMAIL PROTECTED] > Subject: Re: [PHP-DB] MySQL Result Resource > > > I was having something similar and solved it by wrapping the column names in > parentheses: > > select password, 1 as auth from acl where (username='andrewd' and > password=MD5(andrewd.madonna)); > > It might help. or eliminate something if I'm not right. > > George > - Original Message - > From: "Necro" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Thursday, January 10, 2002 4:09 PM > Subject: RE: [PHP-DB] MySQL Result Resource > > > > Yep, > > > > andrewd is the username im trying to get this script to work with, its an > > authentication script.. > > > > The result of echo $arg is the following: > > > > select password, 1 as auth from acl where username='andrewd' and > > password=MD5(andrewd.madonna)1109 : Unknown table 'andrewd' in where > clause > > > > Andrew > > > > -Original Message- > > From: Miles Thompson [mailto:[EMAIL PROTECTED]] > > Sent: Friday, 11 January 2002 3:08 AM > > To: Necro; [EMAIL PROTECTED] > > Subject: RE: [PHP-DB] MySQL Result Resource > > > > > > Can you try this puppy at the MySQL console? I'd dearly love to know where > > "andrewd" is coming from, it sounds like your username. > > > > Before executing mysql_query(), echo $arg and see what it prints. > > > > This is strange, but better than what we had - Miles Thompson > > > > At 02:54 AM 1/11/2002 +1100, Necro wrote: > > >Ok, > > >I have tried a few things now. I finally got it to echo the errors, > firstly > > >there was still a prob with MD5 values being in the apostrophes. > > >Then next error was no db was selected. So i added a mysql_select_db > > >statement. > > >Now i get this: > > > > > >1109 : Unknown table 'andrewd' in where clause > > > > > >andrewd being the username I am trying to get it to accept. > > > > > >Following lines are the current bit: > > > $arg = "select password, 1 as auth from acl where > > > username='$username' and > > >password=MD5($username.$password)"; > > > $result = mysql_query( $arg ) or die(mysql_errno()." : ". > > > mysql_error() ); > > > $row = mysql_fetch_array($result); > > > > > >Andrew > > > > > >-Original Message- > > >From: Miles Thompson [mailto:[EMAIL PROTECTED]] > > >Sent: Friday, 11 January 2002 2:36 AM > > >To: [EMAIL PROTECTED] > > >Subject: RE: [PHP-DB] MySQL Result Resource > > > > > > > > >Break up the code. > > > > > >I assume you are connecting to the database with mysql_connect() or > > >mysql_pconnect(). If not, do that. > > > > > >Echo your query so that you know it contains valid values. > > > > > >Break $row = mysql_fetch_array(mysql_db_query( DATABASE, $arg )); > > >into > > >$result = mysql_query( $arg ) or die(mysql_errno()." : ". > mysql_error() ); > > >$row = mysql_fetch_array($result) ) > > >then do whatever processing you need with the array $row. > > > > > >Miles > > > > > >PS Just reply to the list, if you reply directly to me I have one more > > >message to delete. /mt > > > > > >At 02:10 AM 1/11/2002 +1100, Necro wrote: > > > >Yeh, I notice now the MD5 was wrong. > > > > > > > >But I still get the same error on line 104. If I try and replace it > with > > >the > > > >current query function then I get two errors. > > > > > > > >e.g. > > > >Warning: Supplied argument is not a valid MySQL-Link resource in > > > >d:\htdocs\infekt\packages\auth.inc on line 104 > > > > > > > >Warning: Supplied argument is not a valid MySQL result resource in > > > >d:\htdocs\infekt\packages\auth.inc on line 104 > > > > > > > >Andrew > > > > > > > > > > > >-Original Message- > > > >From: Miles Thompson [mailto:[EMAIL PROTECTED]] > > > >Sent: Friday, 11 January 2002 2:05 AM > > > >To: Necro; [EMAIL PROTECTED] > > > >Subject: Re: [PHP-DB] MySQL Result Resource > > > > > > > > > > > > > > > >The use of the MD5 function in the query doesn't look quite right. > > > >Shouldn't it be MD5('$password') or MD5('$username'.'$password') if > > > >concatenating? > > > > > > > >Also, mysql_d
RE: [PHP-DB] MySQL Result Resource
LIGHT just came on!!! Why does ittake so long. MD5(andrew.madonna) - I think you're goint to have to do this $passhash = $username . $password and use MD5($passhash). MySQL is looking for a table "andrewd" with the field "madonna" in the way the MD5() is presently structured. Go to it - Miles At 03:09 AM 1/11/2002 +1100, Necro wrote: >Yep, > >andrewd is the username im trying to get this script to work with, its an >authentication script.. > >The result of echo $arg is the following: > >select password, 1 as auth from acl where username='andrewd' and >password=MD5(andrewd.madonna)1109 : Unknown table 'andrewd' in where clause > >Andrew > >-Original Message- >From: Miles Thompson [mailto:[EMAIL PROTECTED]] >Sent: Friday, 11 January 2002 3:08 AM >To: Necro; [EMAIL PROTECTED] >Subject: RE: [PHP-DB] MySQL Result Resource > > >Can you try this puppy at the MySQL console? I'd dearly love to know where >"andrewd" is coming from, it sounds like your username. > >Before executing mysql_query(), echo $arg and see what it prints. > >This is strange, but better than what we had - Miles Thompson > >At 02:54 AM 1/11/2002 +1100, Necro wrote: > >Ok, > >I have tried a few things now. I finally got it to echo the errors, firstly > >there was still a prob with MD5 values being in the apostrophes. > >Then next error was no db was selected. So i added a mysql_select_db > >statement. > >Now i get this: > > > >1109 : Unknown table 'andrewd' in where clause > > > >andrewd being the username I am trying to get it to accept. > > > >Following lines are the current bit: > > $arg = "select password, 1 as auth from acl where > > username='$username' and > >password=MD5($username.$password)"; > > $result = mysql_query( $arg ) or die(mysql_errno()." : ". > > mysql_error() ); > > $row = mysql_fetch_array($result); > > > >Andrew > > > >-Original Message- > >From: Miles Thompson [mailto:[EMAIL PROTECTED]] > >Sent: Friday, 11 January 2002 2:36 AM > >To: [EMAIL PROTECTED] > >Subject: RE: [PHP-DB] MySQL Result Resource > > > > > >Break up the code. > > > >I assume you are connecting to the database with mysql_connect() or > >mysql_pconnect(). If not, do that. > > > >Echo your query so that you know it contains valid values. > > > >Break $row = mysql_fetch_array(mysql_db_query( DATABASE, $arg )); > >into > >$result = mysql_query( $arg ) or die(mysql_errno()." : ". mysql_error() ); > >$row = mysql_fetch_array($result) ) > >then do whatever processing you need with the array $row. > > > >Miles > > > >PS Just reply to the list, if you reply directly to me I have one more > >message to delete. /mt > > > >At 02:10 AM 1/11/2002 +1100, Necro wrote: > > >Yeh, I notice now the MD5 was wrong. > > > > > >But I still get the same error on line 104. If I try and replace it with > >the > > >current query function then I get two errors. > > > > > >e.g. > > >Warning: Supplied argument is not a valid MySQL-Link resource in > > >d:\htdocs\infekt\packages\auth.inc on line 104 > > > > > >Warning: Supplied argument is not a valid MySQL result resource in > > >d:\htdocs\infekt\packages\auth.inc on line 104 > > > > > >Andrew > > > > > > > > >-Original Message- > > >From: Miles Thompson [mailto:[EMAIL PROTECTED]] > > >Sent: Friday, 11 January 2002 2:05 AM > > >To: Necro; [EMAIL PROTECTED] > > >Subject: Re: [PHP-DB] MySQL Result Resource > > > > > > > > > > > >The use of the MD5 function in the query doesn't look quite right. > > >Shouldn't it be MD5('$password') or MD5('$username'.'$password') if > > >concatenating? > > > > > >Also, mysql_db_query() has been a deprecated function for some time now, > > >mysql_query() is recommended. > > > > > >Hope this gets you going - Miles Thompson > > > > > >At 01:33 AM 1/11/2002 +1100, Necro wrote: > > > >Lo all, > > > > > > > >Slight problem on an auth script... > > > > > > > > > > > >Warning: Supplied argument is not a valid MySQL result resource in > > > >d:\htdocs\infekt\packages\auth.inc on line 104 > > > > > > > > > > > >Line 26: define( "DATABASE", "imanager" ); > > > >Line 103: $arg = "select password, 1 as auth from acl where > > > >username='$username' and password=MD5('$username','$password')"; > > > >Line 104: $row = mysql_fetch_array(mysql_db_query( DATABASE, $arg )); > > > > > > > > > > > >Can anyone help get this to work?? > > > > > > > >Thankyou. > > > > > > > >Andrew > > > > > > > > > > > >-- > > > >PHP Database Mailing List (http://www.php.net/) > > > >To unsubscribe, e-mail: [EMAIL PROTECTED] > > > >For additional commands, e-mail: [EMAIL PROTECTED] > > > >To contact the list administrators, e-mail: >[EMAIL PROTECTED] > > > > > >-- > >PHP Database Mailing List (http://www.php.net/) > >To unsubscribe, e-mail: [EMAIL PROTECTED] > >For additional commands, e-mail: [EMAIL PROTECTED] > >To contact the list administrators, e-mail: [EMAIL PROTECTED] > > > > > >-- > >PHP Database Mailing List (http://www.php.net/) > >To unsubscribe, e-mail: [EMAIL PROTECTED] >
Re: [PHP-DB] MySQL Result Resource
try this : select password, 1 as auth from acl where (username='andrewd' and password=MD5("andrewd.madonna")); - Original Message - From: "Necro" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, January 10, 2002 6:18 PM Subject: RE: [PHP-DB] MySQL Result Resource > Same error... > > select password, 1 as auth from acl where (username='andrewd' and > password=MD5(andrewd.madonna))1109 : Unknown table 'andrewd' in where clause > > Andrew > > -Original Message- > From: George Pitcher [mailto:[EMAIL PROTECTED]] > Sent: Friday, 11 January 2002 3:10 AM > To: Necro; [EMAIL PROTECTED] > Subject: Re: [PHP-DB] MySQL Result Resource > > > I was having something similar and solved it by wrapping the column names in > parentheses: > > select password, 1 as auth from acl where (username='andrewd' and > password=MD5(andrewd.madonna)); > > It might help. or eliminate something if I'm not right. > > George > - Original Message - > From: "Necro" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Thursday, January 10, 2002 4:09 PM > Subject: RE: [PHP-DB] MySQL Result Resource > > > > Yep, > > > > andrewd is the username im trying to get this script to work with, its an > > authentication script.. > > > > The result of echo $arg is the following: > > > > select password, 1 as auth from acl where username='andrewd' and > > password=MD5(andrewd.madonna)1109 : Unknown table 'andrewd' in where > clause > > > > Andrew > > > > -Original Message- > > From: Miles Thompson [mailto:[EMAIL PROTECTED]] > > Sent: Friday, 11 January 2002 3:08 AM > > To: Necro; [EMAIL PROTECTED] > > Subject: RE: [PHP-DB] MySQL Result Resource > > > > > > Can you try this puppy at the MySQL console? I'd dearly love to know where > > "andrewd" is coming from, it sounds like your username. > > > > Before executing mysql_query(), echo $arg and see what it prints. > > > > This is strange, but better than what we had - Miles Thompson > > > > At 02:54 AM 1/11/2002 +1100, Necro wrote: > > >Ok, > > >I have tried a few things now. I finally got it to echo the errors, > firstly > > >there was still a prob with MD5 values being in the apostrophes. > > >Then next error was no db was selected. So i added a mysql_select_db > > >statement. > > >Now i get this: > > > > > >1109 : Unknown table 'andrewd' in where clause > > > > > >andrewd being the username I am trying to get it to accept. > > > > > >Following lines are the current bit: > > > $arg = "select password, 1 as auth from acl where > > > username='$username' and > > >password=MD5($username.$password)"; > > > $result = mysql_query( $arg ) or die(mysql_errno()." : ". > > > mysql_error() ); > > > $row = mysql_fetch_array($result); > > > > > >Andrew > > > > > >-Original Message- > > >From: Miles Thompson [mailto:[EMAIL PROTECTED]] > > >Sent: Friday, 11 January 2002 2:36 AM > > >To: [EMAIL PROTECTED] > > >Subject: RE: [PHP-DB] MySQL Result Resource > > > > > > > > >Break up the code. > > > > > >I assume you are connecting to the database with mysql_connect() or > > >mysql_pconnect(). If not, do that. > > > > > >Echo your query so that you know it contains valid values. > > > > > >Break $row = mysql_fetch_array(mysql_db_query( DATABASE, $arg )); > > >into > > >$result = mysql_query( $arg ) or die(mysql_errno()." : ". > mysql_error() ); > > >$row = mysql_fetch_array($result) ) > > >then do whatever processing you need with the array $row. > > > > > >Miles > > > > > >PS Just reply to the list, if you reply directly to me I have one more > > >message to delete. /mt > > > > > >At 02:10 AM 1/11/2002 +1100, Necro wrote: > > > >Yeh, I notice now the MD5 was wrong. > > > > > > > >But I still get the same error on line 104. If I try and replace it > with > > >the > > > >current query function then I get two errors. > > > > > > > >e.g. > > > >Warning: Supplied argument is not a valid MySQL-Link resource in > > > >d:\htdocs\infekt\packages\auth.inc on line 104 > > > > > > > >Warning: Supplied argument is not a valid MySQL result resource in > > > >d:\htdocs\infekt\packages\auth.inc on line 104 > > > > > > > >Andrew > > > > > > > > > > > >-Original Message- > > > >From: Miles Thompson [mailto:[EMAIL PROTECTED]] > > > >Sent: Friday, 11 January 2002 2:05 AM > > > >To: Necro; [EMAIL PROTECTED] > > > >Subject: Re: [PHP-DB] MySQL Result Resource > > > > > > > > > > > > > > > >The use of the MD5 function in the query doesn't look quite right. > > > >Shouldn't it be MD5('$password') or MD5('$username'.'$password') if > > > >concatenating? > > > > > > > >Also, mysql_db_query() has been a deprecated function for some time > now, > > > >mysql_query() is recommended. > > > > > > > >Hope this gets you going - Miles Thompson > > > > > > > >At 01:33 AM 1/11/2002 +1100, Necro wrote: > > > > >Lo all, > > > > > > > > > >Slight problem on an auth script... > > > > > > > > > > > > > > >Warning: Supplied argument is not a valid MySQL result resource
RE: [PHP-DB] MySQL Result Resource
Same error... select password, 1 as auth from acl where (username='andrewd' and password=MD5(andrewd.madonna))1109 : Unknown table 'andrewd' in where clause Andrew -Original Message- From: George Pitcher [mailto:[EMAIL PROTECTED]] Sent: Friday, 11 January 2002 3:10 AM To: Necro; [EMAIL PROTECTED] Subject: Re: [PHP-DB] MySQL Result Resource I was having something similar and solved it by wrapping the column names in parentheses: select password, 1 as auth from acl where (username='andrewd' and password=MD5(andrewd.madonna)); It might help. or eliminate something if I'm not right. George - Original Message - From: "Necro" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, January 10, 2002 4:09 PM Subject: RE: [PHP-DB] MySQL Result Resource > Yep, > > andrewd is the username im trying to get this script to work with, its an > authentication script.. > > The result of echo $arg is the following: > > select password, 1 as auth from acl where username='andrewd' and > password=MD5(andrewd.madonna)1109 : Unknown table 'andrewd' in where clause > > Andrew > > -Original Message- > From: Miles Thompson [mailto:[EMAIL PROTECTED]] > Sent: Friday, 11 January 2002 3:08 AM > To: Necro; [EMAIL PROTECTED] > Subject: RE: [PHP-DB] MySQL Result Resource > > > Can you try this puppy at the MySQL console? I'd dearly love to know where > "andrewd" is coming from, it sounds like your username. > > Before executing mysql_query(), echo $arg and see what it prints. > > This is strange, but better than what we had - Miles Thompson > > At 02:54 AM 1/11/2002 +1100, Necro wrote: > >Ok, > >I have tried a few things now. I finally got it to echo the errors, firstly > >there was still a prob with MD5 values being in the apostrophes. > >Then next error was no db was selected. So i added a mysql_select_db > >statement. > >Now i get this: > > > >1109 : Unknown table 'andrewd' in where clause > > > >andrewd being the username I am trying to get it to accept. > > > >Following lines are the current bit: > > $arg = "select password, 1 as auth from acl where > > username='$username' and > >password=MD5($username.$password)"; > > $result = mysql_query( $arg ) or die(mysql_errno()." : ". > > mysql_error() ); > > $row = mysql_fetch_array($result); > > > >Andrew > > > >-Original Message- > >From: Miles Thompson [mailto:[EMAIL PROTECTED]] > >Sent: Friday, 11 January 2002 2:36 AM > >To: [EMAIL PROTECTED] > >Subject: RE: [PHP-DB] MySQL Result Resource > > > > > >Break up the code. > > > >I assume you are connecting to the database with mysql_connect() or > >mysql_pconnect(). If not, do that. > > > >Echo your query so that you know it contains valid values. > > > >Break $row = mysql_fetch_array(mysql_db_query( DATABASE, $arg )); > >into > >$result = mysql_query( $arg ) or die(mysql_errno()." : ". mysql_error() ); > >$row = mysql_fetch_array($result) ) > >then do whatever processing you need with the array $row. > > > >Miles > > > >PS Just reply to the list, if you reply directly to me I have one more > >message to delete. /mt > > > >At 02:10 AM 1/11/2002 +1100, Necro wrote: > > >Yeh, I notice now the MD5 was wrong. > > > > > >But I still get the same error on line 104. If I try and replace it with > >the > > >current query function then I get two errors. > > > > > >e.g. > > >Warning: Supplied argument is not a valid MySQL-Link resource in > > >d:\htdocs\infekt\packages\auth.inc on line 104 > > > > > >Warning: Supplied argument is not a valid MySQL result resource in > > >d:\htdocs\infekt\packages\auth.inc on line 104 > > > > > >Andrew > > > > > > > > >-Original Message- > > >From: Miles Thompson [mailto:[EMAIL PROTECTED]] > > >Sent: Friday, 11 January 2002 2:05 AM > > >To: Necro; [EMAIL PROTECTED] > > >Subject: Re: [PHP-DB] MySQL Result Resource > > > > > > > > > > > >The use of the MD5 function in the query doesn't look quite right. > > >Shouldn't it be MD5('$password') or MD5('$username'.'$password') if > > >concatenating? > > > > > >Also, mysql_db_query() has been a deprecated function for some time now, > > >mysql_query() is recommended. > > > > > >Hope this gets you going - Miles Thompson > > > > > >At 01:33 AM 1/11/2002 +1100, Necro wrote: > > > >Lo all, > > > > > > > >Slight problem on an auth script... > > > > > > > > > > > >Warning: Supplied argument is not a valid MySQL result resource in > > > >d:\htdocs\infekt\packages\auth.inc on line 104 > > > > > > > > > > > >Line 26: define( "DATABASE", "imanager" ); > > > >Line 103: $arg = "select password, 1 as auth from acl where > > > >username='$username' and password=MD5('$username','$password')"; > > > >Line 104: $row = mysql_fetch_array(mysql_db_query( DATABASE, $arg )); > > > > > > > > > > > >Can anyone help get this to work?? > > > > > > > >Thankyou. > > > > > > > >Andrew > > > > > > > > > > > >-- > > > >PHP Database Mailing List (http://www.php.net/) > > > >To unsubscribe, e-mail: [EMAIL PROTECTED] > > > >For
Re: [PHP-DB] MySQL Result Resource
I was having something similar and solved it by wrapping the column names in parentheses: select password, 1 as auth from acl where (username='andrewd' and password=MD5(andrewd.madonna)); It might help. or eliminate something if I'm not right. George - Original Message - From: "Necro" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, January 10, 2002 4:09 PM Subject: RE: [PHP-DB] MySQL Result Resource > Yep, > > andrewd is the username im trying to get this script to work with, its an > authentication script.. > > The result of echo $arg is the following: > > select password, 1 as auth from acl where username='andrewd' and > password=MD5(andrewd.madonna)1109 : Unknown table 'andrewd' in where clause > > Andrew > > -Original Message- > From: Miles Thompson [mailto:[EMAIL PROTECTED]] > Sent: Friday, 11 January 2002 3:08 AM > To: Necro; [EMAIL PROTECTED] > Subject: RE: [PHP-DB] MySQL Result Resource > > > Can you try this puppy at the MySQL console? I'd dearly love to know where > "andrewd" is coming from, it sounds like your username. > > Before executing mysql_query(), echo $arg and see what it prints. > > This is strange, but better than what we had - Miles Thompson > > At 02:54 AM 1/11/2002 +1100, Necro wrote: > >Ok, > >I have tried a few things now. I finally got it to echo the errors, firstly > >there was still a prob with MD5 values being in the apostrophes. > >Then next error was no db was selected. So i added a mysql_select_db > >statement. > >Now i get this: > > > >1109 : Unknown table 'andrewd' in where clause > > > >andrewd being the username I am trying to get it to accept. > > > >Following lines are the current bit: > > $arg = "select password, 1 as auth from acl where > > username='$username' and > >password=MD5($username.$password)"; > > $result = mysql_query( $arg ) or die(mysql_errno()." : ". > > mysql_error() ); > > $row = mysql_fetch_array($result); > > > >Andrew > > > >-Original Message- > >From: Miles Thompson [mailto:[EMAIL PROTECTED]] > >Sent: Friday, 11 January 2002 2:36 AM > >To: [EMAIL PROTECTED] > >Subject: RE: [PHP-DB] MySQL Result Resource > > > > > >Break up the code. > > > >I assume you are connecting to the database with mysql_connect() or > >mysql_pconnect(). If not, do that. > > > >Echo your query so that you know it contains valid values. > > > >Break $row = mysql_fetch_array(mysql_db_query( DATABASE, $arg )); > >into > >$result = mysql_query( $arg ) or die(mysql_errno()." : ". mysql_error() ); > >$row = mysql_fetch_array($result) ) > >then do whatever processing you need with the array $row. > > > >Miles > > > >PS Just reply to the list, if you reply directly to me I have one more > >message to delete. /mt > > > >At 02:10 AM 1/11/2002 +1100, Necro wrote: > > >Yeh, I notice now the MD5 was wrong. > > > > > >But I still get the same error on line 104. If I try and replace it with > >the > > >current query function then I get two errors. > > > > > >e.g. > > >Warning: Supplied argument is not a valid MySQL-Link resource in > > >d:\htdocs\infekt\packages\auth.inc on line 104 > > > > > >Warning: Supplied argument is not a valid MySQL result resource in > > >d:\htdocs\infekt\packages\auth.inc on line 104 > > > > > >Andrew > > > > > > > > >-Original Message- > > >From: Miles Thompson [mailto:[EMAIL PROTECTED]] > > >Sent: Friday, 11 January 2002 2:05 AM > > >To: Necro; [EMAIL PROTECTED] > > >Subject: Re: [PHP-DB] MySQL Result Resource > > > > > > > > > > > >The use of the MD5 function in the query doesn't look quite right. > > >Shouldn't it be MD5('$password') or MD5('$username'.'$password') if > > >concatenating? > > > > > >Also, mysql_db_query() has been a deprecated function for some time now, > > >mysql_query() is recommended. > > > > > >Hope this gets you going - Miles Thompson > > > > > >At 01:33 AM 1/11/2002 +1100, Necro wrote: > > > >Lo all, > > > > > > > >Slight problem on an auth script... > > > > > > > > > > > >Warning: Supplied argument is not a valid MySQL result resource in > > > >d:\htdocs\infekt\packages\auth.inc on line 104 > > > > > > > > > > > >Line 26: define( "DATABASE", "imanager" ); > > > >Line 103: $arg = "select password, 1 as auth from acl where > > > >username='$username' and password=MD5('$username','$password')"; > > > >Line 104: $row = mysql_fetch_array(mysql_db_query( DATABASE, $arg )); > > > > > > > > > > > >Can anyone help get this to work?? > > > > > > > >Thankyou. > > > > > > > >Andrew > > > > > > > > > > > >-- > > > >PHP Database Mailing List (http://www.php.net/) > > > >To unsubscribe, e-mail: [EMAIL PROTECTED] > > > >For additional commands, e-mail: [EMAIL PROTECTED] > > > >To contact the list administrators, e-mail: > [EMAIL PROTECTED] > > > > > >-- > >PHP Database Mailing List (http://www.php.net/) > >To unsubscribe, e-mail: [EMAIL PROTECTED] > >For additional commands, e-mail: [EMAIL PROTECTED] > >To contact the list administrators, e-mail: [EMAIL PROTECTED] > > > >
RE: [PHP-DB] MySQL Result Resource
Yep, andrewd is the username im trying to get this script to work with, its an authentication script.. The result of echo $arg is the following: select password, 1 as auth from acl where username='andrewd' and password=MD5(andrewd.madonna)1109 : Unknown table 'andrewd' in where clause Andrew -Original Message- From: Miles Thompson [mailto:[EMAIL PROTECTED]] Sent: Friday, 11 January 2002 3:08 AM To: Necro; [EMAIL PROTECTED] Subject: RE: [PHP-DB] MySQL Result Resource Can you try this puppy at the MySQL console? I'd dearly love to know where "andrewd" is coming from, it sounds like your username. Before executing mysql_query(), echo $arg and see what it prints. This is strange, but better than what we had - Miles Thompson At 02:54 AM 1/11/2002 +1100, Necro wrote: >Ok, >I have tried a few things now. I finally got it to echo the errors, firstly >there was still a prob with MD5 values being in the apostrophes. >Then next error was no db was selected. So i added a mysql_select_db >statement. >Now i get this: > >1109 : Unknown table 'andrewd' in where clause > >andrewd being the username I am trying to get it to accept. > >Following lines are the current bit: > $arg = "select password, 1 as auth from acl where > username='$username' and >password=MD5($username.$password)"; > $result = mysql_query( $arg ) or die(mysql_errno()." : ". > mysql_error() ); > $row = mysql_fetch_array($result); > >Andrew > >-Original Message- >From: Miles Thompson [mailto:[EMAIL PROTECTED]] >Sent: Friday, 11 January 2002 2:36 AM >To: [EMAIL PROTECTED] >Subject: RE: [PHP-DB] MySQL Result Resource > > >Break up the code. > >I assume you are connecting to the database with mysql_connect() or >mysql_pconnect(). If not, do that. > >Echo your query so that you know it contains valid values. > >Break $row = mysql_fetch_array(mysql_db_query( DATABASE, $arg )); >into >$result = mysql_query( $arg ) or die(mysql_errno()." : ". mysql_error() ); >$row = mysql_fetch_array($result) ) >then do whatever processing you need with the array $row. > >Miles > >PS Just reply to the list, if you reply directly to me I have one more >message to delete. /mt > >At 02:10 AM 1/11/2002 +1100, Necro wrote: > >Yeh, I notice now the MD5 was wrong. > > > >But I still get the same error on line 104. If I try and replace it with >the > >current query function then I get two errors. > > > >e.g. > >Warning: Supplied argument is not a valid MySQL-Link resource in > >d:\htdocs\infekt\packages\auth.inc on line 104 > > > >Warning: Supplied argument is not a valid MySQL result resource in > >d:\htdocs\infekt\packages\auth.inc on line 104 > > > >Andrew > > > > > >-Original Message- > >From: Miles Thompson [mailto:[EMAIL PROTECTED]] > >Sent: Friday, 11 January 2002 2:05 AM > >To: Necro; [EMAIL PROTECTED] > >Subject: Re: [PHP-DB] MySQL Result Resource > > > > > > > >The use of the MD5 function in the query doesn't look quite right. > >Shouldn't it be MD5('$password') or MD5('$username'.'$password') if > >concatenating? > > > >Also, mysql_db_query() has been a deprecated function for some time now, > >mysql_query() is recommended. > > > >Hope this gets you going - Miles Thompson > > > >At 01:33 AM 1/11/2002 +1100, Necro wrote: > > >Lo all, > > > > > >Slight problem on an auth script... > > > > > > > > >Warning: Supplied argument is not a valid MySQL result resource in > > >d:\htdocs\infekt\packages\auth.inc on line 104 > > > > > > > > >Line 26: define( "DATABASE", "imanager" ); > > >Line 103: $arg = "select password, 1 as auth from acl where > > >username='$username' and password=MD5('$username','$password')"; > > >Line 104: $row = mysql_fetch_array(mysql_db_query( DATABASE, $arg )); > > > > > > > > >Can anyone help get this to work?? > > > > > >Thankyou. > > > > > >Andrew > > > > > > > > >-- > > >PHP Database Mailing List (http://www.php.net/) > > >To unsubscribe, e-mail: [EMAIL PROTECTED] > > >For additional commands, e-mail: [EMAIL PROTECTED] > > >To contact the list administrators, e-mail: [EMAIL PROTECTED] > > >-- >PHP Database Mailing List (http://www.php.net/) >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] >To contact the list administrators, e-mail: [EMAIL PROTECTED] > > >-- >PHP Database Mailing List (http://www.php.net/) >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] >To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP-DB] MySQL Result Resource
Can you try this puppy at the MySQL console? I'd dearly love to know where "andrewd" is coming from, it sounds like your username. Before executing mysql_query(), echo $arg and see what it prints. This is strange, but better than what we had - Miles Thompson At 02:54 AM 1/11/2002 +1100, Necro wrote: >Ok, >I have tried a few things now. I finally got it to echo the errors, firstly >there was still a prob with MD5 values being in the apostrophes. >Then next error was no db was selected. So i added a mysql_select_db >statement. >Now i get this: > >1109 : Unknown table 'andrewd' in where clause > >andrewd being the username I am trying to get it to accept. > >Following lines are the current bit: > $arg = "select password, 1 as auth from acl where > username='$username' and >password=MD5($username.$password)"; > $result = mysql_query( $arg ) or die(mysql_errno()." : ". > mysql_error() ); > $row = mysql_fetch_array($result); > >Andrew > >-Original Message- >From: Miles Thompson [mailto:[EMAIL PROTECTED]] >Sent: Friday, 11 January 2002 2:36 AM >To: [EMAIL PROTECTED] >Subject: RE: [PHP-DB] MySQL Result Resource > > >Break up the code. > >I assume you are connecting to the database with mysql_connect() or >mysql_pconnect(). If not, do that. > >Echo your query so that you know it contains valid values. > >Break $row = mysql_fetch_array(mysql_db_query( DATABASE, $arg )); >into >$result = mysql_query( $arg ) or die(mysql_errno()." : ". mysql_error() ); >$row = mysql_fetch_array($result) ) >then do whatever processing you need with the array $row. > >Miles > >PS Just reply to the list, if you reply directly to me I have one more >message to delete. /mt > >At 02:10 AM 1/11/2002 +1100, Necro wrote: > >Yeh, I notice now the MD5 was wrong. > > > >But I still get the same error on line 104. If I try and replace it with >the > >current query function then I get two errors. > > > >e.g. > >Warning: Supplied argument is not a valid MySQL-Link resource in > >d:\htdocs\infekt\packages\auth.inc on line 104 > > > >Warning: Supplied argument is not a valid MySQL result resource in > >d:\htdocs\infekt\packages\auth.inc on line 104 > > > >Andrew > > > > > >-Original Message- > >From: Miles Thompson [mailto:[EMAIL PROTECTED]] > >Sent: Friday, 11 January 2002 2:05 AM > >To: Necro; [EMAIL PROTECTED] > >Subject: Re: [PHP-DB] MySQL Result Resource > > > > > > > >The use of the MD5 function in the query doesn't look quite right. > >Shouldn't it be MD5('$password') or MD5('$username'.'$password') if > >concatenating? > > > >Also, mysql_db_query() has been a deprecated function for some time now, > >mysql_query() is recommended. > > > >Hope this gets you going - Miles Thompson > > > >At 01:33 AM 1/11/2002 +1100, Necro wrote: > > >Lo all, > > > > > >Slight problem on an auth script... > > > > > > > > >Warning: Supplied argument is not a valid MySQL result resource in > > >d:\htdocs\infekt\packages\auth.inc on line 104 > > > > > > > > >Line 26: define( "DATABASE", "imanager" ); > > >Line 103: $arg = "select password, 1 as auth from acl where > > >username='$username' and password=MD5('$username','$password')"; > > >Line 104: $row = mysql_fetch_array(mysql_db_query( DATABASE, $arg )); > > > > > > > > >Can anyone help get this to work?? > > > > > >Thankyou. > > > > > >Andrew > > > > > > > > >-- > > >PHP Database Mailing List (http://www.php.net/) > > >To unsubscribe, e-mail: [EMAIL PROTECTED] > > >For additional commands, e-mail: [EMAIL PROTECTED] > > >To contact the list administrators, e-mail: [EMAIL PROTECTED] > > >-- >PHP Database Mailing List (http://www.php.net/) >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] >To contact the list administrators, e-mail: [EMAIL PROTECTED] > > >-- >PHP Database Mailing List (http://www.php.net/) >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] >To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP-DB] MySQL Result Resource
Ok, I have tried a few things now. I finally got it to echo the errors, firstly there was still a prob with MD5 values being in the apostrophes. Then next error was no db was selected. So i added a mysql_select_db statement. Now i get this: 1109 : Unknown table 'andrewd' in where clause andrewd being the username I am trying to get it to accept. Following lines are the current bit: $arg = "select password, 1 as auth from acl where username='$username' and password=MD5($username.$password)"; $result = mysql_query( $arg ) or die(mysql_errno()." : ". mysql_error() ); $row = mysql_fetch_array($result); Andrew -Original Message- From: Miles Thompson [mailto:[EMAIL PROTECTED]] Sent: Friday, 11 January 2002 2:36 AM To: [EMAIL PROTECTED] Subject: RE: [PHP-DB] MySQL Result Resource Break up the code. I assume you are connecting to the database with mysql_connect() or mysql_pconnect(). If not, do that. Echo your query so that you know it contains valid values. Break $row = mysql_fetch_array(mysql_db_query( DATABASE, $arg )); into $result = mysql_query( $arg ) or die(mysql_errno()." : ". mysql_error() ); $row = mysql_fetch_array($result) ) then do whatever processing you need with the array $row. Miles PS Just reply to the list, if you reply directly to me I have one more message to delete. /mt At 02:10 AM 1/11/2002 +1100, Necro wrote: >Yeh, I notice now the MD5 was wrong. > >But I still get the same error on line 104. If I try and replace it with the >current query function then I get two errors. > >e.g. >Warning: Supplied argument is not a valid MySQL-Link resource in >d:\htdocs\infekt\packages\auth.inc on line 104 > >Warning: Supplied argument is not a valid MySQL result resource in >d:\htdocs\infekt\packages\auth.inc on line 104 > >Andrew > > >-Original Message- >From: Miles Thompson [mailto:[EMAIL PROTECTED]] >Sent: Friday, 11 January 2002 2:05 AM >To: Necro; [EMAIL PROTECTED] >Subject: Re: [PHP-DB] MySQL Result Resource > > > >The use of the MD5 function in the query doesn't look quite right. >Shouldn't it be MD5('$password') or MD5('$username'.'$password') if >concatenating? > >Also, mysql_db_query() has been a deprecated function for some time now, >mysql_query() is recommended. > >Hope this gets you going - Miles Thompson > >At 01:33 AM 1/11/2002 +1100, Necro wrote: > >Lo all, > > > >Slight problem on an auth script... > > > > > >Warning: Supplied argument is not a valid MySQL result resource in > >d:\htdocs\infekt\packages\auth.inc on line 104 > > > > > >Line 26: define( "DATABASE", "imanager" ); > >Line 103: $arg = "select password, 1 as auth from acl where > >username='$username' and password=MD5('$username','$password')"; > >Line 104: $row = mysql_fetch_array(mysql_db_query( DATABASE, $arg )); > > > > > >Can anyone help get this to work?? > > > >Thankyou. > > > >Andrew > > > > > >-- > >PHP Database Mailing List (http://www.php.net/) > >To unsubscribe, e-mail: [EMAIL PROTECTED] > >For additional commands, e-mail: [EMAIL PROTECTED] > >To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Re: [PHP] need help looping through each record witha query -stumped
dn - thanks SO much for your detailed reply. :) yes there are tons of problems :( the "last 3 consecutive Months" issue is tricky enough - but the fact that the database is set up all wrong for this type of query is the real problem. unfortunately changing the structure and field formats then changes a LOT of other scripts that interact with with this table. So i need to figure out which is less time consuming - change the database or change the handful of scripts that use this part of the database. But as far as the loop I was trying to accomplish - any idea why it was not processed through completion.? I need to loop through each user's score and process each one. I can't figure out how to do this one user at a time, i.e.: while (list(Username, $Month, $Score) = mysql_fetch_row($result2)) { this will just return every record in the database and doesn't allow me to loop through each Username. so how would I do this? is this where i might use FOR or FOREACH? brian on 1/10/02 7:23 AM, DL Neil at [EMAIL PROTECTED] wrote: > Brian, > ... > > =regardless of the age of the database, the data appears to be normalised (to > the description given) however it > is definitely NOT optimised. You will notice that each of the contributors has > been attempting to work in MySQL, > but you still have the other option - that of tidying up and debugging your > torturous PHP code! The PHP effort > can be used to attempt to 'recover' from the poor database structure, but as > you have observed, at some cost - > particularly if you ask yourself how you are going to get things to work in > February... The problem with > persisting in this is that you have a weak database structure AND you have > some hairy (hard to understand) PHP > code as a work-around (and may God bless all who sail in her)! > > =like the others, my recommendations consist of revisiting your business rules > and then 'optimising' the > database/data structure - best to fix the problem at its source! > > =the idea that the NAME of each month should be used for processing is causing > major problems. The name of the > month is a LABEL, ie is very useful at the tops of reports, letters, > newspapers, etc. It is NOT a tool for > calculations. If you'd like to take a look at the archives of the PHP > discussion list, you'll find my > contribution on this topic dated a few days ago entitled: "counting with dates > (help!)" talking about the three > primary date formats and their uses. > > =So if I sit a test this month (January), and the last month of last year > (December), and the second-last month > of 2000 (November) [and with blinding arrogance, let me assume that I would > pass each with flying colors (cough, > cough)], and further assume that I haven't sat any other tests [much more my > speed!]; the current logic > (apparently) credits me with a certification!? [thank you] Now before anyone > following this labrythine logic > starts to laugh, let me say that there are good reasons/procedures that might > be in place to prevent such a > stupidity happening - but they will almost certainly also make the process of > keeping historical records more > difficult. > > =how does the system keep track of people who do not sit a test during a > particular month? > > =and the other way around: if I sit the test today and fail [please no jeers, > I'm very sensitive] do the rules > allow/is it possible for me to 'resit' during January. Thus is it possible for > me to sit (and pass) single tests > in Nov and Dec, but sit two tests in Jan - one a 'fail' and one a 'pass'. If > so, are you looking at my last > three tests with a view to certification, or are you looking at my last three > passes (during the pertinent three > months)? > > =further: can we assume that a record will be entered into the scores table > regardless of whether the person > passed or failed? (I have assumed so) > > =while on this theme, how is the system to react if tests are not held during > a particular month, eg the > certification center is closed for summer/Christmas vacation, or out of > respect for September 11? > > =another question about 'rules': the problem description indicates that it is > possible for a person to have sat > January's test already/early in the month, but it is also possible that (s)he > has not. Are the tests held on a > particular date for all candidates, or does the system allow each candidate to > pick his/her own test date? > (which also implies that the January date for all candidates will either be > the same, or is potentially very > different) - this may make it easier/harder to define an SQL query. > > =finally, if I have understood correctly, certification is calculated by three > 'month' units, not 90-days. Thus > the rule is not three passes in the last 90 days, but is in fact (today) > something like the last 100 days, ie > any time in November, not only since 10Nov2001. Correct? > > =all of these questions will have a m
Re: [PHP-DB] Concept help required
David, > =there's a bunch of fast-mover jockies and helo boys who never have to pay for their drinks when any of my guys > are around... > Air Traffic Control was my area, though we did have to put up with some of your lot when Ark Royal was in dock as we were a Buccaneer base. > > =Sorry, misunderstood the 'level' of your question/comment... > > =Yes you are correct, the SQL code 'resides'/is kept within the PHP code. Borrowing an example (and editing a > little) from Brian's post: > > $query = "SELECT Month, Score FROM scores WHERE Username = '$Username' " ; > $result = mysql_query($query2) >or die( "Cannot execute query" . mysql_error () ) ; > > =This is PHP code. The first line of which builds a SQL SELECT statement where the contents of the PHP variable > $Username will be substituted inside the single quotes, eg > > SELECT Month, Score FROM scores WHERE Username = 'George Pitcher' > > =The second line throws the query at MySQL and receives two results by return. Firstly the logical: "did the > call work or not?" which may fire the 'or' clause (returning an error msg and number); and secondly the handle > of the MySQL resultset. (the next step being to retrieve the actual data, as required/appropriate from the > resultset) > > =So at the code-level, the SQL commands/script is/are contained within the .php page. > > =At the logic level, the functionality to retrieve only the single record (that fulfills the stated criteria) > from amongst all those in the database, is contained within the SQL command. > > =but I'm still not sure which one is "wood", and which "trees"! > > =Ok now? Yes, that clarifies a lot. I can stop looking for some place where it might exist in MySQL and concentrate on the design until you are ready for the SQL building. I think that some of my queries might be a bit of a challenge and might require revisiting the design and data structure. I'm not looking for anyone to solve my problems, just to help me along while I learn the basics and then the tricks. George --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.307 / Virus Database: 168 - Release Date: 11/12/01 _ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP-DB] MySQL Result Resource
Break up the code. I assume you are connecting to the database with mysql_connect() or mysql_pconnect(). If not, do that. Echo your query so that you know it contains valid values. Break $row = mysql_fetch_array(mysql_db_query( DATABASE, $arg )); into $result = mysql_query( $arg ) or die(mysql_errno()." : ". mysql_error() ); $row = mysql_fetch_array($result) ) then do whatever processing you need with the array $row. Miles PS Just reply to the list, if you reply directly to me I have one more message to delete. /mt At 02:10 AM 1/11/2002 +1100, Necro wrote: >Yeh, I notice now the MD5 was wrong. > >But I still get the same error on line 104. If I try and replace it with the >current query function then I get two errors. > >e.g. >Warning: Supplied argument is not a valid MySQL-Link resource in >d:\htdocs\infekt\packages\auth.inc on line 104 > >Warning: Supplied argument is not a valid MySQL result resource in >d:\htdocs\infekt\packages\auth.inc on line 104 > >Andrew > > >-Original Message- >From: Miles Thompson [mailto:[EMAIL PROTECTED]] >Sent: Friday, 11 January 2002 2:05 AM >To: Necro; [EMAIL PROTECTED] >Subject: Re: [PHP-DB] MySQL Result Resource > > > >The use of the MD5 function in the query doesn't look quite right. >Shouldn't it be MD5('$password') or MD5('$username'.'$password') if >concatenating? > >Also, mysql_db_query() has been a deprecated function for some time now, >mysql_query() is recommended. > >Hope this gets you going - Miles Thompson > >At 01:33 AM 1/11/2002 +1100, Necro wrote: > >Lo all, > > > >Slight problem on an auth script... > > > > > >Warning: Supplied argument is not a valid MySQL result resource in > >d:\htdocs\infekt\packages\auth.inc on line 104 > > > > > >Line 26: define( "DATABASE", "imanager" ); > >Line 103: $arg = "select password, 1 as auth from acl where > >username='$username' and password=MD5('$username','$password')"; > >Line 104: $row = mysql_fetch_array(mysql_db_query( DATABASE, $arg )); > > > > > >Can anyone help get this to work?? > > > >Thankyou. > > > >Andrew > > > > > >-- > >PHP Database Mailing List (http://www.php.net/) > >To unsubscribe, e-mail: [EMAIL PROTECTED] > >For additional commands, e-mail: [EMAIL PROTECTED] > >To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Concept help required
> > =ex-Navy guys are always "at sea" - however they never let me near the > ships, but I guess that's another > > story... > ex RAF myself (almost 30 years ago though), so I suppose I might be all 'up > in the air'? =there's a bunch of fast-mover jockies and helo boys who never have to pay for their drinks when any of my guys are around... > > =correct MySQL does not CURRENTLY have stored procedures, but it is under > active discussion (too late for us, > > but then...). > > > > =many people have a very shallow understanding of SQL - particularly [he > says generalising like crazy] people > > who 'fall into it' from (say) PHP programming. Indeed my own initial > training course [mumble, mumble] years ago > > majored on SELECT, charged through INSERT and DELETE, and settled lightly > on DML. However there is enormous > > power in the SELECT statement that belies the usual course topics of > SELECT *... and SELECT colName, colName, > > ... and a bit of format control/changing the column names/labels. In my > training course, and many others I've > > seen since, token gestures are made so that even throwing in MAX(), MIN(), > and AVG() seems more an illustration > > of (the more narrow) GROUP BY clause than it does of the SELECT statement. > [rant, rave,...] This shallow > > understanding means that 'they' will tend to do too much in PHP (assuming > they know it better) in preference to > > SQL - at a cost of efficiency/execution time. > > > > =let's make this answer a 'game of two halves': firstly, if you followed > my earlier point, after producing ELH > > diagrams, (my)/the next step is to start writing SQL queries. Thus one > tries to pack as much functionality into > > the SQL statement, as is possible. Each SQL query will feed some response > 'back' to the PHP code (that in the > > finished product, will first call it). Thus if you throw together the > system's SQL calls in a previous > > development step, the only PHP functionality required is that which cannot > be accomplished within MySQL - so my > > terminology may be flawed/deceptive, it is not that I'm taking stuff out > of the PHP code (I haven't written any > > yet/at this stage), it's that it never gets in there in the first place! > Remember the mantra: prevailing wisdom > > says that if you have a choice of doing something in SQL or PHP, do it in > SQL. > > > > =there's an interesting problem on the list (in fact both PHP and PHP-DB) > posed by Brian Tully "need help > > looping through each record with a query -stumped". It is a much > smaller/self-contained example than your own. > > He has presented his 65-line, mainly-PHP code in his statement of the > problem. It provided a brain-starting > > challenge for me this morning, and I have opened my big mouth to suggest > that we could get it down to a much > > less complex single SQL call and one or two nested loops of PHP. To do > this, I have requested some clarification > > of the business rules governing his case. If it suits you, and assuming he > gets back to me, I will work through > > it. Could we then use this as an example of how to shift functionality out > of PHP (the 'middle box') and into > > SQL (the 'left-hand box')? > > Yes, please do. But if I could interject with a sub-concept question. Much > of what I will be scratching my head about can probably be achieved with SQL > as it pertains to data held. Can this fuctionality be built into MySQL or is > it more a case of still doing it all in SQL but the SQL 'script' resides in > the .php page? Just trying to see the trees instead of the wood. =Sorry, misunderstood the 'level' of your question/comment... =Yes you are correct, the SQL code 'resides'/is kept within the PHP code. Borrowing an example (and editing a little) from Brian's post: $query = "SELECT Month, Score FROM scores WHERE Username = '$Username' " ; $result = mysql_query($query2) or die( "Cannot execute query" . mysql_error () ) ; =This is PHP code. The first line of which builds a SQL SELECT statement where the contents of the PHP variable $Username will be substituted inside the single quotes, eg SELECT Month, Score FROM scores WHERE Username = 'George Pitcher' =The second line throws the query at MySQL and receives two results by return. Firstly the logical: "did the call work or not?" which may fire the 'or' clause (returning an error msg and number); and secondly the handle of the MySQL resultset. (the next step being to retrieve the actual data, as required/appropriate from the resultset) =So at the code-level, the SQL commands/script is/are contained within the .php page. =At the logic level, the functionality to retrieve only the single record (that fulfills the stated criteria) from amongst all those in the database, is contained within the SQL command. =but I'm still not sure which one is "wood", and which "trees"! =Ok now? =dn -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Problem with PHP, MySQL and Apache System
Is it possible to go upload an earlier version of one of the pages and hit it repeatedly to see if you get the same behaviour? When you get the blank page, what do you see in "View Source"? What are browser settings for reloading the page? What happens with other browsers, NS 4.x, NS 6.2, Opera? I tend to suspect the browser. Is there another system you can use to patch/apply MSFT's updates? Are you trying to deliver files directly to the browser using header() calls, IE 5.5, w/o SP2 doesnt' handle them well. Good luck - Miles Thompson At 04:06 PM 1/10/2002 +0100, Christian Krzywicki wrote: >Hi all! > >I do not know, if this is the right forum, but I need help . > >We have a stable Website, that handeled several thousand visitors a day >before xmas. We did some additional programming (mostly PHP) and are running >into problems right now, that can be reproduced, but we do not know where >they come from: > >Server-side: Linux, Apache, PHP, MySQL >Client: Windows 2000, IE 5.5 > >Surfing the site is fast and traffic is very low today. After surfing around >for some minutes and trying to open a new page i just get back a blank page, >the browser tries to load the page but finally, a "site not found" appears. >This happens with all pages ... When i Restat my browser after closing all >windows, everything is fine. > >Does anybody have a clue, what could be wrong? My knowledge on PHP and MySQL >is medium, on Apache it is almost zero... Any tips are appreciated! > >Thanks > >Christian > >-- >PHP Database Mailing List (http://www.php.net/) >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] >To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP-DB] MySQL Result Resource
Yeh, I notice now the MD5 was wrong. But I still get the same error on line 104. If I try and replace it with the current query function then I get two errors. e.g. Warning: Supplied argument is not a valid MySQL-Link resource in d:\htdocs\infekt\packages\auth.inc on line 104 Warning: Supplied argument is not a valid MySQL result resource in d:\htdocs\infekt\packages\auth.inc on line 104 Andrew -Original Message- From: Miles Thompson [mailto:[EMAIL PROTECTED]] Sent: Friday, 11 January 2002 2:05 AM To: Necro; [EMAIL PROTECTED] Subject: Re: [PHP-DB] MySQL Result Resource The use of the MD5 function in the query doesn't look quite right. Shouldn't it be MD5('$password') or MD5('$username'.'$password') if concatenating? Also, mysql_db_query() has been a deprecated function for some time now, mysql_query() is recommended. Hope this gets you going - Miles Thompson At 01:33 AM 1/11/2002 +1100, Necro wrote: >Lo all, > >Slight problem on an auth script... > > >Warning: Supplied argument is not a valid MySQL result resource in >d:\htdocs\infekt\packages\auth.inc on line 104 > > >Line 26: define( "DATABASE", "imanager" ); >Line 103: $arg = "select password, 1 as auth from acl where >username='$username' and password=MD5('$username','$password')"; >Line 104: $row = mysql_fetch_array(mysql_db_query( DATABASE, $arg )); > > >Can anyone help get this to work?? > >Thankyou. > >Andrew > > >-- >PHP Database Mailing List (http://www.php.net/) >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] >To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] Problem with PHP, MySQL and Apache System
Hi all! I do not know, if this is the right forum, but I need help . We have a stable Website, that handeled several thousand visitors a day before xmas. We did some additional programming (mostly PHP) and are running into problems right now, that can be reproduced, but we do not know where they come from: Server-side: Linux, Apache, PHP, MySQL Client: Windows 2000, IE 5.5 Surfing the site is fast and traffic is very low today. After surfing around for some minutes and trying to open a new page i just get back a blank page, the browser tries to load the page but finally, a "site not found" appears. This happens with all pages ... When i Restat my browser after closing all windows, everything is fine. Does anybody have a clue, what could be wrong? My knowledge on PHP and MySQL is medium, on Apache it is almost zero... Any tips are appreciated! Thanks Christian -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] MySQL Result Resource
The use of the MD5 function in the query doesn't look quite right. Shouldn't it be MD5('$password') or MD5('$username'.'$password') if concatenating? Also, mysql_db_query() has been a deprecated function for some time now, mysql_query() is recommended. Hope this gets you going - Miles Thompson At 01:33 AM 1/11/2002 +1100, Necro wrote: >Lo all, > >Slight problem on an auth script... > > >Warning: Supplied argument is not a valid MySQL result resource in >d:\htdocs\infekt\packages\auth.inc on line 104 > > >Line 26: define( "DATABASE", "imanager" ); >Line 103: $arg = "select password, 1 as auth from acl where >username='$username' and password=MD5('$username','$password')"; >Line 104: $row = mysql_fetch_array(mysql_db_query( DATABASE, $arg )); > > >Can anyone help get this to work?? > >Thankyou. > >Andrew > > >-- >PHP Database Mailing List (http://www.php.net/) >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] >To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Concept help required
David, > =ex-Navy guys are always "at sea" - however they never let me near the ships, but I guess that's another > story... ex RAF myself (almost 30 years ago though), so I suppose I might be all 'up in the air'? > > > > level). Once again we draw boxes (I have some wonderful s/w for doing > > these tasks, but it is M$). A single > > Visio? > > =yes - but as part of my venturing into LAMPs, I have been pointed to an equivalent package under Linux. > > > =understood - and so whilst you may not 'improve' the system design (the primary objective when developing on a > 'green field' site) it will help in your conversion to SQL/relational technology, as per below. > I'm sure it will. > =correct MySQL does not CURRENTLY have stored procedures, but it is under active discussion (too late for us, > but then...). > > =many people have a very shallow understanding of SQL - particularly [he says generalising like crazy] people > who 'fall into it' from (say) PHP programming. Indeed my own initial training course [mumble, mumble] years ago > majored on SELECT, charged through INSERT and DELETE, and settled lightly on DML. However there is enormous > power in the SELECT statement that belies the usual course topics of SELECT *... and SELECT colName, colName, > ... and a bit of format control/changing the column names/labels. In my training course, and many others I've > seen since, token gestures are made so that even throwing in MAX(), MIN(), and AVG() seems more an illustration > of (the more narrow) GROUP BY clause than it does of the SELECT statement. [rant, rave,...] This shallow > understanding means that 'they' will tend to do too much in PHP (assuming they know it better) in preference to > SQL - at a cost of efficiency/execution time. > > =let's make this answer a 'game of two halves': firstly, if you followed my earlier point, after producing ELH > diagrams, (my)/the next step is to start writing SQL queries. Thus one tries to pack as much functionality into > the SQL statement, as is possible. Each SQL query will feed some response 'back' to the PHP code (that in the > finished product, will first call it). Thus if you throw together the system's SQL calls in a previous > development step, the only PHP functionality required is that which cannot be accomplished within MySQL - so my > terminology may be flawed/deceptive, it is not that I'm taking stuff out of the PHP code (I haven't written any > yet/at this stage), it's that it never gets in there in the first place! Remember the mantra: prevailing wisdom > says that if you have a choice of doing something in SQL or PHP, do it in SQL. > > =there's an interesting problem on the list (in fact both PHP and PHP-DB) posed by Brian Tully "need help > looping through each record with a query -stumped". It is a much smaller/self-contained example than your own. > He has presented his 65-line, mainly-PHP code in his statement of the problem. It provided a brain-starting > challenge for me this morning, and I have opened my big mouth to suggest that we could get it down to a much > less complex single SQL call and one or two nested loops of PHP. To do this, I have requested some clarification > of the business rules governing his case. If it suits you, and assuming he gets back to me, I will work through > it. Could we then use this as an example of how to shift functionality out of PHP (the 'middle box') and into > SQL (the 'left-hand box')? Yes, please do. But if I could interject with a sub-concept question. Much of what I will be scratching my head about can probably be achieved with SQL as it pertains to data held. Can this fuctionality be built into MySQL or is it more a case of still doing it all in SQL but the SQL 'script' resides in the .php page? Just trying to see the trees instead of the wood. George --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.307 / Virus Database: 168 - Release Date: 11/12/01 _ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] Re: [PHP] Query Optimizing on sum() function
1. Please don't cross-post -- it just confuses us. The reply is going to php-db. 2. It seems that you are using imp_log incorrectly. Either you add a record to it for each hit, or for a camp_id value you update the impressions field. Which is it? If the former, then a count() will give you what you need, if the second, then a simple retrieval of the value stored in impressions should do the trick. 3. If the second, then camp_id should be indexed uniquely. 4. Do count() and sum() return the same values? Hope this helps - Miles Thompson At 01:51 PM 1/10/2002 +, Nomor Satu Bajingan wrote: >Hello Friends, >I've some performance problem, when I do sum() functions on my tables it >took 5-7 minutes to return the results.. here is my story: >I've table with 2461566 rows here is my table structure: >mysql> describe imp_log; >+--+--+--+-+-++ >| Field| Type | Null | Key | Default | Extra > | >+--+--+--+-+-++ >| sno | bigint(10) | | PRI | NULL| >auto_increment | >| advt_id | varchar(20) | | | | > | >| timestamp| datetime | | MUL | -00-00 00:00:00 | > | >| hostname | varchar(120) | | | | > | >| remoteip | varchar(15) | | | | > | >| username | varchar(20) | | MUL | | > | >| camp_id | varchar(8) | | MUL | | > | >| browser_os | varchar(100) | | | | > | >| impressions | int(11) | | | 0 | > | >| cookiestring | varchar(128) | | MUL | | > | >| status | char(1) | | | N | > | >+--+--+--+-+-++ >the problem is I want to sum the impressions from advt_id number 17 (this >advt_id has 855517 records on imp_log table).. I want to sum the >impressions..here is my query: >select sum(impressions) impr from imp_log where camp_id='17'; >but it took 5 minutes for me to do the query... but if I use >count(impressions) it only tooks under 10 sec >mysql> select count(impressions) from imp_log; >++ >| count(impressions) | >++ >|2461566 | >++ >1 row in set (0.06 sec) >How to optimize the query ? the strange things is MySQL only uses a little >of cpu time when I did sum() functions...Can I force MySQL to use all the >cpu time ? > >I uses Linux Mandrake 7.0 with MySQL 4.0.0 alpha-max-log >here is the MySQL variables... >mysql> show variables; >+-+---+ >| Variable_name | Value > > > | >+-+---+ >| back_log| 50 > > > | >| basedir | / > > > | >| bdb_cache_size | 8388600 > > > | >| bdb_log_buffer_size | 32768 > > > | >| bdb_home| /var/lib/mysql/ > > > | >| bdb_max_lock| 1 > > > | >| bdb_logdir | > > > | >| bdb_shared_data | OFF > > > | >| bdb_tmpdir | /data/ads/ > > > | >| bdb_version | Sleepycat Software: Berkeley DB >3.2.9a: (October 10, >2001) > > | >| binlog_cache_size | 32768 > > > | >| character_set | latin1 > > > | >| character_sets | latin1 big5 czech euc_kr gb2312 gbk >latin1_de sjis tis620 ujis dec8 dos german1 hp8 koi8_ru latin2 swe7 usa7 >cp1251 danish hebrew win1251 estonia hungarian koi8_ukr win1251ukr greek >win1250 croat cp1257 latin5 | >| concurrent_insert | ON > > > | >| connect_timeout | 5 > > > | >| datadir | /var/lib/mysql/ > > > | >| delay_key_write | ON > > > | >| delayed_insert_limit| 100 > > > | >| delayed_insert_timeout | 300 > > > | >| delayed_queue_size | 10
Re: [PHP-DB] Concept help required
Hi George, > > =I'm feeling a little 'at sea' here, because we had established that you > want to learn more about "joining", yet > > you recognise the word "normalisation" straight off... > Feel free to realign my approach... > No need to feel at sea. After an earlier response from either you or Miles, > I read up on normalisation. =ex-Navy guys are always "at sea" - however they never let me near the ships, but I guess that's another story... > > level). Once again we draw boxes (I have some wonderful s/w for doing > these tasks, but it is M$). A single > Visio? =yes - but as part of my venturing into LAMPs, I have been pointed to an equivalent package under Linux. > > =One of the great things about doing this, is that in examining where the > data is coming from, going to, and how > > it is being used; you are also making a list of all of the db queries that > you will need to contain within your system ... > I will be going through the stages you have mentioned to map out the > processes and data requirements. I think that I know the process enough to > do this without reference to the 'users' considering that at present this is > for purely self-development purposes. =understood - and so whilst you may not 'improve' the system design (the primary objective when developing on a 'green field' site) it will help in your conversion to SQL/relational technology, as per below. > > =Once the diagrams are finished, or for a little light relief (of the > diagram boredom) as I go along, I then use > > a db admin tool for MySQL to start building the SQL code, and testing them > against some sample data... > One area where I remain a bit thick is when it comes to moving the > functionality from the middle (php) box to the left (MySQL) box. How is it > done in MySQL? Is it a case of restructuring the queries to handle the > calculation or is there a pseudo-Stored Procedures (cos I know that MySQL > doesn't use Stored Procedures)? =correct MySQL does not CURRENTLY have stored procedures, but it is under active discussion (too late for us, but then...). =many people have a very shallow understanding of SQL - particularly [he says generalising like crazy] people who 'fall into it' from (say) PHP programming. Indeed my own initial training course [mumble, mumble] years ago majored on SELECT, charged through INSERT and DELETE, and settled lightly on DML. However there is enormous power in the SELECT statement that belies the usual course topics of SELECT *... and SELECT colName, colName, ... and a bit of format control/changing the column names/labels. In my training course, and many others I've seen since, token gestures are made so that even throwing in MAX(), MIN(), and AVG() seems more an illustration of (the more narrow) GROUP BY clause than it does of the SELECT statement. [rant, rave,...] This shallow understanding means that 'they' will tend to do too much in PHP (assuming they know it better) in preference to SQL - at a cost of efficiency/execution time. =let's make this answer a 'game of two halves': firstly, if you followed my earlier point, after producing ELH diagrams, (my)/the next step is to start writing SQL queries. Thus one tries to pack as much functionality into the SQL statement, as is possible. Each SQL query will feed some response 'back' to the PHP code (that in the finished product, will first call it). Thus if you throw together the system's SQL calls in a previous development step, the only PHP functionality required is that which cannot be accomplished within MySQL - so my terminology may be flawed/deceptive, it is not that I'm taking stuff out of the PHP code (I haven't written any yet/at this stage), it's that it never gets in there in the first place! Remember the mantra: prevailing wisdom says that if you have a choice of doing something in SQL or PHP, do it in SQL. =there's an interesting problem on the list (in fact both PHP and PHP-DB) posed by Brian Tully "need help looping through each record with a query -stumped". It is a much smaller/self-contained example than your own. He has presented his 65-line, mainly-PHP code in his statement of the problem. It provided a brain-starting challenge for me this morning, and I have opened my big mouth to suggest that we could get it down to a much less complex single SQL call and one or two nested loops of PHP. To do this, I have requested some clarification of the business rules governing his case. If it suits you, and assuming he gets back to me, I will work through it. Could we then use this as an example of how to shift functionality out of PHP (the 'middle box') and into SQL (the 'left-hand box')? > However, my job here depends on the service succeeding in raisng funding for > continuation beyond July this year else I'll be looking for a company > willing to employ someone with a good overview and no extensive skills! =powerful motivation indeed. Let's see what we can do... =dn -- PHP Database
Re: [PHP-DB] Please help, On phpnuke and phpgroupware.
On Thursday 10 January 2002 22:15, HiM wrote: > Jason, > phpNuke problem fixed after downgrade to 4.0.6 Glad to hear. > Thanks ! You're welcome :) -- Jason Wong -> Gremlins Associates -> www.gremlins.com.hk /* Falling in love is a lot like dying. You never get to do it enough to become good at it. */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] MySQL Result Resource
Lo all, Slight problem on an auth script... Warning: Supplied argument is not a valid MySQL result resource in d:\htdocs\infekt\packages\auth.inc on line 104 Line 26: define( "DATABASE", "imanager" ); Line 103: $arg = "select password, 1 as auth from acl where username='$username' and password=MD5('$username','$password')"; Line 104: $row = mysql_fetch_array(mysql_db_query( DATABASE, $arg )); Can anyone help get this to work?? Thankyou. Andrew -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Please help, On phpnuke and phpgroupware.
Jason, phpNuke problem fixed after downgrade to 4.0.6 Thanks ! And I am still solving to problem with phpgroupware. Nori - - Original Message - From: "Jason Wong" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, January 10, 2002 10:07 PM Subject: Re: [PHP-DB] Please help, On phpnuke and phpgroupware. > On Thursday 10 January 2002 21:53, HiM wrote: > > Jason, > > But after downgrade to 4.0.6, is there any new feature I can't use? > > > > Nori Chan > > > If you're going to be using only PHPNuke and/or PHPGroupware and they haven't > been updated for 4.1.1 then they won't be using any of the new features of > 4.1.1. > > Read the changelog for 4.1.1 to see what's added and fixed. > > > -- > Jason Wong -> Gremlins Associates -> www.gremlins.com.hk > > /* > Let's not complicate our relationship by trying to communicate with each > other. > */ > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Please help, On phpnuke and phpgroupware.
On Thursday 10 January 2002 21:53, HiM wrote: > Jason, > But after downgrade to 4.0.6, is there any new feature I can't use? > > Nori Chan If you're going to be using only PHPNuke and/or PHPGroupware and they haven't been updated for 4.1.1 then they won't be using any of the new features of 4.1.1. Read the changelog for 4.1.1 to see what's added and fixed. -- Jason Wong -> Gremlins Associates -> www.gremlins.com.hk /* Let's not complicate our relationship by trying to communicate with each other. */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] Query Optimizing on sum() function
Hello Friends, I've some performance problem, when I do sum() functions on my tables it took 5-7 minutes to return the results.. here is my story: I've table with 2461566 rows here is my table structure: mysql> describe imp_log; +--+--+--+-+-++ | Field| Type | Null | Key | Default | Extra | +--+--+--+-+-++ | sno | bigint(10) | | PRI | NULL| auto_increment | | advt_id | varchar(20) | | | | | | timestamp| datetime | | MUL | -00-00 00:00:00 | | | hostname | varchar(120) | | | | | | remoteip | varchar(15) | | | | | | username | varchar(20) | | MUL | | | | camp_id | varchar(8) | | MUL | | | | browser_os | varchar(100) | | | | | | impressions | int(11) | | | 0 | | | cookiestring | varchar(128) | | MUL | | | | status | char(1) | | | N | | +--+--+--+-+-++ the problem is I want to sum the impressions from advt_id number 17 (this advt_id has 855517 records on imp_log table).. I want to sum the impressions..here is my query: select sum(impressions) impr from imp_log where camp_id='17'; but it took 5 minutes for me to do the query... but if I use count(impressions) it only tooks under 10 sec mysql> select count(impressions) from imp_log; ++ | count(impressions) | ++ |2461566 | ++ 1 row in set (0.06 sec) How to optimize the query ? the strange things is MySQL only uses a little of cpu time when I did sum() functions...Can I force MySQL to use all the cpu time ? I uses Linux Mandrake 7.0 with MySQL 4.0.0 alpha-max-log here is the MySQL variables... mysql> show variables; +-+---+ | Variable_name | Value | +-+---+ | back_log| 50 | | basedir | / | | bdb_cache_size | 8388600 | | bdb_log_buffer_size | 32768 | | bdb_home| /var/lib/mysql/ | | bdb_max_lock| 1 | | bdb_logdir | | | bdb_shared_data | OFF
Re: [PHP-DB] Please help, On phpnuke and phpgroupware.
Jason, But after downgrade to 4.0.6, is there any new feature I can't use? Nori Chan - Original Message - From: "Jason Wong" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, January 10, 2002 9:41 PM Subject: Re: [PHP-DB] Please help, On phpnuke and phpgroupware. > On Thursday 10 January 2002 21:28, HiM wrote: > > > I am sorry that last message haven't give the URL...:( > > > > http://nori.dns2go.com:8080/phpnuke/html/admin.php > > http://nori.dns2go.com:8080/phpgroupware/setup/config.php > > > > I was trying to use to phpnuke system and also the phpgroupware. > > I have followed the instruction listed in INSTALL step by step. > > But I don't know why there's so many error even in phpnuke / phpgroupware > > > > I am using Windows2000 server and apache, php 4.1.1 and mysql 3.23 > > The recommended php.ini settings for php 4.1.1 are more secure than previous > versions BUT will break a lot of the existing PHP applications. Either change > the php.ini settings to match those of an earlier version of PHP (eg 4.0.6) > or wait until the author of the apps in question upgrade them to make it > compatible with 4.1.1(!) > > > -- > Jason Wong -> Gremlins Associates -> www.gremlins.com.hk > > /* > I don't want people to love me. It makes for obligations. > -- Jean Anouilh > */ > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Please help, On phpnuke and phpgroupware.
On Thursday 10 January 2002 21:28, HiM wrote: > I am sorry that last message haven't give the URL...:( > > http://nori.dns2go.com:8080/phpnuke/html/admin.php > http://nori.dns2go.com:8080/phpgroupware/setup/config.php > > I was trying to use to phpnuke system and also the phpgroupware. > I have followed the instruction listed in INSTALL step by step. > But I don't know why there's so many error even in phpnuke / phpgroupware > > I am using Windows2000 server and apache, php 4.1.1 and mysql 3.23 The recommended php.ini settings for php 4.1.1 are more secure than previous versions BUT will break a lot of the existing PHP applications. Either change the php.ini settings to match those of an earlier version of PHP (eg 4.0.6) or wait until the author of the apps in question upgrade them to make it compatible with 4.1.1(!) -- Jason Wong -> Gremlins Associates -> www.gremlins.com.hk /* I don't want people to love me. It makes for obligations. -- Jean Anouilh */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Concept help required
Olinux, > Haven't been following and not sure if this is what > you're after, but these are some great data models: > http://www.databaseanswers.com/data_models/index.htm Thanks for this. I came across this site/these diagrams before, but thought them to be too 'introductory' and vague for use 'in anger', and without commentary not particularly useful as a tutorial (unless one is really determined) Unfortunately they [that I looked at again today] are also in the form of ERDs (entity relationship diagrams) rather than ELH diagrams (which we had been discussing). So I Googled "entity life history" and diagram... The first hit took me to SmartDraw.com. Their site was good because it shows examples of different types of diagrams, but it is all academic-theoretical/no worked real-life examples. Poking around the site (or duh! using the second Google hit) I did find a fairly simple worked example of an ELH diagram. Tim: these guys are pushing SSADM, a British government initiative from 15-20 years back (no less valid for its age). You (and others in the States) may or may not find it easy to get hold of SSADM stuff, simply because it didn't become popular in the States. A bit further down, Google offers http://www.cscs.wmin.ac.uk/~ssadm/elh/elhs.html which is a lecture from the University of Westminster and part of the/an SSADM organisation's site. It has the sort of worked-descriptions that I mentioned (to Tim) earlier. Rumbling around on their site will also enable the study of other useful design tool/method tutorials - and may save/justify a trip to the library! Regards, =dn -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] Please help, On phpnuke and phpgroupware.
I am sorry that last message haven't give the URL...:( http://nori.dns2go.com:8080/phpnuke/html/admin.php http://nori.dns2go.com:8080/phpgroupware/setup/config.php I was trying to use to phpnuke system and also the phpgroupware. I have followed the instruction listed in INSTALL step by step. But I don't know why there's so many error even in phpnuke / phpgroupware I am using Windows2000 server and apache, php 4.1.1 and mysql 3.23 Please help , I have to build a groupware tool for my work. Nori. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] count
Barry, I can't see where you've created $topictest. Maybe, just before you define $queyr2, you should have the line $topictest = $row[ "topcitext"]; I also think xp_stories_topicid should be xp_stories.topicid Try echo 'ing $query2 and see what is printed. Hope this helps, and that I've not missed something else. Miles Thompson At 02:05 AM 1/11/2002 +1300, Barry Rumsey wrote: >I'm trying to do the following query: > >$db_connect = mysql_connect($sqlhostname,$login,$password); >$base_selection = mysql_select_db($base,$db_connect); >$query = "SELECT DISTINCT * FROM xp_topics WHERE artist_count='artist' AND >topictext LIKE > 'A%' ORDER BY artist_count ASC limit 0,5"; $req = > mysql_query($query); > $res = mysql_num_rows($req); if ($res == 0) > > > { echo " > N/A";} else { while($row = mysql_fetch_array($req)) >$query2 = "SELECT SUM(1) FROM xp_stories,xp_topics WHERE xp_topics.topicid >= xp_stories_topicid AND xp_topics.topictext = '$topictest'"; >$numtopic = mysql_query($query2) or die("Select Failed!"); >$numtopic = mysql_fetch_array($numtopic); > { extract($row); echo ("$topictext $numtopic[0] > "); } } >?> > >Which should return a name and then count how many topics by that person. > >If I leave out the query2 statement I do get a list of name, but I can't >get query2 to work. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] A phpnuke / phpgroupware question..please help me.
I was trying to use to phpnuke system and also the phpgroupware. I have followed the instruction listed in INSTALL step by step. But I don't know why there's so many error even in phpnuke / phpgroupware I am using Windows2000 server and apache, php 4.1.1 and mysql 3.23 Please help , I have to build a groupware tool for my work. Nori. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] count
I'm trying to do the following query: $db_connect = mysql_connect($sqlhostname,$login,$password); $base_selection = mysql_select_db($base,$db_connect); $query = "SELECT DISTINCT * FROM xp_topics WHERE artist_count='artist' AND topictext LIKE 'A%' ORDER BY artist_count ASC limit 0,5"; $req = mysql_query($query); $res = mysql_num_rows($req); if ($res == 0) { echo " N/A";} else { while($row = mysql_fetch_array($req)) $query2 = "SELECT SUM(1) FROM xp_stories,xp_topics WHERE xp_topics.topicid = xp_stories_topicid AND xp_topics.topictext = '$topictest'"; $numtopic = mysql_query($query2) or die("Select Failed!"); $numtopic = mysql_fetch_array($numtopic); { extract($row); echo ("$topictext $numtopic[0] "); } } ?> Which should return a name and then count how many topics by that person. If I leave out the query2 statement I do get a list of name, but I can't get query2 to work.
[PHP-DB] How to use PHP and MS Access?
How can read date and put it into and out of (name.mdb) with SQL query Sergey -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Concept help required
> You wouldn't happen to have a spare ELH diagram (or two) lying around > that one could take a look at, would you? Hah TIM now you've got me! I 'do' diagrams. I don't 'do' neat! [no need to move over Matisse] The longer answer is that I have diagrams coming out of my ears (well, computer), but they are very much working documents, rather than something fit for publication - indeed fit for showing to someone else at all... I (somewhat feebly) suggest that you would do better to grab a book on structured analysis and design from a convenient library. In the 'old days' I would have recommended Yourdon or Jackson, but many have entered the field/published since. Such will have example diagrams chosen for the simplicity of the subject matter, and carefully/logically explained - that's three times better than anything I can (quickly) offer... In addition, they will mention the three or four main diagram types that can be employed in SA and D, which may be yield additional benefits. I fear my stuff, assuming I can weed out something that is both reasonably straightforward and that will 'stand' on its own, will not be quite so 'inspirational'. With apologies... Regards, =dn -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] How can I use MS access file and PHP?
How can I raed and write data to My_file.mdb through PHP with SQL qyery Sergey -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] How to connect MS accsess file
HOw can i read and put data into or out of name.mdb file with sql query Sergey -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] how to use MS Access file
At 17:25 10.01.02 +0600, Sergey wrote: >How can read and put data into or out of file.mdb with sql query With ODBC. Have a look on http://www.unixodbc.org Regards, Ruprecht -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Re: [PHP] need help looping through each record with a query -stumped
Brian, > first off, Martin your suggestion looks great but I don't think its SQL > syntax is supported by MySQL. It's a good start though - gives me something > to work with :) =until it is tried, you won't know! From an SQL point of view it looks ok. In fairness to Martin, from the 'further information' given since it may not do everything you want... > Unfortunately, since this database is ancient and far from > normalized/optimized, neither table uses unique id's. So looking at the > scores table the fields are Username, Month, and Score. > Another big dud is the fact that the Month field is varchar, not a date > field. So this makes it difficult to sort, as Mehmet suggested. > And this also makes it difficult to write a function to automate the 3 > consecutive month aspect that's required. That's why I had to code to look > for specific months - this month (January) counting back 3 (December, > November, October). Students have until the end of the month to take the > monthly test - so they can maintain certification if they have passed Dec., > Nov., and Oct.'s tests. Or, if they have taken and passed January's test, > they can be certified if they've also passed December and November. Make > sense? 4 months total: if the first 3 are passed and/or last 3 are passed > the student is "certified". ... =regardless of the age of the database, the data appears to be normalised (to the description given) however it is definitely NOT optimised. You will notice that each of the contributors has been attempting to work in MySQL, but you still have the other option - that of tidying up and debugging your torturous PHP code! The PHP effort can be used to attempt to 'recover' from the poor database structure, but as you have observed, at some cost - particularly if you ask yourself how you are going to get things to work in February... The problem with persisting in this is that you have a weak database structure AND you have some hairy (hard to understand) PHP code as a work-around (and may God bless all who sail in her)! =like the others, my recommendations consist of revisiting your business rules and then 'optimising' the database/data structure - best to fix the problem at its source! =the idea that the NAME of each month should be used for processing is causing major problems. The name of the month is a LABEL, ie is very useful at the tops of reports, letters, newspapers, etc. It is NOT a tool for calculations. If you'd like to take a look at the archives of the PHP discussion list, you'll find my contribution on this topic dated a few days ago entitled: "counting with dates (help!)" talking about the three primary date formats and their uses. =So if I sit a test this month (January), and the last month of last year (December), and the second-last month of 2000 (November) [and with blinding arrogance, let me assume that I would pass each with flying colors (cough, cough)], and further assume that I haven't sat any other tests [much more my speed!]; the current logic (apparently) credits me with a certification!? [thank you] Now before anyone following this labrythine logic starts to laugh, let me say that there are good reasons/procedures that might be in place to prevent such a stupidity happening - but they will almost certainly also make the process of keeping historical records more difficult. =how does the system keep track of people who do not sit a test during a particular month? =and the other way around: if I sit the test today and fail [please no jeers, I'm very sensitive] do the rules allow/is it possible for me to 'resit' during January. Thus is it possible for me to sit (and pass) single tests in Nov and Dec, but sit two tests in Jan - one a 'fail' and one a 'pass'. If so, are you looking at my last three tests with a view to certification, or are you looking at my last three passes (during the pertinent three months)? =further: can we assume that a record will be entered into the scores table regardless of whether the person passed or failed? (I have assumed so) =while on this theme, how is the system to react if tests are not held during a particular month, eg the certification center is closed for summer/Christmas vacation, or out of respect for September 11? =another question about 'rules': the problem description indicates that it is possible for a person to have sat January's test already/early in the month, but it is also possible that (s)he has not. Are the tests held on a particular date for all candidates, or does the system allow each candidate to pick his/her own test date? (which also implies that the January date for all candidates will either be the same, or is potentially very different) - this may make it easier/harder to define an SQL query. =finally, if I have understood correctly, certification is calculated by three 'month' units, not 90-days. Thus the rule is not three passes in the last 90 days, but is in fact (today) something
[PHP-DB] how to use MS Access file
How can read and put data into or out of file.mdb with sql query Sergey "Rick Emery" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > mysql_connect ('dbhost','user','pass'); > mysql_select_db ('db'); > > $ircname2 = htmlspecialchars($ircname); > > $result = mysql_query ("select ircname from members"); > while( $row = mysql_fetch_array($result) ) > { > print $row['ircname'].""; > } > > ?> > > Don't forget all other HTML tags you need to pack around this > -Original Message- > From: louie miranda [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, January 09, 2002 6:53 AM > To: [EMAIL PROTECTED] > Subject: [PHP-DB] Listing select * from table; on PHP > > > > mysql_connect ('dbhost','user','pass'); > mysql_select_db ('db'); > > $ircname2 = htmlspecialchars($ircname); > > mysql_query ("select ircname from members"); > > print ($ircname2); > ?> > > > -- > > Hi, i have tried this php script to view my table db, > but when i browse it over the net i couldn't see anything > just plain blank page. > > Hm, Can u help me make this show tables over on php > and post it over. > > > > thanks, > louie... > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] Record Page Through sqlServer Woes
Hi all, I have a small php app where I'd like to incorporate page throughs of records, say 10 at a time. I'm using sqlServer and have run into a problem using the LIMIT statement within my query. Code: $sqls = "SELECT consultantid, firstname, lastname, city, country, category, yearsexp FROM CONSULTANT ORDER BY consultantid DESC LIMIT $var1, $var2" ; So how the heck do I get around this problem since I've discovered that the LIMIT statement will not work with sqlServer??? :) Thx a bunch :) Joe -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP-DB] simple question
not tried it, but according to the manual, it should be something like.. SELECT * FROM Bands WHERE Name REGEXP "^[0-9]"; check out the relevant page and see what you think: http://www.mysql.com/doc/S/t/String_comparison_functions.html regards, Matt -Original Message- From: Barry Rumsey [mailto:[EMAIL PROTECTED]] Sent: 10 January 2002 11:46 To: [EMAIL PROTECTED] Subject: [PHP-DB] simple question I have a colum with the numbers between 0-9 ( table is a list of bands )eg. 2 live crew , 2pac , 1 maniacs also in this table Ihave normal names like : abba , queen , police etc.. How would I query the table to list only the ones starting with numbers. --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.312 / Virus Database: 173 - Release Date: 31/12/01 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.312 / Virus Database: 173 - Release Date: 31/12/01 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] simple question
I have a colum with the numbers between 0-9 ( table is a list of bands )eg. 2 live crew , 2pac , 1 maniacs also in this table Ihave normal names like : abba , queen , police etc.. How would I query the table to list only the ones starting with numbers.
Re: [PHP-DB] Updating table with data from another table in the same database
On Wednesday 09 January 2002 19:49, you wrote: > =A daunting task indeed, however it's a move for the better, so more power > to your right arm/kung-fu grip... However let's not jump to quickly to PHP, > and keep it all within MySQL if we can... I was hoping we could ;-) > =So you started with one table: mag_table which contains the columns id, > name, issn, year, info, volume, numbers and remarks. Right. That was the one I got dumped out of Access97 and then modified it a bit with ALTER TABLE. I probably should have included the output from DESCRIBE mag_table and DESCRIBE names, but I forgot.. : ) > =Then you created a table called names (which was too nebulous for me, so I > created table MagNames with columns MagId (auto_increment) and MagName). At > which point we arrive at your question. > > =UPDATE only works on a single table - but you are right on the other > criteria: that the row already exists. So a good first try, but sorry that > one ain't going to get off the ground, Wilbur! That's stupid and quite illogic. One would think that UPDATE would update a column if one tells it to update a column and if one tells it to, it should use data from another table. Why can't it work the way -I- want it to?-) > =I always think that it would be logical to use a REPLACE here, but no > REPLACE doesn't like a table REPLACING data within itself, unless the whole > row is replaced - and even then it cannot refer to (copy values from) > itself. So again, close but no coconut! Yes, I figured that one out while reading the manual. Bummer. That's also a bit stupid. Doesn't quite make any sense. > =So we are pushed into the waiting arms of the INSERT command. Which > requires an existing table and will cheerfully add new records. INSERT-ing > data from another table/tables requires the INSERT...SELECT option (see > manual 6.4.3 INSERT Syntax) Yes, I know, I used it to populate the names (or, if you prefer, mag_names) table. INSERT INTO names (name) SELECT DISTINCT blablabla. > =Accordingly I recommend CREATE-ing a new table, eg the prosaically named > new_mag_table with the columns Id, MagId, ISSN, Year, Info, Volume, > Numbers, Remarks - in other words, exactly the same as mag_table but with > MagId instead of the (mag)name. Then work out how to join the two 'source' > tables to create each record in turn (write the SELECT clause). Then > construct the INSERT clause, slap the SELECT on its end, and the retrieved > data will be inserted into the new_mag_table, eg: [snip] Yes, I remember that I had an idea like that a while back, but then I forgot it :-) One tends to forget things after working for 11-12 hours/day three days in a row... : ) I did just that now, and it works like a charm! [/snip] > =Ok? Very much so! Thanks a million! Now we're (or rather, I'm) a bit wiser again, and I increased the grasp of my kung-foo grip just a bit more!-) Cheers, Markus -- Markus Lervik Linux-administrator with a kungfoo grip Vaasa City Library - Regional Library [EMAIL PROTECTED] +358-6-325 3589 / +358-40-832 6709 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Concept help required
David, > =I'm feeling a little 'at sea' here, because we had established that you want to learn more about "joining", yet > you recognise the word "normalisation" straight off. I don't want to insult you by 'talking down'/teaching > grandma to suck eggs... Please be sure it is not another one of those words that has a particular definition in > the relational world, but was subjugated by wiley marketing people at FM to mean something 'just a little > different' (alternatively that my ignorance of the product is the issue). Feel free to realign my approach... No need to feel at sea. After an earlier response from either you or Miles, I read up on normalisation. > =Continuing on, in such a situation I am always inclined to try to 'cut corners' (against the 'standard' > structured analysis/book approach) - bet this comment gets some of our list colleagues gagging, already thinking > I'm long-winded in my methods. Because, as an outsider, I would not have such an intimate understanding of the > data items and their inter-relationships as you do, I would probably attempt to take the existing data > structures (the tables, and the list of fields/columns in each) and restate/extend these into something called a > ELH diagram (entity life history) - the theory of which you will find in any competent structured analysis and > design or SSADM text (the latter relevant to your location, SSADM being a British Government initiative, if > you'll pardon the oxymoron). I have done these flow charts in the past to demonstrate how my current system should work at a higher level. > =The purpose of an ELH diagram is to take a piece of data (in your case, because we are assuming/checking > normalisation, I'd 'cheat' and work at the table level - rather than something more atomic like the data-item > level). Once again we draw boxes (I have some wonderful s/w for doing these tasks, but it is M$). A single Visio? > label/box at the top, featuring the name of the data-unit, and I would guess a minimum of three (must be my > favorite number!) boxes in the next row, representing the arrival/creation of the data, its use within the > system, and the removal of the data from the system once its usefulness has subsided, respectively. The third > row of boxes represents the actual, individual events in the life-cycle/daily operation of the system, and how > they alter/update/use the data. Lines drawn between the boxes show how these events relate and where there may > be some iteration. > > =This is an analysis/checking tool. As such it bores the socks off most techies. However it is most useful to > ensure that data is being used properly, and for a consistent purpose. In theory it can also be used to check > the data structure because by following the uses to which a piece of data is put during its life, you can ensure > that it is being represented using the 'best' data type for the purpose. It can certainly be used to ensure that > you have the best design of relationships between multiple data items - both in the single table/normalisation > sense, but most especially in the relationships between tables. As I go, my diagrams accumulate a bunch of notes > around the margins with lead-out lines heading back into/from a point in the diagram - reminding me to check > things as the design (or in your case, verification) proceeds. Methodically iterating across dozens of diagrams, > the notes are removed - and the system data coalesces. > > =One of the great things about doing this, is that in examining where the data is coming from, going to, and how > it is being used; you are also making a list of all of the db queries that you will need to contain within your > system - yes you've guessed it, I have another bunch of boxes scattered around my diagrams (in a different > color, just to be petty, er, pretty) which note these needs. If you 'get into' a design book, they will talk > about other related diagrams, eg data-flow diagrams, which would normally be used to contain much of the info > I'm putting into margin-notes - like I said, I'm short-cutting and I think you'll also get away with it because > of your level of knowledge. Feel free to disagree (either way). > I will be going through the stages you have mentioned to map out the processes and data requirements. I think that I know the process enough to do this without reference to the 'users' considering that at present this is for purely self-development purposes. > =Once the diagrams are finished, or for a little light relief (of the diagram boredom) as I go along, I then use > a db admin tool for MySQL to start building the SQL code, and testing them against some sample data. Yes, I > could use the MySQL command line, but I am a fan of MySQL-Front because as well as the stark content of diagrams > and the code-view of the SQL DDL statements, the package gives me a visual representation of the columns/data - > another opportuntity for any incongruities to penetrate this