Re: [PHP-DB] Multiple Count's in one Select.
- Original Message - From: Chris [EMAIL PROTECTED] To: Ed [EMAIL PROTECTED] Cc: php-db@lists.php.net Sent: Friday, January 05, 2007 5:23 AM Subject: Re: [PHP-DB] Multiple Count's in one Select. [ please don't top-post, makes it hard to follow ] Ed wrote: As this is a new db i've not done any indexing. There's only 4 rows in the table. SELECT DISTINCT u.user_id, u.username, t.user_id, t.jobtype, (SELECT COUNT(jobtype) FROM taskinput) AS 'COUNT', (SELECT COUNT(jobtype) FROM taskinput WHERE t.jobtype = 'Navision') AS 'Navision', (SELECT COUNT(jobtype) FROM taskinput WHERE t.jobtype = 'Abuse') AS 'Abuse', (SELECT COUNT(jobtype) FROM taskinput WHERE t.jobtype = 'Tickets') AS 'Tickets', (SELECT COUNT(jobtype) FROM taskinput) AS 'MegaTotals' FROM users u, taskinput t WHERE t.user_id = u.user_id GROUP BY u.user_id, t.user_id; +-+---+-+-+---+--+---+-++ | user_id | username | user_id | jobtype | COUNT | Navision | Abuse | Tickets | MegaTotals | +-+---+-+-+---+--+---+-++ | 1 | edd | 1 | Tickets| 4 |0 | 0 | 0 | 4 | | 10 | administrator | 10 | Tickets | 4 |0 | 0 | 4 | 4 | +-+---+-+-+---+--+---+-++ 2 rows in set (0.00 sec) Notice how i've removed the WHERE t.user_id = u.user_id from each SELECT count? it's flown through but seems to be putting all the same results in each count. It takes far too long to get any kind of result where adding the extra WHERE t.user_id = u.user_id AND t.jobtype = 'Tickets' It's got me stumped, but then i've not slept in nearly 24 hours. Can you provide table info or a small database dump ? Probably best to send off list if that's ok. You have a complicated query so it'll be easier seeing the table definitions and having some data to work with ;) - Original Message - From: Chris [EMAIL PROTECTED] To: Ed [EMAIL PROTECTED] Cc: php-db@lists.php.net Sent: Friday, January 05, 2007 5:03 AM Subject: Re: [PHP-DB] Multiple Count's in one Select. Ed wrote: Hi, I've been expermenting with displaying stats for our intranet and I'm looking at making it more robust so it can display stats better. I've come up with the most ugly! long winded SQL statement You could imagine. SELECT DISTINCT u.*, t.*, (SELECT COUNT(jobtype) FROM taskinput WHERE t.user_id = u.user_id ) AS 'COUNT', (SELECT COUNT(jobtype) FROM taskinput WHERE t.user_id = u.user_id AND t.jobtype = 'Navision') AS 'Navision', (SELECT COUNT(jobtype) FROM taskinput WHERE t.user_id = u.user_id AND t.jobtype = 'Abuse'') AS 'Abuse', (SELECT COUNT(jobtype) FROM taskinput WHERE t.user_id = u.user_id AND t.jobtype = 'Tickets') AS 'Tickets', (SELECT COUNT(jobtype) FROM taskinput WHERE t.user_id = u.user_id) AS 'MegaTotals' FROM users u, taskinput t WHERE t.user_id = u.user_id GROUP BY u.user_id, t.user_id ORDER BY COUNT DESC I've never down anything so long in all the time i've been playing and it's causing my CPU to go crazy although i'm only using 126mb of my 2.5GB of RAM. The query in question is fine if I strip out the WHERE t.user_id = u.user_id from each SELECT COUNT it goes through in less than a second in fact but doesnt display the results properly it gives every user the same listings. Surely there must be a more efficent way of doing this? but i've not been able to find one that executes quickly. What indexes do you have? Do you have one on taskinput(user_id) and users(user_id) ? -- Postgresql php tutorials http://www.designmagick.com/ -- Postgresql php tutorials http://www.designmagick.com/ Sent a DB dump to you off list :) Thanks again. Ed -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Multiple Count's in one Select.
- Original Message - From: OKi98 [EMAIL PROTECTED] To: php-db@lists.php.net Sent: Friday, January 05, 2007 1:19 PM Subject: Re: [PHP-DB] Multiple Count's in one Select. Ed wrote: SELECT DISTINCT u.*, t.*, (SELECT COUNT(jobtype) FROM taskinput WHERE t.user_id = u.user_id ) AS 'COUNT', (SELECT COUNT(jobtype) FROM taskinput WHERE t.user_id = u.user_id AND t.jobtype = 'Navision') AS 'Navision', (SELECT COUNT(jobtype) FROM taskinput WHERE t.user_id = u.user_id AND t.jobtype = 'Abuse'') AS 'Abuse', (SELECT COUNT(jobtype) FROM taskinput WHERE t.user_id = u.user_id AND t.jobtype = 'Tickets') AS 'Tickets', (SELECT COUNT(jobtype) FROM taskinput WHERE t.user_id = u.user_id) AS 'MegaTotals' FROM users u, taskinput t WHERE t.user_id = u.user_id GROUP BY u.user_id, t.user_id ORDER BY COUNT DESC I quess you are wrongly using aliases - try this and let me know: SELECT DISTINCT u.*, t.*, (SELECT COUNT(jobtype) FROM taskinput WHERE user_id=u.user_id) AS 'COUNT', (SELECT COUNT(jobtype) FROM taskinput WHERE user_id=u.user_id AND jobtype = 'Navision') AS 'Navision', (SELECT COUNT(jobtype) FROM taskinput WHERE user_id=u.user_id AND jobtype = 'Abuse'') AS 'Abuse', (SELECT COUNT(jobtype) FROM taskinput WHERE user_id=u.user_id AND jobtype = 'Tickets') AS 'Tickets', (SELECT COUNT(jobtype) FROM taskinput WHERE user_id=u.user_id) AS 'MegaTotals' FROM users u, taskinput t WHERE t.user_id = u.user_id GROUP BY u.user_id, t.user_id ORDER BY COUNT DESC OKi98 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Thank you very much! that seemed todo the trick nicely :) Thank you everyone who helped you've been very helpful. Ed -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Multiple Count's in one Select.
Hi, I've been expermenting with displaying stats for our intranet and I'm looking at making it more robust so it can display stats better. I've come up with the most ugly! long winded SQL statement You could imagine. SELECT DISTINCT u.*, t.*, (SELECT COUNT(jobtype) FROM taskinput WHERE t.user_id = u.user_id ) AS 'COUNT', (SELECT COUNT(jobtype) FROM taskinput WHERE t.user_id = u.user_id AND t.jobtype = 'Navision') AS 'Navision', (SELECT COUNT(jobtype) FROM taskinput WHERE t.user_id = u.user_id AND t.jobtype = 'Abuse'') AS 'Abuse', (SELECT COUNT(jobtype) FROM taskinput WHERE t.user_id = u.user_id AND t.jobtype = 'Tickets') AS 'Tickets', (SELECT COUNT(jobtype) FROM taskinput WHERE t.user_id = u.user_id) AS 'MegaTotals' FROM users u, taskinput t WHERE t.user_id = u.user_id GROUP BY u.user_id, t.user_id ORDER BY COUNT DESC I've never down anything so long in all the time i've been playing and it's causing my CPU to go crazy although i'm only using 126mb of my 2.5GB of RAM. The query in question is fine if I strip out the WHERE t.user_id = u.user_id from each SELECT COUNT it goes through in less than a second in fact but doesnt display the results properly it gives every user the same listings. Surely there must be a more efficent way of doing this? but i've not been able to find one that executes quickly. Any help of stripping the code down too it's bare minimum and getting the results quickly would be welcome :) Thanks Ed -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Multiple Count's in one Select.
As this is a new db i've not done any indexing. There's only 4 rows in the table. SELECT DISTINCT u.user_id, u.username, t.user_id, t.jobtype, (SELECT COUNT(jobtype) FROM taskinput) AS 'COUNT', (SELECT COUNT(jobtype) FROM taskinput WHERE t.jobtype = 'Navision') AS 'Navision', (SELECT COUNT(jobtype) FROM taskinput WHERE t.jobtype = 'Abuse') AS 'Abuse', (SELECT COUNT(jobtype) FROM taskinput WHERE t.jobtype = 'Tickets') AS 'Tickets', (SELECT COUNT(jobtype) FROM taskinput) AS 'MegaTotals' FROM users u, taskinput t WHERE t.user_id = u.user_id GROUP BY u.user_id, t.user_id; +-+---+-+-+---+--+---+-++ | user_id | username | user_id | jobtype | COUNT | Navision | Abuse | Tickets | MegaTotals | +-+---+-+-+---+--+---+-++ | 1 | edd | 1 | Tickets| 4 |0 | 0 | 0 | 4 | | 10 | administrator | 10 | Tickets | 4 |0 | 0 | 4 | 4 | +-+---+-+-+---+--+---+-++ 2 rows in set (0.00 sec) Notice how i've removed the WHERE t.user_id = u.user_id from each SELECT count? it's flown through but seems to be putting all the same results in each count. It takes far too long to get any kind of result where adding the extra WHERE t.user_id = u.user_id AND t.jobtype = 'Tickets' It's got me stumped, but then i've not slept in nearly 24 hours. Thanks for your help so far :-) - Original Message - From: Chris [EMAIL PROTECTED] To: Ed [EMAIL PROTECTED] Cc: php-db@lists.php.net Sent: Friday, January 05, 2007 5:03 AM Subject: Re: [PHP-DB] Multiple Count's in one Select. Ed wrote: Hi, I've been expermenting with displaying stats for our intranet and I'm looking at making it more robust so it can display stats better. I've come up with the most ugly! long winded SQL statement You could imagine. SELECT DISTINCT u.*, t.*, (SELECT COUNT(jobtype) FROM taskinput WHERE t.user_id = u.user_id ) AS 'COUNT', (SELECT COUNT(jobtype) FROM taskinput WHERE t.user_id = u.user_id AND t.jobtype = 'Navision') AS 'Navision', (SELECT COUNT(jobtype) FROM taskinput WHERE t.user_id = u.user_id AND t.jobtype = 'Abuse'') AS 'Abuse', (SELECT COUNT(jobtype) FROM taskinput WHERE t.user_id = u.user_id AND t.jobtype = 'Tickets') AS 'Tickets', (SELECT COUNT(jobtype) FROM taskinput WHERE t.user_id = u.user_id) AS 'MegaTotals' FROM users u, taskinput t WHERE t.user_id = u.user_id GROUP BY u.user_id, t.user_id ORDER BY COUNT DESC I've never down anything so long in all the time i've been playing and it's causing my CPU to go crazy although i'm only using 126mb of my 2.5GB of RAM. The query in question is fine if I strip out the WHERE t.user_id = u.user_id from each SELECT COUNT it goes through in less than a second in fact but doesnt display the results properly it gives every user the same listings. Surely there must be a more efficent way of doing this? but i've not been able to find one that executes quickly. What indexes do you have? Do you have one on taskinput(user_id) and users(user_id) ? -- Postgresql php tutorials http://www.designmagick.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Add or Subtract
I've been considering doing a little project for my community site which allow people to sell and buy players ... They would have a limit of 2,000,000 upon sign up .. However i'm not sure how i'd update this figure Say player sells for example Alan Shearer for £300,000 he'd then have 2,300,000 how would i make it add to whats in the db already? same goes for if he was sold and it went down to 1,700,000. Ed -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] select text from a text file
Hi, Thanks for answering the question. I'm going to make it write to a database rather than text file after searching google and coming accross common problems with text files. I've now just got to figure out how to mark the message as read in the database so it does not re-appear next time the user clicks update. I'm going to build a function that will put the message in the correct table using an if clause, is that the best method? Ed - Original Message - From: Andrew Kreps [EMAIL PROTECTED] To: Ed [EMAIL PROTECTED]; php-db@lists.php.net Sent: Thursday, January 06, 2005 6:55 PM Subject: Re: [PHP-DB] select text from a text file On Wed, 5 Jan 2005 11:58:59 -, Ed [EMAIL PROTECTED] wrote: Happy new year folks! The titlemight make this seem like an easy to answer question However here's the complicated bit (well for me anyway). In my text file that is written to by the users in a chatroom it looks like this: nickname||color||what the user is saying||user how can i make it so that if they have a private message when they press update it pulls the message from the text file and displays it in the frame but also deletes the text? You should be using a database for this, it makes things so much easier. That being said, here's one way to go about the text file version: Open the file, read through it line by line. As you read it, push the lines into an array. If you find a private message for the user, store that in a variable, and do not push it into the array. Finish reading the file. If there's a private message, you've got it in a variable, and you can overwrite the private message file with the array you've stored, which is all of the current private messages minus the one you're about to display. Please note, this does not scale at all, especially in the fast-paced world of chat rooms. You will likely end up with file locking problems if you proceed with the flat-file method. Also, how can i make it so that if in a drop down menu they select the word everybody it goes to a file called messages.txt and if they select user or user2 or user3 from the list it writes to private.txt is this at all possible? user and user2 etc arent hardcoded it's pulling the names from a list of online users. Are you talking about appending messages to a text file? In that case, you can have the dropdown submit with the message, and in the PHP code have a case for 'everybody' where it writes to messages.txt, and if it's not 'everybody', write it to private.txt with the username that was selected from the dropdown as part of the row. Does that answer your question? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] select text from a text file
Hi, The timestamp idea is an intresting idea and i'll give that method some thought. I only want it to pull one private message at a time out of the private message field so it might start getting very messy doing that method - but it certainly does make it worth considering. Ed - Original Message - From: Jochem Maas [EMAIL PROTECTED] To: Ed [EMAIL PROTECTED] Cc: php-db@lists.php.net Sent: Friday, January 07, 2005 11:37 AM Subject: Re: [PHP-DB] select text from a text file Ed wrote: Hi, Thanks for answering the question. I'm going to make it write to a database rather than text file after searching google and coming accross common problems with text files. I've now just got to figure out how to mark the message as read in the database so it does not re-appear next time the user clicks update. TIMESTAMP? you can save in the session when a use last grabbed messages (clicked update) and only return newer messages (i.e. message have a 'created' timestamp) then update the timestamp in the session. there is a window in which it is possible to have a request inserts a new message in between another request's selecting of all new messages and updating the session timestamp value (in such cases the person at the client end of the second request will never see the new message insert in the first request) - to handle that you have to implement some kind of locking mechanism. good luck is all can say. (PHP implements a 'share nothing' architecture - not, perse, the easiest or most efficient type of system to build realtime multi-user environments in - AFAICT) I'm going to build a function that will put the message in the correct table using an if clause, is that the best method? your the best judge of that - heh if it works that's the main thing - making it work fast that's something to look at later... and then there is the issue of writing code that neat, tidy, well commented and readable 6 months down the line. Ed - Original Message - From: Andrew Kreps [EMAIL PROTECTED] To: Ed [EMAIL PROTECTED]; php-db@lists.php.net Sent: Thursday, January 06, 2005 6:55 PM Subject: Re: [PHP-DB] select text from a text file On Wed, 5 Jan 2005 11:58:59 -, Ed [EMAIL PROTECTED] wrote: Happy new year folks! The titlemight make this seem like an easy to answer question However here's the complicated bit (well for me anyway). In my text file that is written to by the users in a chatroom it looks like this: nickname||color||what the user is saying||user how can i make it so that if they have a private message when they press update it pulls the message from the text file and displays it in the frame but also deletes the text? You should be using a database for this, it makes things so much easier. That being said, here's one way to go about the text file version: Open the file, read through it line by line. As you read it, push the lines into an array. If you find a private message for the user, store that in a variable, and do not push it into the array. Finish reading the file. If there's a private message, you've got it in a variable, and you can overwrite the private message file with the array you've stored, which is all of the current private messages minus the one you're about to display. Please note, this does not scale at all, especially in the fast-paced world of chat rooms. You will likely end up with file locking problems if you proceed with the flat-file method. Also, how can i make it so that if in a drop down menu they select the word everybody it goes to a file called messages.txt and if they select user or user2 or user3 from the list it writes to private.txt is this at all possible? user and user2 etc arent hardcoded it's pulling the names from a list of online users. Are you talking about appending messages to a text file? In that case, you can have the dropdown submit with the message, and in the PHP code have a case for 'everybody' where it writes to messages.txt, and if it's not 'everybody', write it to private.txt with the username that was selected from the dropdown as part of the row. Does that answer your question? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] select text from a text file
Hi, I've been looking at ways todo this, and as yet haven't figured out howto pull something from the database plus at the sametime update the record, can someone tell me how this is done or where i could learn? i've looked all over phpbuilder and a few other php forums but can't seem to find the answer. Ed - Original Message - From: Bastien Koert [EMAIL PROTECTED] To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Cc: php-db@lists.php.net Sent: Friday, January 07, 2005 2:06 PM Subject: Re: [PHP-DB] select text from a text file simple, add a 'read flag' column to the table, when the record is viewed, activate this flag (say 0 for unread and 1 for read) (Note: read is a mysql keyword don't use that for a column name) and then only show the ones unread bastien From: Ed [EMAIL PROTECTED] To: Andrew Kreps [EMAIL PROTECTED] CC: php-db@lists.php.net Subject: Re: [PHP-DB] select text from a text file Date: Fri, 7 Jan 2005 08:58:18 - Hi, Thanks for answering the question. I'm going to make it write to a database rather than text file after searching google and coming accross common problems with text files. I've now just got to figure out how to mark the message as read in the database so it does not re-appear next time the user clicks update. I'm going to build a function that will put the message in the correct table using an if clause, is that the best method? Ed - Original Message - From: Andrew Kreps [EMAIL PROTECTED] To: Ed [EMAIL PROTECTED]; php-db@lists.php.net Sent: Thursday, January 06, 2005 6:55 PM Subject: Re: [PHP-DB] select text from a text file On Wed, 5 Jan 2005 11:58:59 -, Ed [EMAIL PROTECTED] wrote: Happy new year folks! The titlemight make this seem like an easy to answer question However here's the complicated bit (well for me anyway). In my text file that is written to by the users in a chatroom it looks like this: nickname||color||what the user is saying||user how can i make it so that if they have a private message when they press update it pulls the message from the text file and displays it in the frame but also deletes the text? You should be using a database for this, it makes things so much easier. That being said, here's one way to go about the text file version: Open the file, read through it line by line. As you read it, push the lines into an array. If you find a private message for the user, store that in a variable, and do not push it into the array. Finish reading the file. If there's a private message, you've got it in a variable, and you can overwrite the private message file with the array you've stored, which is all of the current private messages minus the one you're about to display. Please note, this does not scale at all, especially in the fast-paced world of chat rooms. You will likely end up with file locking problems if you proceed with the flat-file method. Also, how can i make it so that if in a drop down menu they select the word everybody it goes to a file called messages.txt and if they select user or user2 or user3 from the list it writes to private.txt is this at all possible? user and user2 etc arent hardcoded it's pulling the names from a list of online users. Are you talking about appending messages to a text file? In that case, you can have the dropdown submit with the message, and in the PHP code have a case for 'everybody' where it writes to messages.txt, and if it's not 'everybody', write it to private.txt with the username that was selected from the dropdown as part of the row. Does that answer your question? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] select text from a text file
Happy new year folks! The titlemight make this seem like an easy to answer question However here's the complicated bit (well for me anyway). In my text file that is written to by the users in a chatroom it looks like this: nickname||color||what the user is saying||user how can i make it so that if they have a private message when they press update it pulls the message from the text file and displays it in the frame but also deletes the text? Also, how can i make it so that if in a drop down menu they select the word everybody it goes to a file called messages.txt and if they select user or user2 or user3 from the list it writes to private.txt is this at all possible? user and user2 etc arent hardcoded it's pulling the names from a list of online users.
[PHP-DB] I'm less experienced please be gentle :)
Can anyone tell me whats wrong with the below code? it doesnt execute. $ip=$_SERVER[REMOTE_ADDR]; $banned=SELECT * FROM banned WHERE ip='$ip'; if(@mysql_num_rows(mysql_query($banned)) 0) { echo You have been Banned.; }else{ echo $ip; }
RE: [PHP-DB] Question: Copy and paste text into mysql text column
I have a textarea field that will allow users to copy and paste text into , it might be plain text, or it might come out of word. I'm wondering what type of validations I should perform on this field ? Any suggestions / ideas ? Hi Stuart, Check out the strip_tags and mysql_escape_string commands. They allow you to filter misc. code that might be imbedded in the data and also prepare the data for insertion into the database (if you're going to store it). Ed Lazor, President http://RPGStore.com Up to 50% off. Over 20,000 items in stock -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Rand()
select id, fname, lname, RAND() as temp from clients where featured=1 order by temp -Original Message- I have the following query: Select id, fname, lname from clients where featured=1 order by RAND() At any time, there should only be three clients where featured =1. Problem is I have run this query several times yet it always returns them in the same order. Not sure it makes a difference but the primary key is on the id column. What am I doing wrong? Thanks! -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Rand()
Hrm. Dunno then. I just manually tested it in MySQL and both approaches worked. Are you able to test directly in MySQL? Might have to go to the mysql list for this. -Ed -Original Message- Yeah, I had tried that earlier but it doesn't work. It does generate a new value for temp each time but they are still in the same order as the first one always has a lower temp value On Thu, 7 Oct 2004 06:40:23 -0700, Ed Lazor [EMAIL PROTECTED] wrote: select id, fname, lname, RAND() as temp from clients where featured=1 order by temp -Original Message- I have the following query: Select id, fname, lname from clients where featured=1 order by RAND() At any time, there should only be three clients where featured =1. Problem is I have run this query several times yet it always returns them in the same order. Not sure it makes a difference but the primary key is on the id column. What am I doing wrong? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Dynamic pull down menus with PHP/Mysql
-Original Message- This may be a more javascript related topic, but it's also php/mysql. Apologies in advance if this is too far off topic. I'm trying to pull data from MySQL using PHP to sort the results into a form with a pull down menu. That works fine; I can do that. But I have a second pull down menu whose items need to display based on the item chosen from the first pull down menu. I can do two lists seperately, but I need the second pull down menu to be a result of the first, and I can't figure a way to do it in PHP without reloading the page, which I don't really want to do. Is this a javascript-dependent function, in that a js will have to make the call to the database via some sort of scripted php/mysql request? I really like to avoid javascript if possible, but I'm unsure there's an alternative. You're describing what I think is called Dynamic Options. Doing a Google for javascript dynamic option or javascript dynamic select will pull-up a few examples. Most of these solutions will expect you to load all data into javascript arrays. In other words, you don't have to reload the page, because all of the data is already present. This approach doesn't work well when dealing with large amounts of data. If you're running into this, use javascript's window.opener feature. It allows you to spawn a second window that retrieves data and sends it to the first window. -Ed -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Addslashes / DB Sort
PHP / MySQL I'm using PHP to retrieve user input and store it in MySQL. PHP's addslashes function is used on data going into the database and PHP's stripslashes function is being used on data coming from the database. This is allowing me to store and retrieve data with no problems, but it's causing problems when trying to sort data. In particular, data with double or single quotes is getting escaped, which changes it's position in the sort. For example, without using addslashes, I can sort by Title and end up with the following results: 'Pizza' For Techies Drinking Beer The OOP Way The World According To Linus But. if I use addslashes and try to sort by Title, I end up with: Drinking Beer The OOP Way The World According To Linus \'Pizza\' For Techies Is there a way to account for this? Thanks, Ed
RE: [PHP-DB] Addslashes / DB Sort
Use the more specific mysql_escape_string() (or friend) instead. You're not supposed to use stripslashes() on data coming from the database Kk, thanks Jason =) -Ed -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Using PHP to generate SQL statement
-Original Message- Seems to me we've just answered a very similar question to this (and I'd be surprised it there weren't several relevant threads in the list archives). Nonetheless: I was so tired last night that I don't even remember if I checked the archives first - my bad. Thanks for helping Mike. And thanks to Manuel and Eduardo. I'll explore these options and go from there. -Ed -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Which Database Abstraction Layer ?
Has any performance testing been done between ADOdb and PEARdb? -Original Message- PEARdb does seem to have caught up, but lots of third party applications are already available that use ADOdb or have moved to it (or are moving) in later updates. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Dates - adding to unix 86400 seconds not equal nextday
Quoting ioannes [EMAIL PROTECTED]: The answer seems to be DATE_ADD but I haven't got it to work yet...asking the MySQL people. Check your version of MySQL... I think that's a newer function. -Ed This message was sent using IMP, the Internet Messaging Program. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] SQLite security
Shared hosting vulnerabilities have nothing to do with SQLite security. phpMyAdmin seems to be a popular choice for MySQL admin and I reckon there must be a few people who use it in shared hosting situations. Most of the shared hosting options I've seen lately list phpMyAdmin as one of the benefits of going with their service... -Ed -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] MySQL to EXCEL?
-Original Message- You can use table tr td and each tr becomes an excel row and each td becomes a cell. This may or may not work in/before excel97?? If you're looking to create true excel files, then i highly suggest spreadsheetwrite_excel, It is an excellent codeset, enabling you to use many features of excel such as colors, math, formats, etc. doing it this way, is little to no different from exporting in csv format, but it does work as described. HTH Jeff Wow, that's pretty interesting. I'll play around with it =) -Ed -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] MySQL to EXCEL?
-Original Message- either output the data as a csv which you are doing (on windoze name the file with a .csv extension) or take a look at http://pear.php.net/package/Spreadsheet_Excel_Writer I have another option that might work for you also. Go to MySQL's website and grab their ODBC driver and use that to pull data directly into Excel. That's what I do and the end result tends to be a lot cleaner than going through cvs or other MySQL exports. -Ed -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] MySQL to EXCEL?
-Original Message- From: Daniel Brunner [mailto:[EMAIL PROTECTED] Sent: Tuesday, August 17, 2004 2:45 PM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] MySQL to EXCEL? I don't know how you have it setup. But you can create a XLS file on the fly using PHP By using header... header(Content-Type: application/vnd.ms-excel); header(Content-Dispostion: attachemnt; filename='Project.xls'); header(Pragma: no-cache); header(Expires: 0); Then just echo your results from your query, like normal... Could you expound on this? What field delimiter are you using? You have just created a XLS from PHP...Which can be saved to a XLS Workbook... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Re: Basic MySQL Query Question
Is it just me or is this a very bad thing from a security standpoint? It seems to me that user input should always be filtered before use. Otherwise there's nothing stopping a hacker from embedding sql into the value of the name variable. -Original Message- Insert into members (name) values ($_POST['name']); -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] MAILING LIST QUESTION
-Original Message- I don't have smtp server running on my computer. Any suggestions for smtp server, please. Those settings will depend entirely on your Internet Service Provider. You'll need to call them and ask what you'd use for your outgoing SMTP server for sending email. -Ed -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Limiting persistant connections with IIS
php.ini ; Maximum number of persistent links. -1 means no limit. mysql.max_persistent = -1 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 11, 2004 8:33 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] Limiting persistant connections with IIS I'm running a PHP app on windows 2000 / IIS using unified ODBC to connect to MS-SQL. I would like to connect to the database using persistant connections but need to limit the total number of connections to avoid swamping the database. It seems that a new connection is created for every request made to the webserver at least for the first few tens of requests - presumably a new php thread is being created for each request. I've tried limiting the maximum connections allowed by IIS for the website - but this does not appear to affect the number of PHP threads holding persistant connections to the db. I have set odbc.max_links in the php.ini file in case it is a bug in my program opening lots of connections but with maximum connections for IIS being set to 20 and max_links 4 I still end up with several hundred database connections after a few hundred page requests. If I was implementing this on apache (which I have much more experience of using) I would use the MaxClients directive to achieve this... Does anyone know how to limit the number of persistant database connections on windows/IIS/PHP? cheer Simon -- ~ Simon Rees | [EMAIL PROTECTED] | ORA-03113: end-of-file on communication channel ~ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Intellectual property rights
You're asking a legal question and should contact an attorney. -Original Message- From: Vincent Jordan [mailto:[EMAIL PROTECTED] Sent: Monday, August 09, 2004 4:03 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] Intellectual property rights This is a bit off topic however it may be something people here have or will have the unpleasant opportunity to deal with. The company I work for has been having a problem tracking our customers warranty information and have used paper for items sent in for repair. I on my own time had created a web based application in php that would make both issues paperless, and in my own opinion getter overall. Once complete I informed my supervisor of the application and asked if It could be shown to the vice president for review, with the condition that this is my application and I own all source and design of the application. My supervisor said he would need our IT department to look it over before it went to the VP. At the request of the IT department head I downloaded the files and sql dump of the database to the company's server. The next day I wad in the IT office talking with the director of IT and a 3rd party company about the functions and design of the application. Because they are all Microsoft weenies and cant admin a server unless they can point and click their way to a fix they said php would not be an acceptable language and mysql is not a proper database to run an application on. I informed them I could rewrite this in asp.net and place it on a mssql database. The IT director said they will be having the 3rd party company just take what I have made, convert it to asp and build off of it. I approached my supervisor about compensation for the work that was done since they are using my design. I was told you gave it to IT, there is nothing I can do about it I explained that this was given on the condition that it would be shown to the VP and in hopes that I would either gain a transfer to IT, be awarded a contract to provide the solution and maintenance, or maintain my current position with a slight raise and I will maintain and built onto the application. I went up the chain to my supervisors boss and explained to them what had happened and that since they are using my design and altering it to another language that I would like to be compensated for my work. I was told that I did nothing but give them an idea and they were really doing all the work since what I did was not good enough and their computers could not understand what I wrote. The IT dept refuses to run anything besides Win Servers using IIS. They will not install PHP ( too many hacker problems they say). Did I just screw myself? Do I have any protection of my design? Can I do anything? Thanks, Vinny -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Security Issues
so I've been doing a little thinking about web server security.. #1. Since all files on the web are 644, what is to stop someone on the same server from copying your files to their own directory? (specifically your database connection info) #2. if a folder if 777, what's to stop someone from writing to that folder? Virtual Servers http://searchnetworking.techtarget.com/sDefinition/0,,sid7_gci213304,00.html People can only see their own directories and files. PHP Safe Mode http://us2.php.net/features.safe-mode Check the section titled Safe Mode in the php.ini file. It has settings that help lock things down. Apache open_basedir Also detailed in the PHP Safe Mode documentation. There are a few other things that can be done to limit the scope of access, but all of it really depends on how the server is setup. I've seen many situations where hosting providers set accounts up with basic Virtual Hosting without doing any sort of lock down. If you're not careful and chose one of those providers, then you're definitely open to the sort of security breach that you've described. -Ed -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] addslashes replacement?
I'm using php addslashes to store data into MySQL and php stripslashes when pulling it back out, but I'm running into trouble when people enter HTML code. Do you have any recommendations? Here's an example of what I'm talking about: input name=Title value=?php echo stripslashes($Entry[Title]);? An error occurs if the entry has a value of: this is a font color=redbtest/b/font. Are we having FUN yet? Any ideas or recommendations? Thanks, -Ed -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Re: addslashes replacement?
Thanks everyone. I ended up using a combination of the htmlspecialchars and the stripslashes commands. The htmlspecialchars function has an example about halfway down that I ended up using. Thanks =) -Original Message- Take a look at the php website on the function addslashes. You will find an example with the functions reslash and reslash. You might have some problems regarding magic_quotes. Ive been using the reslash and deslash for some time now without any problems. It might solve your problems. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] HELP-PHP install
I submitted a question on Monday, September 01, 2003 2:45 PM, The title was [PHP-DB] Novice needs help installing PHP on second computer and it containd the following script with which i installed. The script is a result of two or more months of trying to install linux, mysql, php, and apache at the same time on a dell 4100. The script (after 2 months of problems) was created from many many samples found on various web sites. The script for the second PC was used (cut and paste one line at a time), and the system I need works the way I expect. Please be aware of the fact that I do not know much about Linux, and all the commands or whatever they are call were copied from the web. The specification and script follows: OS = Dell 4500, mem 1g, hd 45g, mhz 2g, Mysql-3.23.54a-linux-i686, PHP-4.30, httpd_2.0.44 # # installed using root - #apache package is in file:/usr/local/httpd-2.0.44.tar.gz #php package is in file:/usr/local/php-4.3.0.tar.gz # 1. If successful, install, as root: Download/unpack # Apache2 source from the Apache httpd server website. # cd /usr/local/ # gunzip -dv httpd-2.0.44.tar.gz | tar xvf - # tar -xvf httpd-2.0.44.tar # # 2. In the Apache 2 source directory, type: # cd /usr/local/httpd-2.0.44 # ./configure --prefix=/usr/local/httpd\ --enable-so \ --enable-cgi\ --enable-info \ --enable-rewrite\ --enable-speling\ --enable-usertrack \ --enable-deflate \ --enable-ssl\ --enable-mime-magic # make # # 3. install # make install # # 4. Download/unpack PHP source from the PHP website # Pick one from the 4.3.x series (see note above). # cd /usr/local/ # # Unzip this file with a command like: gunzip php-4.x.y.tar.gz # gunzip php-4.3.0.tar.gz # # Next you have to untar it with: tar -xvf php-4.x.y.tar # tar xvf php-4.3.0.tar # # This will create a php-4.x.y directory. cd into this new directory. # cd /usr/local/php-4.3.0 # # 5. In the php source directory, type: # ./configure \ --with-apxs2=/usr/local/httpd/bin/apxs \ --with-mysql=/usr/local/mysql\ --prefix=/usr/local/php \ --with-config-file-path=/usr/local/php \ --enable-track-vars \ --enable-force-cgi-redirect \ --enable-debugger\ --enable-magic-quotes\ --disable-cgi \ --with-zlib \ --with-gettext \ --with-gdbm # # 6. # make # make install # # 7. If file /usr/local/httpd/modules/libphp4.so # does not exist or is an older version, type this: # cp -p .libs/libphp4.so /usr/local/httpd/modules # # 8. Install the php.ini file: # cp -p php.ini-recommended /usr/local/php/php.ini # # make changes to # ### #/usr/local/httpd/conf/httpd.conf: #/usr/local/httpd/conf/httpd.conf: #/usr/local/httpd/conf/httpd.conf: # 9. Verify (and add if missing) these directives # in /usr/local/httpd/conf/httpd.conf: # Make sure there's only **1** line with this directive: LoadModule php4_modulemodules/libphp4.so # # Add index.php to your DirectoryIndex line: DirectoryIndex index.html index.php # AddType application/x-httpd-php php Files *.php SetOutputFilter PHP SetInputFilter PHP /Files # # PHP Syntax Coloring (recommended): AddType application/x-httpd-php-source phps Files *.phps SetOutputFilter PHP SetInputFilter PHP /Files # # *** I hope this may give you some ideas on how_to for my specific system. [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Mozilla stops displaying the web page
Dell 4200, mem 128g, disk 13g, mhz 800g, Mysql-3.23.54a-linux-i686, PHP-4.30, httpd_2.0.44 ,Mozilla/50 1.0.1, ZEND IDE 2.6 When running a PHP script (program), Mozilla stops displaying the web page after using about 5mb of disk space. Based on the percentage of source processed, I estimate I need about 200mb of disk space. Any method or procedure where all the data processed and saved would be appreciated. Multiple webpages from one PHP script would fill my needs best and being able to label or name each webpage with my page_name would be ideal. Note: ZEND IDE debug runs to end of job displaying all the HTML code generated. Thanks ed anderson [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Novice needs help installing PHP on second computer(repost)
Dell 4500, mem 1g, hd 45g, mhz 2g, Mysql-3.23.54a-linux-i686, PHP-4.30, httpd_2.0.44 I'm having trouble installing and running php. Mozilla displays html pages, and mysql displays commands on the console. I would appreciate any urls for message boards the specialize in this type of php problem. Thanks in advance ed anderson [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Novice needs help installing PHP on second computer
Dell 4500, mem 1g, hd 45g, mhz 2g, Mysql-3.23.54a-linux-i686, PHP-4.30, httpd_2.0.44 The notes script that I used on my Dell 4100 mem 250mb, hd 12g, mhz 800, Mysql-3.23.54a-linux-i686, PHP-4.30, httpd_2.0.44, should in theory work on my Dell 4500. Both computers are stand alone systems. Dell 4100: Mozilla displays the work of one php class, three extended php classes and the processing of five php scripts correctly. This is about 1200 lines of php code are working. Dell 4500: I can manipulate the mysql tables, SELECT, SHOW LOAD etc. I can get Mozilla to display http://127.0.0.1/php_test.html;, but not http://127.0.0.1/stuff.php; which contains phpinfo() or http://127.0.0.1/php_test.php;. Any hints, help, or documentation would be appreciated. Thanks Ed Anderson [EMAIL PROTECTED] The notes I used for both computers follows: # # installed using root - #apache package is in file:/usr/local/httpd-2.0.44.tar.gz #php package is in file:/usr/local/php-4.3.0.tar.gz # 1. If successful, install, as root: Download/unpack # Apache2 source from the Apache httpd server website. # cd /usr/local/ # gunzip -dv httpd-2.0.44.tar.gz | tar xvf - # tar -xvf httpd-2.0.44.tar # # 2. In the Apache 2 source directory, type: # cd /usr/local/httpd-2.0.44 # ./configure --prefix=/usr/local/httpd\ --enable-so \ --enable-cgi\ --enable-info \ --enable-rewrite\ --enable-speling\ --enable-usertrack \ --enable-deflate \ --enable-ssl\ --enable-mime-magic # make # # 3. install # make install # # 4. Download/unpack PHP source from the PHP website # Pick one from the 4.3.x series (see note above). # cd /usr/local/ # # Unzip this file with a command like: gunzip php-4.x.y.tar.gz # gunzip php-4.3.0.tar.gz # # Next you have to untar it with: tar -xvf php-4.x.y.tar # tar xvf php-4.3.0.tar # # This will create a php-4.x.y directory. cd into this new directory. # cd /usr/local/php-4.3.0 # # 5. In the php source directory, type: # ./configure \ --with-apxs2=/usr/local/httpd/bin/apxs \ --with-mysql=/usr/local/mysql\ --prefix=/usr/local/php \ --with-config-file-path=/usr/local/php \ --enable-track-vars \ --enable-force-cgi-redirect \ --enable-debugger\ --enable-magic-quotes\ --disable-cgi \ --with-zlib \ --with-gettext \ --with-gdbm # # 6. # make # make install # # 7. If file /usr/local/httpd/modules/libphp4.so # does not exist or is an older version, type this: # cp -p .libs/libphp4.so /usr/local/httpd/modules # # 8. Install the php.ini file: # cp -p php.ini-recommended /usr/local/php/php.ini # # make changes to # ### #/usr/local/httpd/conf/httpd.conf: #/usr/local/httpd/conf/httpd.conf: #/usr/local/httpd/conf/httpd.conf: # 9. Verify (and add if missing) these directives # in /usr/local/httpd/conf/httpd.conf: # Make sure there's only **1** line with this directive: LoadModule php4_modulemodules/libphp4.so # # Add index.php to your DirectoryIndex line: DirectoryIndex index.html index.php # AddType application/x-httpd-php php Files *.php SetOutputFilter PHP SetInputFilter PHP /Files # # PHP Syntax Coloring (recommended): AddType application/x-httpd-php-source phps Files *.phps SetOutputFilter PHP SetInputFilter PHP /Files # # [EMAIL PROTECTED] php-4.3.0]# /usr/local/httpd/bin/apachectl start note: ps -ef indicates httpd is up and running... [EMAIL PROTECTED] php-4.3.0]# cd /usr/local/mysql [EMAIL PROTECTED] mysql]# ./bin/safe_mysqld --user=mysql [1] 23159 [EMAIL PROTECTED] mysql]# Starting mysqld daemon with databases from /usr/local/mysql/data [EMAIL PROTECTED] mysql]# ./bin/mysql Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 to server version: 3.23.54 Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql USE mysql; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] converting function to class and function (object)
Dell 4500, mem 1g, disk 45g, mhz 2g, Mysql-3.23.54a-linux-i686, PHP-4.30, httpd_2.0.44, moxilla 1.0.1 Can someone help converting a function to a class and function. The included function in example 1 works as expected but the include class and function in example 2 does not. What can I do to fix this problem. Note that example 1 executed 0f and 1f echos in addition to all echos in the main(?) php script, where as example 2 stops after the main(?) php script echo 2 which means the {include (./inc/tcb/tmtb_connect_tbc_db.cls);} statement was parsed but had errors. included Function for example 1 ?php # include (tmtb_connect_tbc_db.inc); function connect_tbc_db() { echo 0f br; $tmtb_db = mysql_connect(localhost, root) or die (die tmtb_connect_tbc_db.inc mysql_connect $tmtb_db\n); echo 1f br; mysql_select_db(tbc_db, $tmtb_db) or die (die tmtb_connect_tbc_db.inc mysql_select_db $tmtb_db\n); echo br tmtb_connect_tbc_db.inc return $tmtb_db br; return $tmtb_db; } ? included Class and Function for example 2 ?php # include (tmtb_connect_tbc_db.cls); class connect_tbc_db_cls { var $tmtb_db = 0; # function connect_tbc_db() { echo 0f br; this-$tmtb_db = mysql_connect(localhost, root) or die (die tmtb_connect_tbc_db.cls mysql_connect this-$tmtb_db\n); echo 1f br; #mysql_select_db(tbc_db, this-$tmtb_db) # or die ( die tmtb_connect_tbc_db.cls mysql_select_db this-$tmtb_db\n); echo br tmtb_connect_tbc_db.cls return this-$tmtb_db br; return this-$tmtb_db; } }; ? using Mozilla example 1 htmlheadtitletmtb_r_select_html_3.php/title/head body tmtb_r_select_html_3.php BRBR !-- including class and functionBRBR -- including functionBRBR ?php ## tmtb_connect_tbc_db.inc echo 1 br; # #include (./inc/tcb/tmtb_connect_tbc_db.cls); #echo 2 br; #$a = new connect_tbc_db_cls(); #echo 3 br; #$tmtb_db = $a-connect_tbc_db(); #echo 4 br; # include (./inc/tcb/tmtb_connect_tbc_db.inc); echo 2 br; $tmtb_db = connect_tbc_db(); echo 3 br; ## define_variables include (./inc/tmr/dat_tmr_variables.inc); include (./inc/html/html_variables.inc); # echo 4 br...br...br...br; ? brbr # tmtb_r_select_html_3.php end BRBR /body /html submit http://127.0.0.1/tmtb_r_select_html_3.php example 1 output follows tmtb_r_select_html_3.php including function 1 2 0f 1f tmtb_connect_tbc_db.inc return Resource id #3 3 4 ... snip # tmtb_r_select_html_3.php end end example 1 using Mozilla example 2 ** htmlheadtitletmtb_r_select_html_3.php/title/head body tmtb_r_select_html_3.php BRBR including class and functionBRBR !-- including functionBRBR -- ?php ## tmtb_connect_tbc_db.inc echo 1 br; # include (./inc/tcb/tmtb_connect_tbc_db.cls); echo 2 br; $a = new connect_tbc_db_cls(); echo 3 br; $tmtb_db = $a-connect_tbc_db(); echo 4 br; # #include (./inc/tcb/tmtb_connect_tbc_db.inc); #echo 2 br; #$tmtb_db = connect_tbc_db(); #echo 3 br; ## define_variables include (./inc/tmr/dat_tmr_variables.inc); include (./inc/html/html_variables.inc); # echo 4 br...br...br...br; ? brbr # tmtb_r_select_html_3.php end BRBR /body /html submit http://127.0.0.1/tmtb_r_select_html_3.php example 2 output follows tmtb_r_select_html_3.php including class and function 1 2 end example 2 Thanks ed anderson -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] How can I get the number of entries retrieved by a SELECT - FROM Thanks!
Dell 4500, mem 1g, disk 45g, mhz 2g, Mysql-3.23.54a-linux-i686, PHP-4.30, httpd_2.0.44 Thanks to Paul DuBois, Roger Davis, Helen Sallee, Ronan Chilvers, and Edward Dudlik for thier response to my question. I've included the a (one of many?) snippit of code that I've decided to use as a pattern for a (class) to be developed. Thanks again: Ed anderson htmlheadtitlesample.php/title/head body sample.php BR see page 405 msql cookbook for code used to develop $h_nrows BR ?php # $mysql_connect = mysql_connect(localhost, root) or die (mysql_connect $mysql_connect\n); mysql_select_db(mysql, $mysql_connect) or die (mysql_select_db $mysql_connect\n); # $h_id1 = 3; $h_id2 = 4; $h_id3 = 5; $t = td; $tn = /td; $r = tr; $rn = /tr; # $h_query = SELECT * FROM employees WHERE id=$h_id1 OR id=$h_id2 OR id=$h_id3; printf(mysql_query: $h_querybr\n); # $h_result_id = mysql_query($h_query, $mysql_connect); if(! $h_result_id) die ( mysql_query h $mysql_connect\n); $h_nrows = @mysql_num_rows ($h_result_id); # if ($h_nrows == 0) print (Note: h query has no result set\n); $dat_h_id = mysql_result($h_result_id,$i,id); $dat_first = mysql_result($h_result_id,$i,first); $dat_last = mysql_result($h_result_id,$i,last); # # # echo table border=1 cellspacing=0; for ($i = 0; $i $h_nrows; $i++) { echo $r; $dat_h_id = mysql_result($h_result_id,$i,id); echo $t $dat_h_id$tn; $dat_first = mysql_result($h_result_id,$i,first); echo $t $dat_first$tn; $dat_last = mysql_result($h_result_id,$i,last); echo $t $dat_last $tn; echo $t $i$tn; echo $t $h_nrows $tn; echo $rn; } echo /table; # ? BR sample.php end BRBR /body /html using mozilla browser -http://127.0.0.1/sample.php sample.php see page 405 msql cookbook code used to develop $h_nrows mysql_query: SELECT * FROM employees WHERE id=3 OR id=4 OR id=5 3 Brad Johnson 0 3 4 aa bb 1 3 5 WW EE 2 3 sample.php end -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] How can I get the number of entries retrieved by a SELECT - FROM
Dell 4500, mem 1g, disk 45g, mhz 2g, Mysql-3.23.54a-linux-i686, PHP-4.30, httpd_2.0.44 1. How do I trap or collect or save the digit 3 generated the mysql SELECT COUNT(*) statement below? 2. The PHP SELECT FROM below (before snip) listed the expected data. Is there a way to get the digit 3 into a PHP variable? SELECT h_id, name FROM tbtm # displays WHERE h_id=1# three OR h_id=2 # lines OR h_id=3; # of data SELECT COUNT(*) FROM tbtm # displays WHERE h_id='1'# the OR h_id='2'# digit OR h_id='3'; # three +--+ | COUNT(*) | +--+ |3 | +--+ 1 row in set (0.00 sec) The next PHP is the same as the SELECT FROM above. ?php $result = mysql_query( SELECT h_id, name, FROM tbtm WHERE h_id='1' OR h_id='2' OR h_id='3', $tmtb_db); # printf(ID: %sbr\n, mysql_result($result,1,h_id)); printf(name: %sbr\n,mysql_result($result,1,name)); snip snip # ? Thanks [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] RE: XML
I am looking at a project using XML to import and export data into MySql directly or using php. The datasets are quite large (40-50 million records) XML is a metadata technology - you wrap data in XML. You don't use XML to import or export data. You don't store XML in a database, you store data. When you fetch the data from the database, you wrap it in XML and send it on its way. Does that make it simpler? sql,mysql -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] RE: XML
On the other hand, proclaimed native XML databases (eg, Software AG's Tamino, Ixiasoft's TEXTML) store the XML-wrapped data in the database...no need to wrap and unwrap the metadata, document/data structure from the data. Isn't that more than a bit stupid? Databases are for storing data, not metadata. Ask Monty why he doesn't store data natively as XML. Short answer: it's stupid, unless all you ever want to see from your database is XML-wrapped data and never want to see it any other way. The whole world isn't XML, nor should it be. 40+ years of working with data tells us that you ALWAYS want to store data in its simplest form. sql,db,mysql -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] RE: XML
Not sure there is much more metadata in an XML database than in a data database. In a standard database, the data and metadata are stored separately, not so with XML. When the next new latest and greatest thing comes along, you'll have to strip all that metadata out of your data. It also makes for bigger databases, and a lot more wasted space, like comparing normalized and unnormailzed tables. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] dropping one word from column entries
Naw do your parsing in PHP..try to lessen the load on the DB server any way you can... ed At 09:11 AM 5/30/2002 +0800, Beau Lebens wrote: A cleaner option might be to do this before you get it to PHP at all, via your SQL query. Check out the string functions available, there are a number of substring-style things available, string position etc. HTH Beau // -Original Message- // From: Ed Gorski [mailto:[EMAIL PROTECTED]] // Sent: Thursday, 30 May 2002 12:09 AM // To: Jen Swofford; php-db@lists. php. net // Subject: Re: [PHP-DB] dropping one word from column entries // // // use: // // $name=Mouse Housing Products; // $name=str_replace(Products,,$name); // // also the RTFM() function works too // // ed // // At 11:06 AM 5/29/2002 -0500, Jen Swofford wrote: // I'm having a problem with this and suppose I'm looking for // a handout. :| // // I am displaying names of product categories. The names of // the categories // are: // // Bird Cages // Cat Toys // Chinchilla Housing Products // Dog Leashes // Ferret Housing Products // Mouse Housing Products // // What I want to do when displaying the names is to drop // Products whenever // it appears. What I want do display on the page instead is: // // Bird Cages // Cat Toys // Chinchilla Housing // Dog Leashes // Ferret Housing // Mouse Housing // // And no, changing the names of the categories in the // database is not an // option. :) I'm completely missing the boat on this one... // any help? // // Jen Swofford // [EMAIL PROTECTED] // // // // // -- // PHP Database Mailing List (http://www.php.net/) // To unsubscribe, visit: http://www.php.net/unsub.php // // // -- // PHP Database Mailing List (http://www.php.net/) // To unsubscribe, visit: http://www.php.net/unsub.php // -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] mysql exclusion in php
You need to parse the string and PHP and generate the appropriate query based on that parsing... ed At 09:22 PM 5/29/2002 -0700, Chris Payne wrote: Hi there everyone, How can I do a search which excludes certain words if they put a - in the search string? I can do a search easily, but if they put a - infront of a word in the string, how can I then get MySQL to search all entries EXCEPT where the word with a - next to it appears? Thanks for everything. Chris -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re[2]: [PHP-DB] how to pull array out?
Well put Julie ed At 10:39 AM 5/30/2002 -0700, Julie Meloni wrote: Jas (and anyone else) - With all due respect, you're acting like a troll. Posting a question, getting MANY correct answers, then reposting the question and bitching about not understanding the answers, well, that's troll-like. Granted, many responses on this list over the past while have been sarcastic, but usually also have the answer in them. The tone comes from people asking the questions not doing their own homework. e.g. http://www.tuxedo.org/~esr/faqs/smart-questions.html Mailing lists such as this one are not intended to give people verbatim answers to their problems, such as I have to write an application for my university class, please do it for me and the like. Instead, these lists will help those who attempt to help themselves. The fact of the matter is, RTFM is the right answer. The very simplistic method of reading the results of a MySQL query are right there in the manual, in the MySQL query functions section. Also, they're in zillions of tutorials, any basic book on PHP, and so on. In short: 1) connect to db server -- mysql_connect() 2) select db -- mysql_select_db() 3) issue query -- mysql_query() 4) from there you get a result identifier. You feed that into mysql_result() or mysql_fetch_array() or mysql_fetch_row() Read the manual for the differences -- including examples. You say: J rest of us we rely on examples, etc to get it done. They ARE in the manual, which is pretty much the best manual out there for just about anything. Good luck, - Julie -- Julie Meloni -- [EMAIL PROTECTED] -- www.thickbook.com Find Sams Teach Yourself MySQL in 24 Hours at http://www.amazon.com/exec/obidos/ASIN/0672323494/thickbookcom-20 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: Re[2]: [PHP-DB] how to pull array out?
People use to suppress errors / warning messagesI know I use it a lot with obdc and SQL SERVER procedures... ed At 02:32 PM 5/30/2002 -0400, Leotta, Natalie (NCI/IMS) wrote: From what I've seen on the PHP.net site, it doesn't look like people use the @ in @mysql_query, and I know that I don't use it for sybase_query. Where did it come from? Assuming that's not the problem, I'd try printing out everything. Right after your while, print $row - it should say array, then try printing $row[0] and see if that works. Then try printing $row['user_id']. You may also want to try doing a SELECT with the fieldnames, instead of just the *. Also, make sure you're typing the field names correctly - they are case sensitive. Hopefully one of these suggestions will help you. -Natalie -Original Message- From: Jas [mailto:[EMAIL PROTECTED]] Sent: Thursday, May 30, 2002 2:18 PM To: [EMAIL PROTECTED] Subject: Re: Re[2]: [PHP-DB] how to pull array out? Ok, given there are people out there that expect people to do the work for them, however if you look at my original post (today) you will see that I have queried the database, feed the results into an array, then called the array elements into my form, however simple this may be for you it is still not pulling out the results of the array into my form. I do believe I am missing something, and doing homework is a part of my everyday routine trying to develop web based apps. The code again: $table = auth_users; // names the table to query correct? $record = @mysql_query(SELECT * FROM $table WHERE user_id = '$user_id',$dbh); // pulls all records in relation to $user_id correct? while ($row = mysql_fetch_array($record)) { // pulls results of query into an array correct? $user_id = $row['user_id']; // assigns unique names for my different editable regions correct? $f_name = $row['f_name']; $l_name = $row['l_name']; $email_addy = $row['email_addy']; $un = $row['un']; $pw = $row['pw']; } $var_form .= form name=\$user_id\ method=\post\ action=\del_account.php\ bEdit Account $user_id/bbr // echoes the $user_id that is going to be edited correct? First Name:input type=\text\ name=\f_name\ size=\30\ maxlength=\30\ value=\$f_name\br // displays text box to edit with $f_name variable from resulting array correct? Last Name:input type=\text\ name=\l_name\ size=\30\ maxlength=\30\ value=\$l_name\br // displays text box to edit with $l_name variable from resulting array correct? Email:input type=\text\ name=\email_addy\ size=\30\ maxlength=\30\ value=\$email_addy\br // displays text box to edit with $email_addy variable from resulting array correct? User Name:input type=\text\ name=\un\ size=\30\ maxlength=\30\ value=\$un\br // displays text box to edit with $un variable from resulting array correct? Password:input type=\password\ name=\pw\ size=\30\ maxlength=\30\br // displays text box to edit with $pw variable from resulting array correct? Confirm Password:input type=\password\ name=\cpw\ size=\30\ maxlength=\30\ nbsp;input type=\submit\ name=\add\ value=\edit user\nbsp;nbsp;input type=\reset\ name=\reset\ value=\reset\; Any help or examples are appreciated. Please understand I am trying to learn this scripting language and RTFM does not help as most of the time I post here as a LAST resort, i.e. after I have indeed RTFM'ed. Thanks again, Jas Julie Meloni [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Jas (and anyone else) - With all due respect, you're acting like a troll. Posting a question, getting MANY correct answers, then reposting the question and bitching about not understanding the answers, well, that's troll-like. Granted, many responses on this list over the past while have been sarcastic, but usually also have the answer in them. The tone comes from people asking the questions not doing their own homework. e.g. http://www.tuxedo.org/~esr/faqs/smart-questions.html Mailing lists such as this one are not intended to give people verbatim answers to their problems, such as I have to write an application for my university class, please do it for me and the like. Instead, these lists will help those who attempt to help themselves. The fact of the matter is, RTFM is the right answer. The very simplistic method of reading the results of a MySQL query are right there in the manual, in the MySQL query functions section. Also, they're in zillions of tutorials, any basic book on PHP, and so on. In short: 1) connect to db server -- mysql_connect() 2) select db -- mysql_select_db() 3) issue query -- mysql_query() 4) from there you get a result identifier. You feed that into mysql_result() or mysql_fetch_array() or mysql_fetch_row() Read the manual for the differences -- including examples. You say: J rest of us we rely on examples, etc to get
Re: [PHP-DB] variables gone?
In php.ini you need to turn register_globals on..you also might want to start using the $_GET, $_POST, $_SESSION global arrays ed At 02:49 PM 5/29/2002 +0100, Rob Fraser wrote: Dear All, I am probably doing something silly but I don't know what (story of my life). I have just upgraded to 4.2.1 and now all the variables I post in forms or in query strings are now coming up undefined errors and are in absent. I'm running PHP under IIS 4. What am I doing wrong? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] dropping one word from column entries
use: $name=Mouse Housing Products; $name=str_replace(Products,,$name); also the RTFM() function works too ed At 11:06 AM 5/29/2002 -0500, Jen Swofford wrote: I'm having a problem with this and suppose I'm looking for a handout. :| I am displaying names of product categories. The names of the categories are: Bird Cages Cat Toys Chinchilla Housing Products Dog Leashes Ferret Housing Products Mouse Housing Products What I want to do when displaying the names is to drop Products whenever it appears. What I want do display on the page instead is: Bird Cages Cat Toys Chinchilla Housing Dog Leashes Ferret Housing Mouse Housing And no, changing the names of the categories in the database is not an option. :) I'm completely missing the boat on this one... any help? Jen Swofford [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Error? new set of eyes...
Why don't you try this instead: while(list($id, $2d, $3d, $web, $prog, $tut, $proj)=mysql_fetch_array($portfolio)) { do whatever.. } the list construct only works with numerical arrays and it might not like the $section array (doesn't it get stored as number indicies AND column names? That might generate that error). But if you need that section array later, we can try a different approach.. ed At 07:15 AM 5/28/2002 -0600, Jas wrote: Hello all, I have an error and I will be darned if I know why. Here is the code: ?php require '/path/to/database/connection/class/db.php'; $table = portfolio; $portfolio = mysql_query(SELECT * FROM $table,$dbh); while ($sections = mysql_fetch_array($portfolio)) { list($id, $2d, $3d, $web, $prog, $tut, $proj) = $sections; // I think the error is on this line. } ? Then I just echo the contents of the database array like so. ?php echo $2d; ? // this is line 69 And this is the error I am recieving: Parse error: parse error, expecting `T_VARIABLE' or `'$'' in /localhost/portfolio.php on line 169 Any help would be great!! Jas -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Edmund Gorski Programmer / Analyst WWW Coordinator Dept. District Office 727-341-3181 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] creating errors
try just: $sql = INSERT INTO $table_name (f_name,l_name,email_addy,un,pw) VALUES ('$f_name','$l_name','$email_addy','$un', 'PASSWORD('$pw')'; ed At 09:55 AM 5/28/2002 -0600, Jas wrote: I am trying to add an insert into a table and set one of the fields to a password hash, however I am recieving errors: $sql = INSERT INTO $table_name (f_name,l_name,email_addy,un,pw) VALUES ('$f_name','$l_name','$email_addy','$un', 'pw=PASSWORD('$pw')'; Is there any reason this would not work? Jas -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] front end for mysql for use on my website
I am looking for a front end for mysql for use on my website. What I want is something that I can run, from the server (my webhost will not allow remote connections to the mysql server), that allows me to insert, delete, and modify records into a mySql database. Requirements are that it be free, preferrably written in PHP and not require a knowledge of SQL. Anything out there that can do this? -- 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]