[PHP-DB] Very complex query
Hi every1! Excuse me for maybe offtopic but I need help on mysql database. I have 4 tables, and here are some important extractions from 'em: objects{ object_id; name; } users{ user_id; nick; date; } notes{ user_id; object_id; } object_properties{ object_id; property_name; property_value; } I need to get EACH object_id from notes with ONLY ONE of corresponding user_id's. Also for each object I need it's name from objects and property from object_properties where property_name = 'foo'. And for each of obtained user_id I need it's nick and it's date. Does anyone know how to do it just by one mysql query? Thanx... Mike U. Petrov -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Very complex query
Mike U. Petrov wrote: Hi every1! Excuse me for maybe offtopic but I need help on mysql database. I have 4 tables, and here are some important extractions from 'em: objects{ object_id; name; } users{ user_id; nick; date; } notes{ user_id; object_id; } object_properties{ object_id; property_name; property_value; } I need to get EACH object_id from notes with ONLY ONE of corresponding user_id's. Also for each object I need it's name from objects and property from object_properties where property_name = 'foo'. And for each of obtained user_id I need it's nick and it's date. Does anyone know how to do it just by one mysql query? Thanx... Mike U. Petrov Use unique(user_id). And please don't reply to a previous post when posting a new threadit screws up threading. -- paperCrane -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Re: Very complex query
First, sorry my starnge way to post new thread. Second: I want to specify some features: in my table notes I've a lot of user_id's for each object_id and I don't want to find unique user_id, I only want to find one user_id for each object_id, so unique(user_id) doesn't match. Do u have any other ideas? Mike U. Petrov -Original Message- From: Justin Patrin [mailto:[EMAIL PROTECTED] Sent: Thursday, December 11, 2003 10:53 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] Re: Very complex query Use unique(user_id). And please don't reply to a previous post when posting a new threadit screws up threading. -- paperCrane -- 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] Re: Very complex query
You can also DISTINCT command instead. UNIQUE command isnot supported by mySQL (at least at MySQL 3.23.41- I am using) Hope this helps, M.Mamedov - Original Message - From: "Justin Patrin" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, December 11, 2003 9:52 AM Subject: [PHP-DB] Re: Very complex query > Mike U. Petrov wrote: > > > Hi every1! > > Excuse me for maybe offtopic but I need help on mysql database. > > I have 4 tables, and here are some important extractions from 'em: > > objects{ > > object_id; > > name; > > } > > users{ > > user_id; > > nick; > > date; > > } > > notes{ > > user_id; > > object_id; > > } > > object_properties{ > > object_id; > > property_name; > > property_value; > > } > > I need to get EACH object_id from notes with ONLY ONE of corresponding > > user_id's. Also for each object I need it's name from objects and property > > from object_properties where property_name = 'foo'. And for each of obtained > > user_id I need it's nick and it's date. > > Does anyone know how to do it just by one mysql query? > > > > Thanx... > > Mike U. Petrov > > Use unique(user_id). And please don't reply to a previous post when > posting a new threadit screws up threading. > > -- > paperCrane > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.545 / Virus Database: 339 - Release Date: 27.11.2003 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Re: Very complex query
No, DISTINCT isn't match my purpose cause of it rerurns unique rows but I need ONE user_id per one object_id. Mike U. Petrov -Original Message- From: Muhammed Mamedov [mailto:[EMAIL PROTECTED] Sent: Thursday, December 11, 2003 11:01 AM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] Re: Very complex query You can also DISTINCT command instead. UNIQUE command isnot supported by mySQL (at least at MySQL 3.23.41- I am using) Hope this helps, M.Mamedov - Original Message - From: "Justin Patrin" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, December 11, 2003 9:52 AM Subject: [PHP-DB] Re: Very complex query > Mike U. Petrov wrote: > > > Hi every1! > > Excuse me for maybe offtopic but I need help on mysql database. > > I have 4 tables, and here are some important extractions from 'em: > > objects{ > > object_id; > > name; > > } > > users{ > > user_id; > > nick; > > date; > > } > > notes{ > > user_id; > > object_id; > > } > > object_properties{ > > object_id; > > property_name; > > property_value; > > } > > I need to get EACH object_id from notes with ONLY ONE of corresponding > > user_id's. Also for each object I need it's name from objects and property > > from object_properties where property_name = 'foo'. And for each of obtained > > user_id I need it's nick and it's date. > > Does anyone know how to do it just by one mysql query? > > > > Thanx... > > Mike U. Petrov > > Use unique(user_id). And please don't reply to a previous post when > posting a new threadit screws up threading. > > -- > paperCrane > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.545 / Virus Database: 339 - Release Date: 27.11.2003 -- 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] Re: Very complex query
Give me exactly the sample table with data and show what you want there. I will try to help you. M.Mamedov - Original Message - From: "Mike U. Petrov" <[EMAIL PROTECTED]> To: "Muhammed Mamedov" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Thursday, December 11, 2003 10:17 AM Subject: RE: [PHP-DB] Re: Very complex query > No, DISTINCT isn't match my purpose cause of it rerurns unique rows but I > need ONE user_id per one object_id. > > Mike U. Petrov > > > -Original Message- > From: Muhammed Mamedov [mailto:[EMAIL PROTECTED] > Sent: Thursday, December 11, 2003 11:01 AM > To: [EMAIL PROTECTED] > Subject: Re: [PHP-DB] Re: Very complex query > > > You can also DISTINCT command instead. > UNIQUE command isnot supported by mySQL (at least at MySQL 3.23.41- I am > using) > > Hope this helps, > M.Mamedov > > > - Original Message - > From: "Justin Patrin" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Thursday, December 11, 2003 9:52 AM > Subject: [PHP-DB] Re: Very complex query > > > > Mike U. Petrov wrote: > > > > > Hi every1! > > > Excuse me for maybe offtopic but I need help on mysql database. > > > I have 4 tables, and here are some important extractions from 'em: > > > objects{ > > > object_id; > > > name; > > > } > > > users{ > > > user_id; > > > nick; > > > date; > > > } > > > notes{ > > > user_id; > > > object_id; > > > } > > > object_properties{ > > > object_id; > > > property_name; > > > property_value; > > > } > > > I need to get EACH object_id from notes with ONLY ONE of corresponding > > > user_id's. Also for each object I need it's name from objects and > property > > > from object_properties where property_name = 'foo'. And for each of > obtained > > > user_id I need it's nick and it's date. > > > Does anyone know how to do it just by one mysql query? > > > > > > Thanx... > > > Mike U. Petrov > > > > Use unique(user_id). And please don't reply to a previous post when > > posting a new threadit screws up threading. > > > > -- > > paperCrane > > > > -- > > PHP Database Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > --- > Outgoing mail is certified Virus Free. > Checked by AVG anti-virus system (http://www.grisoft.com). > Version: 6.0.545 / Virus Database: 339 - Release Date: 27.11.2003 > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > > > --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.545 / Virus Database: 339 - Release Date: 27.11.2003 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Re: Very complex query
Mike U. Petrov wrote: First, sorry my starnge way to post new thread. Second: I want to specify some features: in my table notes I've a lot of user_id's for each object_id and I don't want to find unique user_id, I only want to find one user_id for each object_id, so unique(user_id) doesn't match. Do u have any other ideas? Mike U. Petrov -Original Message- From: Justin Patrin [mailto:[EMAIL PROTECTED] Sent: Thursday, December 11, 2003 10:53 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] Re: Very complex query Use unique(user_id). And please don't reply to a previous post when posting a new threadit screws up threading. -- paperCrane -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Oops, sorry about that. What you could do is: GROUP BY object_id or GROUP BY object_id, other_field, other_field2, etc Just don't group by user_id. -- paperCrane -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Re: Very complex query
I tried to use GROUP BY and it worked almost right but i need to return user_id and mysql generated an error that notes.user_id isn't used in GROUP BY... Mike U. Petrov -Original Message- From: Justin Patrin [mailto:[EMAIL PROTECTED] Sent: Thursday, December 11, 2003 11:25 AM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] Re: Very complex query Mike U. Petrov wrote: > First, sorry my starnge way to post new thread. > Second: > I want to specify some features: > in my table notes I've a lot of user_id's for each object_id and I don't > want to find unique user_id, I only want to find one user_id for each > object_id, so unique(user_id) doesn't match. Do u have any other ideas? > > Mike U. Petrov > > > -Original Message- > From: Justin Patrin [mailto:[EMAIL PROTECTED] > Sent: Thursday, December 11, 2003 10:53 AM > To: [EMAIL PROTECTED] > Subject: [PHP-DB] Re: Very complex query > > Use unique(user_id). And please don't reply to a previous post when > posting a new threadit screws up threading. > > -- > paperCrane > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php Oops, sorry about that. What you could do is: GROUP BY object_id or GROUP BY object_id, other_field, other_field2, etc Just don't group by user_id. -- paperCrane -- 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] Slashes
Hi, can I know when does the magic_quotes_gpc start adding slashes and stripping slashes? I removed my EscapeShellCmd and my data is inserted and retrieved from the database just as i wanted. The problem now comes when I retrieve that data and immediately inserted them into another table.. then I get a MySQL error 1064 whenever my value has a single-quote in it. for example, $query1 = "select * from table where condition"; if(!($result1 = mysql_query($query1))) echo SQLError(); $var = mysql_fetch_array($result1); $query2 = "insert into table2 set col1='".$var["col1"]."', col2='".$var["col2"]."', col3='".$var["col3"]."' etc..."; if(!($result2 = mysql_query($query2))) echo SQLError(); $query1 works perfectly fine of course.. but $query2 gives me error: MySQL error: 1064 : You have an error in your SQL syntax near 's Good!', col2 = 'YES', ' at line 15 (# 256). the value retrieved from the database is: It's Good! what happened?! thanx.. - Original Message - > Ng Hwee Hwee wrote: > > > just a quick question.. does it mean, i don't have to worry that my user may > > type any commands in my text field that may hurt my system since > > magic_quotes_gpc is on? > > Heh...of course not. :) All magic_quotes is going to do for you is > escape quotes within your text. This will help with database queries but > not much else. You still need to be validating your data... > > -- > ---John Holmes...
Re: [PHP-DB] password generator
Thanx you all guys, great tools indeed! - Original Message - From: "Roger Spears" <[EMAIL PROTECTED]> To: "php database" <[EMAIL PROTECTED]> Sent: Wednesday, December 10, 2003 6:33 PM Subject: Re: [PHP-DB] password generator > Here's one I've used recently with success > > http://www.devhood.com/tools/tool_details.aspx?tool_id=784 > > Thanks, > Roger > > -- > 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] Slashes
On Thursday 11 December 2003 17:27, Ng Hwee Hwee wrote: > can I know when does the magic_quotes_gpc start adding slashes and > stripping slashes? magic_quotes_gpc is for incoming GET/POST/Cookie data (NB it does not strip slashes) ... > I removed my EscapeShellCmd and my data is inserted and retrieved from the > database just as i wanted. The problem now comes when I retrieve that data > and immediately inserted them into another table.. ... you can enable magic_quotes_runtime if you want to automatically quote data retrieved from DB (and other runtime generated data) ... But you would be much better off if you disable all magic_quotes_* and do manual quoting and escaping where necessary. That way you will know exactly what is being done to your data. > then I get a MySQL error > 1064 whenever my value has a single-quote in it. -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-db -- /* ...the prevailing Catholic odor - incense, wax, centuries of mild bleating from the lips of the flock. -- Thomas Pynchon, _Gravity's Rainbow_ */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] SQL question
I know it is possible to search a database like this: SELECT * FROM x_table WHERE name="%part_of_name%" but I don't know for sure the correct command. Could you tell me the right syntax? TIA Aurel. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] SQL question
It should be as follows: SELECT * FROM x_table WHERE name Like = "%part_of_name%" Hope this helps, M.Mamedov - Original Message - From: "Constantin Brinzoi" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, December 11, 2003 1:51 PM Subject: [PHP-DB] SQL question > I know it is possible to search a database like this: > > SELECT * FROM x_table WHERE name="%part_of_name%" > > but I don't know for sure the correct command. > > Could you tell me the right syntax? > > TIA > Aurel. > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.545 / Virus Database: 339 - Release Date: 27.11.2003 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] SQL question
On 11 December 2003 11:52, Constantin Brinzoi wrote: > I know it is possible to search a database like this: > > SELECT * FROM x_table WHERE name="%part_of_name%" > > but I don't know for sure the correct command. > > Could you tell me the right syntax? SELECT * FROM x_table WHERE name LIKE "%part_of_name%" Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] SQL question
try SELECT * FROM x_table WHERE name LIKE "%part_of_name%" -Original Message- From: Constantin Brinzoi [mailto:[EMAIL PROTECTED] Sent: 11 December 2003 11:52 To: [EMAIL PROTECTED] Subject: [PHP-DB] SQL question I know it is possible to search a database like this: SELECT * FROM x_table WHERE name="%part_of_name%" but I don't know for sure the correct command. Could you tell me the right syntax? TIA Aurel. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Email has been scanned for viruses by www.emf-systems.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] SQL question
I am sorry without equal "=" sign SELECT * FROM x_table WHERE name Like "%part_of_name%" there are actually three ways to do this: "%part_of_name%" part_of_name appears anywhere "%part_of_name"part_of_name appears at the end "art_of_name%" part_of_name appears at the begining M.Mamedov - Original Message - From: "Muhammed Mamedov" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, December 11, 2003 2:00 PM Subject: Re: [PHP-DB] SQL question > It should be as follows: > SELECT * FROM x_table WHERE name Like = "%part_of_name%" > > Hope this helps, > M.Mamedov > > - Original Message - > From: "Constantin Brinzoi" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Thursday, December 11, 2003 1:51 PM > Subject: [PHP-DB] SQL question > > > > I know it is possible to search a database like this: > > > > SELECT * FROM x_table WHERE name="%part_of_name%" > > > > but I don't know for sure the correct command. > > > > Could you tell me the right syntax? > > > > TIA > > Aurel. > > > > -- > > PHP Database Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > --- > Outgoing mail is certified Virus Free. > Checked by AVG anti-virus system (http://www.grisoft.com). > Version: 6.0.545 / Virus Database: 339 - Release Date: 27.11.2003 > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.545 / Virus Database: 339 - Release Date: 27.11.2003 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: SQL question
$query = "SELECT * FROM x_table WHERE name like '%part_of_name%' "; Constantin Brinzoi wrote: I know it is possible to search a database like this: SELECT * FROM x_table WHERE name="%part_of_name%" but I don't know for sure the correct command. Could you tell me the right syntax? TIA Aurel. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Root-Server Firebird PHP
Hello, I have a root-server (Suse 8.1, PHP 4.2.2) and i will use firebird (1.5) with php. I have install firebird and create my database with tables and data. It works (isql). In the first step i will use firebird with the interbase.so. I do this: ../configure --with-interbase=shared,/opt/firebird This is ok Then i do: make ... Making all in interbase make[2]: Entering directory `/usr/local/php4/php-4.2.2/ext/interbase' make[3]: Entering directory `/usr/local/php4/php-4.2.2/ext/interbase' /bin/sh /usr/local/php4/php-4.2.2/libtool --silent --mode=link gcc - I. -I/usr/local/php4/php-4.2.2/ext/interbase -I/usr/local/php4/php- 4.2.2/main -I/usr/local/php4/php-4.2.2 -I/usr/include/apache - I/usr/local/php4/php-4.2.2/Zend -I/opt/firebird/include - I/usr/local/php4/php-4.2.2/ext/mysql/libmysql -I/usr/local/php4/php- 4.2.2/ext/xml/expat -DEAPI_MM -D_LARGEFILE_SOURCE - D_FILE_OFFSET_BITS=64 -DHARD_SERVER_LIMIT=2048 - DDYNAMIC_MODULE_LIMIT=128 -DSSL_EXPERIMENTAL_PERDIRCA_IGNORE - DSSL_EXPERIMENTAL_PROXY_IGNORE -DLINUX=22 -DMOD_SSL=208110 -DEAPI - I/usr/local/php4/php-4.2.2/TSRM -g -O2 -o interbase.la -avoid- version -module -rpath /usr/local/php4/php-4.2.2/modules interbase.lo -R/opt/firebird/lib -L/opt/firebird/lib -lgds /usr/lib/gcc-lib/i486-suse-linux/3.2/../../../../i486-suse- linux/bin/ld: cannot find -lgds collect2: ld returned 1 exit status make[3]: *** [interbase.la] Error 1 make[3]: Leaving directory `/usr/local/php4/php-4.2.2/ext/interbase' make[2]: *** [all-recursive] Error 1 make[2]: Leaving directory `/usr/local/php4/php-4.2.2/ext/interbase' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/usr/local/php4/php-4.2.2/ext' make: *** [all-recursive] Error 1 i see an error, but i dont now what i must do. Can anybody help me? Thank you. Frank -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] array
Hi I have a variable cold $access and there are values 1,2,3,4,5 How can I check for example If ($access =='2'){ echo "go further"; } How can I make this work Thanx in advance -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: array
if($access ==2) { echo "do something"; } Peppe wrote: Hi I have a variable cold $access and there are values 1,2,3,4,5 How can I check for example If ($access =='2'){ echo "go further"; } How can I make this work Thanx in advance -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] array
Hi >From what I can work out you need to use a function called in_array(value,array); http://www.php.net/manual/en/function.in-array.php here is the php manual link Hope this is what you want Brett -Original Message- From: peppe [mailto:[EMAIL PROTECTED] Sent: 11 December 2003 16:07 To: [EMAIL PROTECTED] Subject: [PHP-DB] array Hi I have a variable cold $access and there are values 1,2,3,4,5 How can I check for example If ($access =='2'){ echo "go further"; } How can I make this work Thanx in advance -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Email has been scanned for viruses by www.emf-systems.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] array
Hi Pete I forgot to write that $acces is a field from Db and there are values 1,2,3,4 a need to split those values to make that IF Brettking thanx mate I think that is a solution "Brettking" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > Hi > > From what I can work out you need to use a function called > in_array(value,array); > http://www.php.net/manual/en/function.in-array.php here is the php manual > link > > Hope this is what you want > Brett > -Original Message- > From: peppe [mailto:[EMAIL PROTECTED] > Sent: 11 December 2003 16:07 > To: [EMAIL PROTECTED] > Subject: [PHP-DB] array > > > Hi > I have a variable cold $access and there are values 1,2,3,4,5 > How can I check for example > If ($access =='2'){ > echo "go further"; > } > How can I make this work > Thanx in advance > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > > Email has been scanned for viruses by www.emf-systems.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: array
Hi Pete I forgot to write that $acces is a field from Db and there are values 1,2,3,4 a need to split those values to make that IF Brettking I think that is solution "Peppe" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi > I have a variable cold $access and there are values 1,2,3,4,5 > How can I check for example > If ($access =='2'){ > echo "go further"; > } > How can I make this work > Thanx in advance -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Re: Very complex query
El Jue 11 Dic 2003 05:00, Muhammed Mamedov escribió: > You can also DISTINCT command instead. > UNIQUE command isnot supported by mySQL (at least at MySQL 3.23.41- I am > using) UNIQUE is for table creation or index creation. It is relevent for insertion, not selects. DISTINCT and DISTINCT ON() are used in SELECT statements. -- 15:49:01 up 15 days, 22:05, 3 users, load average: 1.12, 0.79, 0.61 - Martín Marqués| select 'mmarques' || '@' || 'unl.edu.ar' Centro de Telematica | DBA, Programador, Administrador Universidad Nacional del Litoral - -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Re: Very complex query
El Jue 11 Dic 2003 05:17, Mike U. Petrov escribió: > No, DISTINCT isn't match my purpose cause of it rerurns unique rows but I > need ONE user_id per one object_id. GROUP BY is your answer. -- 15:51:02 up 15 days, 22:07, 3 users, load average: 0.90, 0.75, 0.61 - Martín Marqués| select 'mmarques' || '@' || 'unl.edu.ar' Centro de Telematica | DBA, Programador, Administrador Universidad Nacional del Litoral - -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Re: Very complex query
El Jue 11 Dic 2003 05:30, Mike U. Petrov escribió: > I tried to use GROUP BY and it worked almost right but i need to return > user_id and mysql generated an error that notes.user_id isn't used in GROUP > BY... Add it to the GROUP BY. -- 16:33:02 up 15 days, 22:49, 4 users, load average: 0.03, 0.32, 0.46 - Martín Marqués| select 'mmarques' || '@' || 'unl.edu.ar' Centro de Telematica | DBA, Programador, Administrador Universidad Nacional del Litoral - -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Re: Very complex query
Martin Marques wrote: El Jue 11 Dic 2003 05:30, Mike U. Petrov escribió: I tried to use GROUP BY and it worked almost right but i need to return user_id and mysql generated an error that notes.user_id isn't used in GROUP BY... Add it to the GROUP BY. But he wants only one entry for user_id, not all of them. Adding it will negate the reason he's using it. -- paperCrane -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Grouping and ordering - tricky problem, suggestions welcome
Hi All - I have a query as below, which builds individual records from a series of 4 tables SELECT menuitems.tour_code, image_caption, image_code, region, country, product_type FROM tourcountries, tour_product, countries, menuitems LEFT OUTER JOIN image_ref ON image_ref.tour_code=menuitems.tour_code WHERE FIND_IN_SET('holiday',menuitems.types)>0 AND menuitems.tour_code=tour_product.product_code AND tour_product.id=tourcountries.holiday_id AND tourcountries.country_id=countries.country_id AND countries.country_id=1 GROUP BY tour_code"; This works as desired, returning one correctly formed result row with ancilliary information (caption, image, region etc), for each tour_product ID in my table. However I am unable to see a way to pick the minimum image_code value from the image_ref table. The LEFT OUTER JOINclause is necessary, because the table image_ref on which I do a contains between zero and many matching rows. I need to return only one row containing a product and a single image code, so I then use GROUP BY tour_code to reduce the rows to one. For this query, I wish to return the *minimum* value of image_code, and return all this as one row. Usually what I get back though is the last image_code, as a result of the GROUP BY clause As you might imagine, this is quite tricky but I'm trying to determine if it's impossible using a single query : What I intend to happen, is ORDER BY image_code ASC , *before* grouping (I know I can't do that !), so that the returned row contains the earliest possible image_code. Any suggestions if there are avenues I might explore here > ? Cheers all - Neil Smith. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Root-Server Firebird PHP
My own install worked OK with RC4, but it may be worth a look through the firebird-php list as there are a few other 'fixes' listed. http://groups.yahoo.com/group/firebird-php I've pressure to complete a W2k based job before Xmas otherwise I would be having another look myself. I'm sure we need an 'idiots guide' just to tidy this up :) Frank Kieselbach wrote: Hello, I have a root-server (Suse 8.1, PHP 4.2.2) and i will use firebird (1.5) with php. I have install firebird and create my database with tables and data. It works (isql). In the first step i will use firebird with the interbase.so. I do this: ../configure --with-interbase=shared,/opt/firebird This is ok Then i do: make ... Making all in interbase make[2]: Entering directory `/usr/local/php4/php-4.2.2/ext/interbase' make[3]: Entering directory `/usr/local/php4/php-4.2.2/ext/interbase' /bin/sh /usr/local/php4/php-4.2.2/libtool --silent --mode=link gcc - I. -I/usr/local/php4/php-4.2.2/ext/interbase -I/usr/local/php4/php- 4.2.2/main -I/usr/local/php4/php-4.2.2 -I/usr/include/apache - I/usr/local/php4/php-4.2.2/Zend -I/opt/firebird/include - I/usr/local/php4/php-4.2.2/ext/mysql/libmysql -I/usr/local/php4/php- 4.2.2/ext/xml/expat -DEAPI_MM -D_LARGEFILE_SOURCE - D_FILE_OFFSET_BITS=64 -DHARD_SERVER_LIMIT=2048 - DDYNAMIC_MODULE_LIMIT=128 -DSSL_EXPERIMENTAL_PERDIRCA_IGNORE - DSSL_EXPERIMENTAL_PROXY_IGNORE -DLINUX=22 -DMOD_SSL=208110 -DEAPI - I/usr/local/php4/php-4.2.2/TSRM -g -O2 -o interbase.la -avoid- version -module -rpath /usr/local/php4/php-4.2.2/modules interbase.lo -R/opt/firebird/lib -L/opt/firebird/lib -lgds /usr/lib/gcc-lib/i486-suse-linux/3.2/../../../../i486-suse- linux/bin/ld: cannot find -lgds collect2: ld returned 1 exit status make[3]: *** [interbase.la] Error 1 make[3]: Leaving directory `/usr/local/php4/php-4.2.2/ext/interbase' make[2]: *** [all-recursive] Error 1 make[2]: Leaving directory `/usr/local/php4/php-4.2.2/ext/interbase' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/usr/local/php4/php-4.2.2/ext' make: *** [all-recursive] Error 1 i see an error, but i dont now what i must do. Can anybody help me? Thank you. Frank -- Lester Caine - L.S.Caine Electronic Services -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] NEXTVAL Question
Does anyone know how to make this work??? $sql = "select TEAM_SEQ.NEXTVAL as \"nextval\" from sys.dual"; I get the following error in PHP: ociexecute(): OCIStmtExecute: ORA-00903: invalid table name But when I use my SQL tool to hit the DB will all the same parameters, it works just fine. I have also tried: $sql = "select TEAM_SEQ.NEXTVAL from sys.dual"; $sql = "select TEAM_SEQ.NEXTVAL from dual"; all with the same results. I am running Red Hat AS, PHP 4.3, OCI8 Functions and Oracle 9i. - Paul -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Cronjob
Hello all, I have a cronjob that runs a PHP script against MySQL. The script takes 5 minutes to process 4000 records (approximately 12 records per second). Here are the top two entries from top: PID USER PRI NI SIZE RSS SHARE STAT %CPU %MEM TIME CPU COMMAND 8671 mysql 25 0 20172 19M 2000 R97.8 3.9 2:02 0 mysqld 8670 appmgr15 0 2088 2088 1424 S 2.2 0.4 0:03 0 php Is there a way that I can slow down the script so mysqld does not bog the machine down. Here is a snippet of code. The function is called by the cronjob. function rank_mailbox_current($company_ID){ $query = "select app_ID from mailbox where company_ID = \"$company_ID\" and deleted_date = 0 order by mailbox.ID desc"; $result=query_database($query); while ($row = mysql_fetch_assoc($result)){ $app_ID = $row["app_ID"]; $rank_of_app=rank_app($app_ID,$company_ID); } } Server: P-IV 2.4GHz, 512 DDRAM, RedHat 9 PHP Version 4.3.1 MySQL 4.0.3 Thanks, Ryan -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Cronjob
Ryan Marks wrote: I have a cronjob that runs a PHP script against MySQL. The script takes 5 minutes to process 4000 records (approximately 12 records per second). Here are the top two entries from top: PID USER PRI NI SIZE RSS SHARE STAT %CPU %MEM TIME CPU COMMAND 8671 mysql 25 0 20172 19M 2000 R97.8 3.9 2:02 0 mysqld 8670 appmgr15 0 2088 2088 1424 S 2.2 0.4 0:03 0 php Is there a way that I can slow down the script so mysqld does not bog the machine down. Here is a snippet of code. The function is called by the cronjob. function rank_mailbox_current($company_ID){ $query = "select app_ID from mailbox where company_ID = \"$company_ID\" and deleted_date = 0 order by mailbox.ID desc"; $result=query_database($query); while ($row = mysql_fetch_assoc($result)){ $app_ID = $row["app_ID"]; $rank_of_app=rank_app($app_ID,$company_ID); } } Well, that snippet doesn't really show us much. Actually, unless there's a return() hidden in there somewhere, it's not actually doing anything but wasting time. What are you doing with the data? What is your table structure? Where are you indexes? Sounds like you have some nested queries or something... -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals – www.phparch.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] pg_result_error()
What good is this function? A quick example of the wall Im running into -> $sql = 'INSERT INTO .'; $result = pg_query($conn_id, $sql); if ($result === false) { var_dump( pg_result_error( $result ) ); } According to the manual, pg_result_error takes the result resource. If that resource is boolean false for one reason or another, then pg_result_error isn't useful. Anyone has any other ideas, besides using pg_last_error()? Thanks -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Need HELP with UPDATE & DELETE
Hi all, Right now I'm trying to do a UPDATE and DELETE queries using the following code below: But i kept getting error "Undefined variable: tutor_id in /usr/local/apache/htdocs/tutor/edit.php on line . Didn't I defined my variable "$tutor_id"I thought I have... Anyone can help??? Thanks in advance =) Below is a snip of my code : --- ===edit.php $dsn = "mysql://root:[EMAIL PROTECTED]/tb1"; $db = DB::connect ($dsn); if (DB::isError ($db)) die ($db->getMessage()); $action = $_GET["action"]; if($action == "delete") { $sql = mysql_query ("DELETE FROM tutor WHERE tutor_id='$tutor_id'"); } if($action == "edit") { $sql = mysql_query ("SELECT * FROM tutor WHERE tutor_id ='$tutor_id'");**ERROR HERE!!* $row = mysql_fetch_array($sql); echo ""; echo "Tutor ID : ".$row['tutor_id'].""; echo ""; echo "Name : "; echo "Contact No : "; echo "E-mail : "; echo "Profile : "; echo ""; echo ""; } ?> $result = $db->query($sql); if( DB::isError($result) ) { die ($result->getMessage()); } -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Shift_JIS Character Set
Hi, i've read the following comment on PHP.net and found it very troubling because my database has Shift_JIS japanese words and my forms allow japanese input as well, so, does anyone know how can I stripslashes correctly when it comes to Japanese text? thanx thanx! hash at samurai dot fm 01-Dec-2003 10:34 Might I warn readers that they should be vary careful with the use of stripslashes on Japanese text. The shift_jis character set includes a number of two-byte code charcters that contain the hex-value 0x5c (backslash) which will get stripped by this function thus garbling those characters. hh
Re: [PHP-DB] Shift_JIS Character Set
On Friday 12 December 2003 13:47, Ng Hwee Hwee wrote: > i've read the following comment on PHP.net and found it very troubling > because my database has Shift_JIS japanese words and my forms allow > japanese input as well, so, does anyone know how can I stripslashes > correctly when it comes to Japanese text? thanx thanx! Normally you would not need to use stripslashes() anyway. What are you trying to do? > hash at samurai dot fm > 01-Dec-2003 10:34 > Might I warn readers that they should be vary careful with the use of > stripslashes on Japanese text. The shift_jis character set includes a > number of two-byte code charcters that contain the hex-value 0x5c > (backslash) which will get stripped by this function thus garbling those > characters. -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-db -- /* I've never been drunk, but often I've been overserved. -- George Gobel */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Shift_JIS Character Set
thanks for your reply.. i'm doing a form (form.php) 1) user comes to form.php 2) user enters details and press submit 3) details get passed to form action verify.php 4) verify.php puts all the $_POST into an array $formVars 5) verify.php session_register("formVars") 6) if there is an error, verify.php sends user back to form.php 7) form.php echos all the $formVars (i.e. details that user has previously entered) in their respective textfields, together with the error messages i need to stripslashes at Step7 because as you have mentioned in a previous post on this list, magic_quotes_gpc added slashes to all my $_POST. Thus, since I need to echo them, I need to stripslashes.. I tried echoing the $formVars without the stripslashes and I see all the slashes before the quotes and backslashes etc.. so, by right, with English characters, i still need to stripslashes. please advice. thanx thanx! - Original Message - HH > i've read the following comment on PHP.net and found it very troubling HH > because my database has Shift_JIS japanese words and my forms allow HH > japanese input as well, so, does anyone know how can I stripslashes HH > correctly when it comes to Japanese text? thanx thanx! JW > Normally you would not need to use stripslashes() anyway. What are you trying JW > to do? HH > hash at samurai dot fm HH > 01-Dec-2003 10:34 HH > Might I warn readers that they should be vary careful with the use of HH > stripslashes on Japanese text. The shift_jis character set includes a HH > number of two-byte code charcters that contain the hex-value 0x5c HH > (backslash) which will get stripped by this function thus garbling those HH > characters.