[PHP-DB] database/form help needed
Hi there everyone, I have a loop which goes through my MySQL database and some PHP code which grabs results 9 at a time, and that works great. Now, I also have a checkbox called ID for each of the 9 entries and here is my problem. How can I dynamically assign a unique ID for my checkboxes? I am getting my checkboxes through a loop, and because of that the ID is called id - for all of my entries, so I can't select multiple as only one entry comes out on the results page. How can I dynamically create checkboxes with a unique id (Such as id1, id2 etc ...) so that I can make multiple selections from my DB? Thank you all so much - Happy New Year. Regards Chris Payne www.planetoxygene.com
Re: [PHP-DB] database/form help needed
try using the rand function.. eg... $rand=rand(1,10); but that migth get a same number more then once... my suggestion is this $checkboxid="1"; // Start of the loop echo ""; // end of loop $checkboxid = $checkboxid + 1; that should work i think havent tested that code. but thats my idea. Neil - Original Message - From: Chris Payne <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Saturday, January 05, 2002 10:59 PM Subject: [PHP-DB] database/form help needed Hi there everyone, I have a loop which goes through my MySQL database and some PHP code which grabs results 9 at a time, and that works great. Now, I also have a checkbox called ID for each of the 9 entries and here is my problem. How can I dynamically assign a unique ID for my checkboxes? I am getting my checkboxes through a loop, and because of that the ID is called id - for all of my entries, so I can't select multiple as only one entry comes out on the results page. How can I dynamically create checkboxes with a unique id (Such as id1, id2 etc ...) so that I can make multiple selections from my DB? Thank you all so much - Happy New Year. Regards Chris Payne www.planetoxygene.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] Probably an easy question - blank search fields (PHP & MySQL)
Hiya, I'm writing a backend in MySQL with a PHP frontend. One of the PHP pages searches the database. The user can enter as many or as few fields as they like. I then search the database using this code: $result = mysql_query("select * from equipment where (category='$category') and (description like '$description') and (roomloc='$roomloc') and (quantity like '$quantity') and (serialno like '$serialno') and (patdue like '$patdue')",$db); Messy, I know. The category and roomloc are s and therefore are definite. However, if the user enters nothing for the other fields, they get given no results. If I set the default value of each field to % in the page that calls this, then it works fine. It's just not what I'd like to do - have the user clear out % from each field before putting their data in. Is there an easy way to code "if the field is blank, send %, else send the users entry" or just putting % before whatever is sent? (this shouldn't mess up what's being entered, surely?) Thanks for any help. -- Gary Smith E: [EMAIL PROTECTED] W: http://www.l33t-d00d.co.uk Pics: http://photos.l33t-d00d.co.uk -- 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: Confused Newbie - PHP/Mysql/Apache timeout
Hi, I really hope someone can help me with this. I'm new to PHP; just got started late last year. I've put together a MySQL/Apache/PHP system to manage contacts. It's all running locally on my Win2k system. I have installed phpmyadmin also, and I used that utility to populate my tables. So far, so good. I can browse the tables with that utility all I like. Now, when I go to my own PHP pages, and attempt to pull data, all is well as long as I set my LIMIT to 10 or 15 or so. Much higher than that, and the system just spins its wheels. It never gets to a PHP time-out because it's not PHP taking up the time (in fact, php shows 0 seconds used on the Windows Task Manager). If I stop the browser (IE), I get a partial table, and if I have a look at the source code, it's always just shy of 4, 8, or 16k. (I don't know if that's relevant, but it seemed non-coincidental). But what I'm saying is, it's not a whole lot of data. There's not even 400 rows in the table. And on another page, I attempted to dump all the email addresses from my table into groups of (n) addresses, as a test. I'm only pulling 3 data columns (2 name columns and the email address). Still, the page just idles. Can someone point me to the problem? I think it must be in my code, because I can get PHPMYADMIN to do a complete dump on this system without a problem. Here's a code sample from the email address page. (The web mail client I'm using is wiping out my formatting, please drop me a personal email and I'll send you the actual entire PHP file). if (isset($submit) && (is_numeric($list_length))) { /* We are creating a list from the database */ $sql = "select name_fn, name_ln, email from contact where correspond = 'email' and email is not null and email != '' order by name_ln, name_fn"; $contacts = mysql_query($sql,$db) or die (' ERROR: Unable to read from the database because '.mysql_errno().': '.mysql_error().''); $g =1; $i =1; while ($contact = mysql_fetch_array($contacts)) { if ($i==1) echo "Group $g:"; if ($i>1) echo $list_separator; /* to put a separator between email addresses */ print ($contact['name_fn'].' '.$contact['name_ln'].' <'.$contact['email'].'>'); if ($i==$list_length) { $i=1; $g++; } else { $i++; } } mysql_free_result($contacts); } If it's not my code, can someone maybe point me at someplace I can look next? When I tried this on my old work laptop, (which was using PHP, Mysql and IIS on Win2k), I was able to dump the whole table with a very similar script, and no timeouts. So perhaps it's something about my Apache setup? I'm very confused, please give a newbie a hand? Thanks, -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: Probably an easy question - blank search fields (PHP & MySQL)
if (empty($var)) { } else { } -- Best regards, George Nicolae IT Manager ___ X-Playin - Professional Web Design www.x-playin.f2s.com "Gary Smith" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Hiya, I'm writing a backend in MySQL with a PHP frontend. One of the PHP > pages searches the database. The user can enter as many or as few fields as > they like. I then search the database using this code: > > $result = mysql_query("select * from equipment where (category='$category') > and (description like '$description') and (roomloc='$roomloc') and > (quantity like '$quantity') and (serialno like '$serialno') and (patdue > like '$patdue')",$db); > > Messy, I know. The category and roomloc are s and therefore are > definite. However, if the user enters nothing for the other fields, they > get given no results. If I set the default value of each field to % in the > page that calls this, then it works fine. > > It's just not what I'd like to do - have the user clear out % from each > field before putting their data in. Is there an easy way to code "if the > field is blank, send %, else send the users entry" or just putting % before > whatever is sent? (this shouldn't mess up what's being entered, surely?) > > Thanks for any help. > -- > Gary Smith > E: [EMAIL PROTECTED] > W: http://www.l33t-d00d.co.uk > Pics: http://photos.l33t-d00d.co.uk -- 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] Probably an easy question - blank search fields (PHP & MySQL)
$result = mysql_query("select * from equipment where (category='$category') and (description like '%$description') and (roomloc='$roomloc') and (quantity like '%$quantity') and (serialno like '%$serialno') and (patdue like '%$patdue')",$db); Gary Smith wrote: > Hiya, I'm writing a backend in MySQL with a PHP frontend. One of the PHP > pages searches the database. The user can enter as many or as few fields as > they like. I then search the database using this code: > > $result = mysql_query("select * from equipment where (category='$category') > and (description like '$description') and (roomloc='$roomloc') and > (quantity like '$quantity') and (serialno like '$serialno') and (patdue > like '$patdue')",$db); > > Messy, I know. The category and roomloc are s and therefore are > definite. However, if the user enters nothing for the other fields, they > get given no results. If I set the default value of each field to % in the > page that calls this, then it works fine. > > It's just not what I'd like to do - have the user clear out % from each > field before putting their data in. Is there an easy way to code "if the > field is blank, send %, else send the users entry" or just putting % before > whatever is sent? (this shouldn't mess up what's being entered, surely?) > > Thanks for any help. > -- > Gary Smith > E: [EMAIL PROTECTED] > W: http://www.l33t-d00d.co.uk > Pics: http://photos.l33t-d00d.co.uk > > -- > 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] database/form help needed
You could setup an autoincremented unique integer field in your db table(s), then when you fetch the row from the table use the id in generating your checkbox name. -ib Chris Payne wrote: > Hi there everyone, > > I have a loop which goes through my MySQL database and some PHP code which grabs >results 9 at a time, and that works great. Now, I also have a checkbox called ID for >each of the 9 entries and here is my problem. > > How can I dynamically assign a unique ID for my checkboxes? I am getting my >checkboxes through a loop, and because of that the ID is called id - for all of my >entries, so I can't select multiple as only one entry comes out on the results page. >How can I dynamically create checkboxes with a unique id (Such as id1, id2 etc ...) >so that I can make multiple selections from my DB? > > Thank you all so much - Happy New Year. > > Regards > > Chris Payne > www.planetoxygene.com > -- "Out beyond the ideas of wrong-doing and right-doing there is a field. I'll meet you there." -Rumi *(O)* [EMAIL PROTECTED] *** under construction *** http://centralcoasthealing.net Healing Resources on the Central Coast http://kornsnake.com Internet Development -- 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 - address book
Hi, I'm trying to do a sort of address book where I'd put all information about anybody or any company from which I receive informtation (friend, people from work, hotels, places...) An entry starts with a name, then I can have any type of information. The table I'm using has a lot of fields, but I display via PHP only those that are not empty. I'm now facing a problem many must have already faced. A lot of people work for the same company, and I'd like to have a separate table or storage area to put that data, so that I don't have to write the same company addresse twice, and if that information changes, I won't have to go through ten or twenty people's entries to modify it. So how would I link a company's information to a person's entry? I know it may sound easy or ridiculous a question, but though I know HTML very well I'm still a beginner (learning on my own) et PHP and MySql. So far I have a neat rendering of the database I've created, but I feel I should look further into DB use. Software I'm using: EasyPHP (latest version) PHP 4 MySql PhpMyAdmin on Windows Me Main question, I repeat is : how would I link a company's information to a person's entry? Cheers Sébastien -- 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] database/form help needed
Use Then you'll have an array of the boxes checked with the id as the array key. olinux --- Neil Thomson <[EMAIL PROTECTED]> wrote: > try using the rand function.. > eg... > $rand=rand(1,10); > > > > but that migth get a same number more then once... > my suggestion is this > > $checkboxid="1"; > // Start of the loop > echo ""; > // end of loop > $checkboxid = $checkboxid + 1; > > that should work i think > > havent tested that code. but thats my idea. > > Neil > __ Do You Yahoo!? Send FREE video emails in Yahoo! Mail! http://promo.yahoo.com/videomail/ -- 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/MySql - address book
look at http://www.webmasterbase.com/article/228 -- Best regards, George Nicolae IT Manager ___ X-Playin - Professional Web Design www.x-playin.f2s.com "Sg" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Hi, > > I'm trying to do a sort of address book where I'd put all information about > anybody or any company from which I receive informtation (friend, people > from work, hotels, places...) > > An entry starts with a name, then I can have any type of information. The > table I'm using has a lot of fields, but I display via PHP only those that > are not empty. > > I'm now facing a problem many must have already faced. A lot of people work > for the same company, and I'd like to have a separate table or storage area > to put that data, so that I don't have to write the same company addresse > twice, and if that information changes, I won't have to go through ten or > twenty people's entries to modify it. > > So how would I link a company's information to a person's entry? > > I know it may sound easy or ridiculous a question, but though I know HTML > very well I'm still a beginner (learning on my own) et PHP and MySql. > > So far I have a neat rendering of the database I've created, but I feel I > should look further into DB use. > > Software I'm using: > > EasyPHP (latest version) > PHP 4 > MySql > PhpMyAdmin > > on Windows Me > > Main question, I repeat is : how would I link a company's information to a > person's entry? > > Cheers > > Sébastien > > -- 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_num_rows
Hi everyone, I have a problem with mysql connectivety which is making me nuts. If the query is "select blah, blah from table" (i.e. without where clause) mysql_num_rows returns the right number, but when i put in a query with where clause, although there are rows returned, PHP is giving: "Warning: Supplied argument is not a valid MySQL result resource" error.. Can anyone point me to any direction about this? Thanks. Gurhan -- 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_num_rows
It would help if we could see the actual query. It sounds like the problem is a syntax error in the query itself. At 11:52 AM 1/6/2002, Gurhan Ozen wrote: > Hi everyone, > I have a problem with mysql connectivety which is making me nuts. If the >query is "select blah, blah from table" (i.e. without where clause) >mysql_num_rows returns the right number, but when i put in a query with >where clause, although there are rows returned, PHP is giving: >"Warning: Supplied argument is not a valid MySQL result resource" error.. >Can anyone point me to any direction about this? > Thanks. > >Gurhan > > >-- >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] Sliante, Richard S. Crawford http://www.mossroot.com AIM: Buffalo2K ICQ: 11646404 Y!: rscrawford MSN: [EMAIL PROTECTED] "It is only with the heart that we see rightly; what is essential is invisible to the eye." --Antoine de Saint Exupéry "Push the button, Max!" -- 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_num_rows
I am pretty sure that the query is correct. here is the actual query: $query="select distinct(nodeid), nodename from books where bookid=$bookid"; $result=mysql_query($query); $num_results=mysql_num_rows($result); I have loaded a book into the tabel called "books". I have gave each section a nodeid and each book a bookid. SO i wanted to get number of distinct nodeid's (i.e. sections) in the book so that i could use a for loop to display all of them and an inner for loop to display each page under each section. The funny thing is that if i write the same query without "where bookid=$bookid" then the mysql_num_rows works but with where statement it doesn't. By the way the web hoster i am using has PHP Version 4.0.6 . Thanks. Gurhan -Original Message- From: Richard S. Crawford [mailto:[EMAIL PROTECTED]] Sent: Sunday, January 06, 2002 3:01 PM To: Gurhan Ozen; [EMAIL PROTECTED] Subject: Re: [PHP-DB] mysql_num_rows It would help if we could see the actual query. It sounds like the problem is a syntax error in the query itself. At 11:52 AM 1/6/2002, Gurhan Ozen wrote: > Hi everyone, > I have a problem with mysql connectivety which is making me nuts. If the >query is "select blah, blah from table" (i.e. without where clause) >mysql_num_rows returns the right number, but when i put in a query with >where clause, although there are rows returned, PHP is giving: >"Warning: Supplied argument is not a valid MySQL result resource" error.. >Can anyone point me to any direction about this? > Thanks. > >Gurhan > > >-- >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] Sliante, Richard S. Crawford http://www.mossroot.com AIM: Buffalo2K ICQ: 11646404 Y!: rscrawford MSN: [EMAIL PROTECTED] "It is only with the heart that we see rightly; what is essential is invisible to the eye." --Antoine de Saint Exupéry "Push the button, Max!" -- 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_num_rows
Hm, if the result you want is the number of distinct nodeid values, why not use a query like this: "select count(distinct(nodeid)) as nodecount from books where bookid = $bookid"; Then the number of nodeid's is stored in nodecount. You might also want to look into the GROUP BY clause. That might give you a better handle on what you want to do. At 12:09 PM 1/6/2002, Gurhan Ozen wrote: >I am pretty sure that the query is correct. here is the actual query: > $query="select distinct(nodeid), nodename from books where >bookid=$bookid"; > $result=mysql_query($query); > $num_results=mysql_num_rows($result); > > I have loaded a book into the tabel called "books". I have gave each >section a nodeid and each book a bookid. SO i wanted to get number of >distinct nodeid's (i.e. sections) in the book so that i could use a for loop >to display all of them and an inner for loop to display each page under each >section. > The funny thing is that if i write the same query without "where >bookid=$bookid" then the mysql_num_rows works but with where statement it >doesn't. > By the way the web hoster i am using has PHP Version 4.0.6 . > Thanks. >Gurhan Sliante, Richard S. Crawford http://www.mossroot.com AIM: Buffalo2K ICQ: 11646404 Y!: rscrawford MSN: [EMAIL PROTECTED] "It is only with the heart that we see rightly; what is essential is invisible to the eye." --Antoine de Saint Exupéry "Push the button, Max!" -- 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_num_rows
hmm that's an idea... I stil don't get why mysql_num_rows wouldn't work with WHERE clause but i will try to do a workaround with what you said below. Although it will be a little extra coding I guess I don't have any other choice:) Thank you very much for your help:) Gurhan -Original Message- From: Richard S. Crawford [mailto:[EMAIL PROTECTED]] Sent: Sunday, January 06, 2002 3:34 PM To: Gurhan Ozen; [EMAIL PROTECTED] Subject: RE: [PHP-DB] mysql_num_rows Hm, if the result you want is the number of distinct nodeid values, why not use a query like this: "select count(distinct(nodeid)) as nodecount from books where bookid = $bookid"; Then the number of nodeid's is stored in nodecount. You might also want to look into the GROUP BY clause. That might give you a better handle on what you want to do. At 12:09 PM 1/6/2002, Gurhan Ozen wrote: >I am pretty sure that the query is correct. here is the actual query: > $query="select distinct(nodeid), nodename from books where >bookid=$bookid"; > $result=mysql_query($query); > $num_results=mysql_num_rows($result); > > I have loaded a book into the tabel called "books". I have gave each >section a nodeid and each book a bookid. SO i wanted to get number of >distinct nodeid's (i.e. sections) in the book so that i could use a for loop >to display all of them and an inner for loop to display each page under each >section. > The funny thing is that if i write the same query without "where >bookid=$bookid" then the mysql_num_rows works but with where statement it >doesn't. > By the way the web hoster i am using has PHP Version 4.0.6 . > Thanks. >Gurhan Sliante, Richard S. Crawford http://www.mossroot.com AIM: Buffalo2K ICQ: 11646404 Y!: rscrawford MSN: [EMAIL PROTECTED] "It is only with the heart that we see rightly; what is essential is invisible to the eye." --Antoine de Saint Exupéry "Push the button, Max!" -- 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_num_rows
Gurhan, The first rule with all of these problems is to insert error-checking statements. There are two types: firstly the MySQL function set includes error number and error (msg) text facilities; and secondly the addition of 'debug' echo statements, eg to be absolutely sure what $query looks like before it gets fed to MySQL. The other advice is to copy the $query text into a MySQL command line or an administrative package, eg MySQL-Front, to test if it works in 'native' mode (so then you can work out if the source of the problem is PHP or MySQL code). Regards, =dn - Original Message - From: "Gurhan Ozen" <[EMAIL PROTECTED]> To: "Richard S. Crawford" <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: 06 January 2002 20:42 Subject: RE: [PHP-DB] mysql_num_rows hmm that's an idea... I stil don't get why mysql_num_rows wouldn't work with WHERE clause but i will try to do a workaround with what you said below. Although it will be a little extra coding I guess I don't have any other choice:) Thank you very much for your help:) Gurhan -Original Message- From: Richard S. Crawford [mailto:[EMAIL PROTECTED]] Sent: Sunday, January 06, 2002 3:34 PM To: Gurhan Ozen; [EMAIL PROTECTED] Subject: RE: [PHP-DB] mysql_num_rows Hm, if the result you want is the number of distinct nodeid values, why not use a query like this: "select count(distinct(nodeid)) as nodecount from books where bookid = $bookid"; Then the number of nodeid's is stored in nodecount. You might also want to look into the GROUP BY clause. That might give you a better handle on what you want to do. At 12:09 PM 1/6/2002, Gurhan Ozen wrote: >I am pretty sure that the query is correct. here is the actual query: > $query="select distinct(nodeid), nodename from books where >bookid=$bookid"; > $result=mysql_query($query); > $num_results=mysql_num_rows($result); > > I have loaded a book into the tabel called "books". I have gave each >section a nodeid and each book a bookid. SO i wanted to get number of >distinct nodeid's (i.e. sections) in the book so that i could use a for loop >to display all of them and an inner for loop to display each page under each >section. > The funny thing is that if i write the same query without "where >bookid=$bookid" then the mysql_num_rows works but with where statement it >doesn't. > By the way the web hoster i am using has PHP Version 4.0.6 . > Thanks. >Gurhan Sliante, Richard S. Crawford http://www.mossroot.com AIM: Buffalo2K ICQ: 11646404 Y!: rscrawford MSN: [EMAIL PROTECTED] "It is only with the heart that we see rightly; what is essential is invisible to the eye." --Antoine de Saint Exupéry "Push the button, Max!" -- 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: [PHP] Connect to IBM DB2
This is probably not what you want but I found at http://www.php.net/manual/en/install.configure.php something like that: --with-ibm-db2[=DIR] Include IBM DB2 support. DIR is the DB2 base install directory, defaults to /home/db2inst1/sqllib. Maybe you can make use of it, I don't run IBM DB2. Maciek > -Original Message- > From: Jerry [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, January 02, 2002 2:14 PM > To: [EMAIL PROTECTED]; [EMAIL PROTECTED] > Subject: [PHP] Connect to IBM DB2 > Now, how to connect to a DB2 database server without ODBC ? -- 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] Building a user preference site
Thanks Rich, I am unclear how to merge the login to the preferences. Check out my code for my login. Right below it is the login2.php,login_done.html,admin.php where will I merge the user preferences portion within this script.. Thanks for all your help.. Here is the test url -> http://www.planttel.com/newsite2/login.php Username: Password: login($username, $password); if (!$login) { include("login_error.html"); } else { include("login/html/login_done.html"); } ?> --- is_logged(); if (!$login_check) { include("/home/plantcom/planttel-www/newsite2/login/html/nologin.html"); } else { include("/home/plantcom/planttel-www/newsite2/member/home.php"); } ?> -Original Message- From: Rich Buggy [mailto:[EMAIL PROTECTED]] Sent: Saturday, January 05, 2002 11:13 PM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] Building a user preference site > I am trying to figure out how to setup a user preference system. When the > user successfully > logs in they will go to a page that will display their preferences. I have a > Mysql database that contains all the user info. How do I START developing a > site like this. Thanks, Dan What I find usually works is this. 1. User logs in and a session variable is set indicating who is currently logged in. 2. When the user requests a page, gather together the default settings 3. Look up the users preferences in the MySQL database and merge them in to the default settings (that way you can add additional preference settings later without breaking your code) 4. Display the page using the merged setting. If no one is logged in the skip step 3 so they see the default settings. When the user changes their preferences save the changes to the database. That will allow them to log in from anywhere and retrieve their preferences. Don't trying using cookies to store preferences unless you want the preferences to apply to that browser (rather than user). Anyone using a shared machine will get very annoyed and the preferences won't be portable. Saving preferences in session also won't work because they will only last as long as the session. Loading user preferences in to session variables when the user logs in is ok and you may want to look at that. Rich -- 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_num_rows - update....
I think i narrowed down the problem and know what is wrong, and just solved the problem:). The problem wasn't with mysql or php it was because of my poor i should say object-oriented skill. I will tell why I had this problem so that it might be a good reference for someone else who are likely to get in the same trap:) I wrote a class in PHP which serves as a template to all other pages. It is called "page_layout.inc" and also have another include file (db.inc) which takes care of db connection. So, everypage I have has require("../../page_layout.inc"); and require ("../../db.inc"); lines. Normally, my pages just set title of the page and the content of the page by either giving arguments to SetTitle() and SetContent() functions or overridding DisplayContent() function. So the code pretty much looks like this in every page: For those setting SetTitle and SetContent functions: require ( "../../page_layout.inc"); require ( "../../db.inc" ); $query="select * from $tab where encoding = 0 and articleid=$articleid"; $result=mysql_query($query); $row = mysql_fetch_array($result); $page = new page_layout(); $page -> SetTitle($row[title]); $page -> SetContent($row[content]); $page -> DisplayPage(); And For those overridding DisplayContent() function: require ("../../page_layout.inc"); require ("../../db.inc"); class testpage extends page_layout { function DisplayContent() { . . . } // End of DisplayContent() function } //end of class testpage $page= new testpage(); $title= "TITLE"; $page -> SetTitle($title); $page -> DisplayPage(); Ok, the problem i was having with mysql_num_rows have occured in the DisplayContent() function in the new class. Here are some of the things I have tried: $query="select distinct(nodeid), nodename from books"; $result=mysql_query($query); $num_results = mysql_num_rows($result); This has worked ok. It didn't have a where clause and it did work. $query="select distinct(nodeid), nodename from books where bookid=1002"; $result=mysql_query($query); $num_results = mysql_num_rows($result); This has worked fine as well. When i hard coded the bookid it works. $query="select distinct(nodeid), nodename from books where bookid=$bookid"; $result=mysql_query($query); $num_results = mysql_num_rows($result); This didn't work because I haven't paid enough attention to the object-oriented methodology. I failed because when i pass the variable bookid as an argument to the pagename (i.e. show_book.php?bookid=1001), it is not passing the value inside new the class. So I had to find a way to pass that vaue into the class so that the new overridding DisplayContent() function could use it. There are a couple ways to do this, and I have used a set function. I have created a variable in the new class called $booknum. Then I wrote a function to set it called SetBooknum. It took an argument and set the variable $booknum to the argument. then Inside the DisplayContent() function I have used a variable called $booknumber to correspond to the bookid column in the table. So it looked like this: class testpage extends page_layout { var $booknum; function SetBooknum($num) { $this -> booknum = $num; } function DisplayContent() { $booknumber= $this -> booknum; $query="select distinct(nodeid), nodename from books where bookid=$booknumber"; . . . } //end of function DisplayContent() } //end of class testpage And then after creating the instance of the new class I have just used SetBooknum() function to pass the bookid variable into the new class and use it as the search criteria in the query. Thanks to all who tried to help me. Gurhan -- 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] help on mulit query
Hi I have three tables set out below: xp_artist: artist_id , artist _name xp_sings: artist_id , songs_id xp_songs: songs_id , song_name , lyrics I can not figure out how to query and return the results for a query like: "select song_name FROM xp_artist,xp_sings,xp_songs WHERE xp_artist.artist_id = xp_sings.artist_id AND xp_sings.song_id = xp_songs.songs_id AND artist_name LIKE 'b%'";
Re: [PHP-DB] help on mulit query
You seem to be doing it fine as far as I can see, except for "song_id" which should be "songs_id" in the query... Bogdan Barry Rumsey wrote: > Hi > I have three tables set out below: > > xp_artist: artist_id , artist _name > xp_sings: artist_id , songs_id > xp_songs: songs_id , song_name , lyrics > > I can not figure out how to query and return the results for a query like: > > "select song_name FROM xp_artist,xp_sings,xp_songs WHERE xp_artist.artist_id = >xp_sings.artist_id AND xp_sings.song_id = xp_songs.songs_id AND artist_name LIKE >'b%'"; -- 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] help on mulit query
I did not see that ( I must be blind hehe ). One other question , I have the lyrics also stored in the database, how can I create a link so that when the query is returned they can click on song name and the lyrics will be viewed? - Original Message - From: "Bogdan Stancescu" <[EMAIL PROTECTED]> To: "Barry Rumsey" <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Monday, January 07, 2002 1:51 PM Subject: Re: [PHP-DB] help on mulit query > You seem to be doing it fine as far as I can see, except for "song_id" which should be "songs_id" in the query... > > Bogdan > > Barry Rumsey wrote: > > > Hi > > I have three tables set out below: > > > > xp_artist: artist_id , artist _name > > xp_sings: artist_id , songs_id > > xp_songs: songs_id , song_name , lyrics > > > > I can not figure out how to query and return the results for a query like: > > > > "select song_name FROM xp_artist,xp_sings,xp_songs WHERE xp_artist.artist_id = xp_sings.artist_id AND xp_sings.song_id = xp_songs.songs_id AND artist_name LIKE 'b%'"; > > > -- > 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] help on mulit query
Your query looks fine, except that it should be xp_sings.songs_id. What you are trying to resolve is a many to many relationship where many artists can sing the same song, hence you have created the table xp_sings. This is also known as a pivot table. What problem are you having? Have you echoed your SQL statement? Tried it at the console? Miles Thompson At 01:40 PM 1/7/2002 +1300, Barry Rumsey wrote: >Hi >I have three tables set out below: > >xp_artist: artist_id , artist _name >xp_sings: artist_id , songs_id >xp_songs: songs_id , song_name , lyrics > >I can not figure out how to query and return the results for a query like: > >"select song_name FROM xp_artist,xp_sings,xp_songs WHERE >xp_artist.artist_id = xp_sings.artist_id AND xp_sings.song_id = >xp_songs.songs_id AND artist_name LIKE 'b%'"; -- 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] help on mulit query
Barry, Execute your query, fetching song_id as well as song_name, returning the result handle to $result (or any name you're comfortable with) and present your song titles like so .. while ($myrow = mysql_fetch_array($result)) { printf("%s \n", $LYRIC_URL, $myrow["songs_id"], $myrow["song_name"]); } This assumes that songs_id is the key for the lyrics in the lyrics table. Presenting this neatly in a table is left up to you! Have fun. Miles Thompson At 02:13 PM 1/7/2002 +1300, Barry Rumsey wrote: >I did not see that ( I must be blind hehe ). One other question , I have the >lyrics also stored in the database, how can I create a link so that when the >query is returned they can click on song name and the lyrics will be viewed? >- Original Message - >From: "Bogdan Stancescu" <[EMAIL PROTECTED]> >To: "Barry Rumsey" <[EMAIL PROTECTED]> >Cc: <[EMAIL PROTECTED]> >Sent: Monday, January 07, 2002 1:51 PM >Subject: Re: [PHP-DB] help on mulit query > > > > You seem to be doing it fine as far as I can see, except for "song_id" >which should be "songs_id" in the query... > > > > Bogdan > > > > Barry Rumsey wrote: > > > > > Hi > > > I have three tables set out below: > > > > > > xp_artist: artist_id , artist _name > > > xp_sings: artist_id , songs_id > > > xp_songs: songs_id , song_name , lyrics > > > > > > I can not figure out how to query and return the results for a query >like: > > > > > > "select song_name FROM xp_artist,xp_sings,xp_songs WHERE >xp_artist.artist_id = xp_sings.artist_id AND xp_sings.song_id = >xp_songs.songs_id AND artist_name LIKE 'b%'"; > > -- 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 script connect to mySQL problem
Hi all, I'm a newbie to PHP and mySQL and I'm currently running PHP+mySQL on my Linux 2.2.16 kernel. Every time I try to connect to mySQL from a php page, I get this error message: ERROR 2002: Can't connect to local MySQL server through socket '/var/lib/mysql/mys ql.sock' (111) What does that mean and how do I go about solving it? Thanks in advance for your directions and have a great new year. Best regards, -- 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 script connect to mySQL problem
Is mysqld running? Username? Password? At 08:30 PM 1/6/2002 -0500, Vu Hoang Huynh wrote: >Hi all, > >I'm a newbie to PHP and mySQL and I'm currently running PHP+mySQL on my >Linux 2.2.16 kernel. Every time I try to connect to mySQL from a php page, I >get this error message: > >ERROR 2002: Can't connect to local MySQL server through socket >'/var/lib/mysql/mys >ql.sock' (111) > >What does that mean and how do I go about solving it? > >Thanks in advance for your directions and have a great new year. > >Best regards, > > > > >-- >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 script connect to mySQL problem
Yes, mysqld was running. Username and password were provided via this function call $db = mysql_connect("localhost","username","password"); I have to same problem when trying to connect to mysql server whenever I use any user other than root. So basically whenever I try to run "mysql" using root account then everything is fine but otherwise I'll get the same error message. Thanks to your reply. "Miles Thompson" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > Is mysqld running? > Username? > Password? > > > At 08:30 PM 1/6/2002 -0500, Vu Hoang Huynh wrote: > >Hi all, > > > >I'm a newbie to PHP and mySQL and I'm currently running PHP+mySQL on my > >Linux 2.2.16 kernel. Every time I try to connect to mySQL from a php page, I > >get this error message: > > > >ERROR 2002: Can't connect to local MySQL server through socket > >'/var/lib/mysql/mys > >ql.sock' (111) > > > >What does that mean and how do I go about solving it? > > > >Thanks in advance for your directions and have a great new year. > > > >Best regards, > > > > > > > > > >-- > >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] version conflict
Dear List, I was installed mysql-3.23.47 in my Linux box with PHP. I could shown version correctly with mysql command line or any windows client tools. It still shown in phpinfo with version 3.23.37 (old version before upgrade). What wrong? Did somone know about Zend Optimizer for php 4.1.1? I have problem with latest Zend Optimizer (Zend say it could run with php-4.1.0) because it did not work (see in phpinfo page). SF -- 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] help on mulit query
Just echo a link of the form Click for lyrics and use the incoming song_id in lyrics.php to get it from the database. Bogdan Barry Rumsey wrote: > I did not see that ( I must be blind hehe ). One other question , I have the > lyrics also stored in the database, how can I create a link so that when the > query is returned they can click on song name and the lyrics will be viewed? -- 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] Database Connection Properties
I'm new to PHP, and I have a question regarding the storage of connection properties to the database. I have a site on a shared (Unix) server. I'm adding some PHP to a section which will be database-driven. I'm concerned about storing the username and password to my database (some of the data contained within this database is sensitive) in my PHP files which are readable by the webserver, and thus by anyone on the system. Is there a recommended strategy for keeping my database username and password in a secure location so that no other user can access the files? Any help would be greatly appreciated. Thanks very much, Patrick ---| patrick gibson |---+ email: email @ patrickg.com url: http://patrickgibson.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] I think i saw this somewhere....
Hi All I think i saw a php script somewhere on my web travels, that allows you to include sub domain reg to your web site. it allowed you to offer http://yourname.choiceofdomainname.com so the visitor can have thier name in front of a domain name reged to our webspace. If i remeber right, it had a mysql db in the background. Is this kind of thing available or did i dream it. As always any pointers of advice is welcome Dave C The two rules for success are: 1. Never tell them everything you know. -- 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] I think i saw this somewhere....
*being a smart-ass from your email signature* sure... you can download the script from .. just kidding :) the best way to do this as far as I know would be to have a PHP script which had write-access to your apache conf files, which then just added in the required lines and restarted apache. there is no real need for a mysql database, since the same script could read the existing conf file to find out if a subdomain is available etc etc etc. i know this isn't what you are after, but it might be useful if you get lost and have to write your own :) useful functions file() fopen() fwrite() (? something like that) system() (or ') hope something there helps :) /beau // -Original Message- // From: Dave Carrera [mailto:[EMAIL PROTECTED]] // Sent: Monday, 7 January 2002 2:54 PM // To: [EMAIL PROTECTED] // Subject: [PHP-DB] I think i saw this somewhere // // // Hi All // // I think i saw a php script somewhere on my web travels, that // allows you to // include // sub domain reg to your web site. // // it allowed you to offer // // http://yourname.choiceofdomainname.com // // so the visitor can have thier name in front of a domain name // reged to our // webspace. // // If i remeber right, it had a mysql db in the background. // // Is this kind of thing available or did i dream it. // // As always any pointers of advice is welcome // // Dave C // // The two rules for success are: // 1. Never tell them everything you know. // // // // -- // 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: I think i saw this somewhere....
Hello, Dave Carrera wrote: > > Hi All > > I think i saw a php script somewhere on my web travels, that allows you to > include > sub domain reg to your web site. > > it allowed you to offer > > http://yourname.choiceofdomainname.com > > so the visitor can have thier name in front of a domain name reged to our > webspace. > > If i remeber right, it had a mysql db in the background. > > Is this kind of thing available or did i dream it. That is plain easy and has nothing to do with PHP. Just add a *.choiceofdomainname.com entry to your DNS records pointing to the same IP as www.choiceofdomainname.com . Then also add virtual domain entries for www and * to Apache configuration. In your site, you can always check each domain is being accessed by checking the environment variables. 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]