Re: [PHP] number of records
Diana, This is how I typically do this with mysql_num_rows: $sql = "SELECT * FROM sometable WHERE field LIKE '%$field%' LIMIT 0, 30 "; $result = mysql_query($sql) or die ("Error In Query:".mysql_error()); $num_results = mysql_num_rows($result); HTH! Cory On Tue, 2002-12-10 at 09:54, Diana Castillo wrote: > After I run a query lik this, > $db->query($sql); > > what is the quickest way to find out how many records result? Without having > to loop through them all? > > Thank you , > Diana > -- Cory Hicks <[EMAIL PROTECTED]> TRI-International -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] OO newb question....query results from a class
Hello! I am just getting going with OO stuff and I am stumped at how to pull out query results once it is part of a class. I am also using PEAR. Here is my code: class user { var $retval; function get_signin() { global $db_obj; $DateView = date("Y-m-d"); $sql = "SELECT date_format(sys_time_sign_in, '%h:%i %p') as sign_in FROM system_log WHERE sys_time_user_id='$_SESSION[valid_user]' AND sys_time_date='$DateView' AND sys_time_flag='ON'"; $result = $db_obj->query($sql); if (DB::isError($result)) die($result->getMessage()); while($rows = $db_obj->fetchRow($result, DB_FETCHMODE_ASSOC)) { $retval[] = $rows; } $retval = Array(); $retval['signin'] = $signin; return $retval; } } /* now to try to get at the var $retval */ $userinfo = new user(); echo $userinfo->get_signin(); It just returns "Array"? How do I, for lack of a better wordget to this array? Outside of a class it works great, I echo $rows['sign_in'] and it works. But this! Help! Many many thanks! Cory -- Cory Hicks <[EMAIL PROTECTED]> TRI-International -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] form within form
Can we see some code? Maybe we could help.. Cory On Thu, 2003-02-13 at 12:26, [EMAIL PROTECTED] wrote: > ALso, global variables are off... > > -Original Message- > From: Edward Peloke [mailto:[EMAIL PROTECTED]] > Sent: Thursday, February 13, 2003 1:22 PM > To: Php-General@Lists. Php. Net > Subject: [PHP] form within form > > > I am creating a form to allow the user to change his/her password. After > the user enters their username and old password, I need to verify that info > before they can change their user name and password. So I tried using a > form within a form but am having some problems with passing the parameters > back and forth...any new ideas would be greatly appreciated. I will fill in > all the db stuff later. > > Thanks, > Eddie > > > > > > > > > > UserName: > > > > '> > > > > > > > Password: > > > > > > > > > > > > > > > > > > New Password: > > > > > > > > > > > > Verify Password: > > > > > > > > > > > > > > > > > name=reset> > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php -- Cory Hicks <[EMAIL PROTECTED]> TRI-International -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] form within form
My bad...I see your code now. On Thu, 2003-02-13 at 12:22, [EMAIL PROTECTED] wrote: > I am creating a form to allow the user to change his/her password. After > the user enters their username and old password, I need to verify that info > before they can change their user name and password. So I tried using a > form within a form but am having some problems with passing the parameters > back and forth...any new ideas would be greatly appreciated. I will fill in > all the db stuff later. > > Thanks, > Eddie > > > > > > > > > > UserName: > > > > '> > > > > > > > Password: > > > > > > > > > > > > > > > > > > New Password: > > > > > > > > > > > > Verify Password: > > > > > > > > > > > > > > > > > name=reset> > -- Cory Hicks <[EMAIL PROTECTED]> TRI-International -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Admin Login
Ben, How about some session vars that denote you being an admin? This way you could show these options if $_SESSION[user_info] == 'Admin' is true. If you need more, let me know. Cory On Tue, 2003-06-10 at 22:12, Ben Houlton wrote: > How do I make it so when I log in the options such as delete message, edit message, > are viewable, but when someone else logs in they can't view it. Could someone guide > me to a tutorial or alike? > Thanks. -- Cory Hicks <[EMAIL PROTECTED]> TRI International -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] getting data from inside a class
Hey folks! I just posted this over on the PEAR list, but thought someone here might have some input. Can someone point me in the right direction with this little piece of code. This all works fine to get $num_rows or a single element in an array, but I need to get at all the actual elements in the arraylike $rows["sys_id"] ...how would I do this? Do I return $results[] or $rows? It seems when I have tried this, all I get returned is "Array"... Any help would be great! Thanks, Cory class user_info { var $num_rows; var $results; function get_user_info() { global $db_obj; $sql = "SELECT sys_id, sys_time_user_id, sys_time_flag, sys_time_sign_in, sys_remote_add, sys_user_agent FROM system_log WHERE sys_time_flag = 'On' ORDER BY sys_time_sign_in DESC"; $result=$db_obj->query($sql); if (DB::isError($result)) die($result->getMessage()); /* //works to return num_rows while ($rows = $result->fetchRow(DB_FETCHMODE_ASSOC)) { $this->results[] = $rows; } //$num_rows = $result->numRows(); return $num_rows; */ //works to return 1 value $rows = $result->fetchRow(DB_FETCHMODE_ASSOC); $this->results = $rows[sys_time_user_id]; return $this->results; } } -- Cory Hicks <[EMAIL PROTECTED]> TRI International -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Text from web form
Rick, Someone had mentioned doing the following: << $name = $_POST['name']; $message = $_POST['message']; at the top of your script to enable the variables. >> Or, you could try this at the top of every page: global $HTTP_POST_VARS; global $HTTP_GET_VARS; and then use: $_POST["field_name"] hth!~ Cory >>> "Rick King" <[EMAIL PROTECTED]> 09/11/02 16:29 PM >>> Apache: 1.3.26 PHP: 4.2.3 OS: HPUX-11 Hello PHP Guru's! After successfully installing PHP and viewing the phpinfo page, I decided to create a simple web-form. Just a basic "Name" "Message" web-form, when the form is complete it is emailed to an account. Everything works, except I don't see the filled in contents in the email message. I don't see the what the person filled out. But I see "Name:" ane "Message:" Any ideas? Here's my config line for installing PHP: CC=gcc ./configure --prefix=/opt/php \ --without-mysql \ (didn't have MySQL installed) --with-apxs=/opt/apache/bin/apxs Here's my config line for installing Apache: CC=gcc ./configure --prefix=/opt/apache \ --enable-module=most \ --enable-shared=max Any help would be greatly appreciated! Rick -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Who can tell me where I can get the cracked ZendEncoder3.0 ?
Be gone already! On Thu, 2002-10-31 at 09:00, jianking wrote: > Who can tell me where I can get the cracked Zend Encoder 3.0 ? > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP LDAP attributes question
Hello, I am having trouble returning attributes from an LDAP dir and was curious if anyone had experienced similar issues. I am able to retrieve the attributes in the $nds_stuff fine. However, once I add an attribute to the array, I can get the last attribute in the array, but not the one that comes before. For example, this returns usertier2, but not usertier. If I switch the order, I can get the last one, but not the one that comes before? Here is my code: $filter="(|(cn=" . $login_name . "*))"; //Attributes to get from NDS $nds_stuff = array("cn", "sn", "fullname", "usertier"); //doesn't work as expected //returns usertier2, but usertier is empty //$nds_stuff = array("cn", "sn", "fullname", "usertier","usertier2"); //Search for a specified filter on the directory with the scope of LDAP_SCOPE_SUBTREE $results=ldap_search($ldap, $dn, $filter, $nds_stuff); $info = ldap_get_entries($ldap, $results); //This loops Through the array for ($i=0; $i < $info["count"]; $i++) { //Declare the LDAP results as session variables $valid_user = strtolower($info[$i]["cn"][0]); $user_tier = $info[$i]["usertier"][0]; $user_tier2 = $info[$i]["usertier2"][0]; $user_fullname = $info[$i]["fullname"][0]; } //Close LDAP login array loop ldap_close($ldap); Any suggestions? Cory -- Cory Hicks <[EMAIL PROTECTED]> TRI International -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php