Re: [PHP-DB] boolean instead of array
On Sun, 2002-11-03 at 01:44, Jason Wong wrote: On Sunday 03 November 2002 10:23, John Coder wrote: I seem to somehow get an boolean instead of an array from a mysql_fetch_row function and I have no idea how. Here's the code; Try adding some error checking into your code (see manual examples) and using mysql_error() to find out what's going. What error checking to insert into this code I'm clueless. I found out why I wasn't getting an array by inserting gettype and finding out it's a boolean type instead of array but past that checking out why It's boolean type I have no idea how to begin. John Coder -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] boolean instead of array
It's hard to tell which output is from which loop, you might be getting confused (if anything, you might be confusing anyone that might help)... the Boolean was probabally due to a bad result, for whatever reason (maybe your connect code was wrong? I'm not sure but I think you get a valid resource id even when your connection fails or you don't get any returs on your query), and the arrays were more than likely empty before if they didn't contain your results, because mysql_fetch_row returned an array of nulls (try looping through those arrays, and checking is_null on the values). I'll skip the lecture on naming conventions, especially the lengthy section about other people reading your code. Without seeing the rest of your script, or your talbe structure, you might want to try a LEFT JOIN in your query, that will preserve values that are null. You might also want to use mysql_fetch_array (or mysql_fetch_object), which I've always used, and never had a problem getting results from. I'd be nice to at least see your table structure, then I or anybody else here could give you a more precise answer. I'd suggest looking at the mysql manual entries for SUM, JOIN, LEFT JOIN, and the php manual entries for mysql_fetch_row, mysql_fetch_array, and mysql_query. Hope this is helpful! -- Josh -Original Message- From: John Coder [mailto:jcoder;insightbb.com] Sent: Saturday, November 02, 2002 9:23 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] boolean instead of array I seem to somehow get an boolean instead of an array from a mysql_fetch_row function and I have no idea how. Here's the code; ? snip $names=mysql_query(select name from dept join picdata where dept.deptid=picdata.deptid limit 5); print $names.p; //offending query snip $resets=mysql_query(select sum(reset) from Tmp group by deptid order by deptid limit 5); snip while($c=mysql_fetch_row($names)); { //$a[]=$c[0]; commented out for troubleshooting $y=gettype($c); print $y.P; } while($e=mysql_fetch_row($resets)) { $z=gettype($e); print $z.br; //$b[]=$e[0]; commented out for troubleshooting } Here's the output from a terminal: select name from dept join picdata where picdata.deptid=dept.deptid limit 5; +-+ | name| +-+ | BodyWatch | | BreakThroughGallery | | TempGallery | | KidZone | | Lobby | +-+ 5 rows in set (0.01 sec) here's the output from the browser: Resource id #3 boolean array array array array array Any suggestions as to what I'm doing wrong? John Coder -- 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] security check
Hi everyone, on my site I created a login which is supposed to be secure. I'm not familiar with how to surpass signups, but was wondering if people can see if they can get my page to view without signing up. The page that is supposed to be secured is the about me index. (the rest is still open). http://seabird.jmtech.ca Please report any other issues aswell. Jacco -- http://seabird.jmtech.ca Attitude is Everything! But Remember, Attitudes are Contagious! Is Yours worth Catching -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Generating readio buttons
Howdy -- How do I dynamically generate the value for radio buttons off the DB (MySQL) backend? Here's some code that almost works TIA, David - Almost works ?php $header = mysql_query (SELECT * FROM chart ORDER BY acct ); if ($row = mysql_fetch_array($header)) { do { print(tr bgcolor=\white\ ); print 'td width=5input type=radio name=gl_acct value=acct[]/td'; print(td width=\12\); print $row[acct]; print /tdtd width=\12\; print $row[cat]; print /tdtd ; print $row[descript]; print(/td/tr\n); } while($row = mysql_fetch_array($header)); } else {print Sorry, no records were found!;} ? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] LIKE statement
change your query to this: select count(distinct itemid) from business where name like 'word1 word2 word3%' or description like 'word1 word2 word3%'; Peter On 4 Nov 2002, Chris Barnes wrote: Hi, I've got a dilly of a problem. I'm probably doing something wrong but I don't know what. I'm trying to use the LIKE statement in a query where more than one word is used in with LIKE..e.g. select count(distinct itemid) from business where name or description like 'word1 word2 word3%' The problem I'm having is probably obvious to you but I don't know why this returns no matches but if i specify only 1 word in the LIKE statement then it returns a match. Am i not able to specify more than 1 word with LIKE or am I just doing it wrong? It has been designed to take input from a web form by the variable $search_string and then the query string is constructed from that e.g. $query = select count(distinct itemid) from business where name or description like' . $search_string . '; Any help or suggestions greatly appreciated. --- Peter BeckmanSystems Engineer, Fairfax Cable Access Corporation [EMAIL PROTECTED] http://www.purplecow.com/ --- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Generating readio buttons
Gonna need some additional information, such as: 1. The first three rows your query returns 2. The expected output 3. The actual problem and/or error. Peter On Sun, 3 Nov 2002, David Jackson wrote: Howdy -- How do I dynamically generate the value for radio buttons off the DB (MySQL) backend? Here's some code that almost works TIA, David - Almost works ?php $header = mysql_query (SELECT * FROM chart ORDER BY acct ); if ($row = mysql_fetch_array($header)) { do { print(tr bgcolor=\white\ ); print 'td width=5input type=radio name=gl_acct value=acct[]/td'; print(td width=\12\); print $row[acct]; print /tdtd width=\12\; print $row[cat]; print /tdtd ; print $row[descript]; print(/td/tr\n); } while($row = mysql_fetch_array($header)); } else {print Sorry, no records were found!;} ? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php --- Peter BeckmanSystems Engineer, Fairfax Cable Access Corporation [EMAIL PROTECTED] http://www.purplecow.com/ --- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: LIKE statement
Chris Barnes wrote: Hi, I've got a dilly of a problem. I'm probably doing something wrong but I don't know what. I'm trying to use the LIKE statement in a query where more than one word is used in with LIKE..e.g. select count(distinct itemid) from business where name or description like 'word1 word2 word3%' Chris -- The answer depends on what database you using? MySQL has a IN operator, so you might try: SELECT * from table WHERE name IN ('value1','value2','value3) OR WHERE description IN ('value1','value2','value3) Your might want to cross post to MySQL list. HTH, David The problem I'm having is probably obvious to you but I don't know why this returns no matches but if i specify only 1 word in the LIKE statement then it returns a match. Am i not able to specify more than 1 word with LIKE or am I just doing it wrong? It has been designed to take input from a web form by the variable $search_string and then the query string is constructed from that e.g. $query = select count(distinct itemid) from business where name or description like' . $search_string . '; Any help or suggestions greatly appreciated. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Generating readio buttons
Peter Beckman wrote: Peter, Thanks for your prompt reply. Gonna need some additional information, such as: 1. The first three rows your query returns 2. The expected output 3. The actual problem and/or error. What I'm trying todo is build a radio box form for the selection of ledger accounts for a account app. ( http://mustardandrelish.com/ledger) Query returns (from HTML table): input type=radio name=gl_acct value=acct[] input type=radio name=gl_acct value=acct[] input type=radio name=gl_acct value=acct[] Expected results might be: input type=radio name=gl_acct value=1000 input type=radio name=gl_acct value=2000 input type=radio name=gl_acct value=3000 And then gl_acct will be passed to the G/L entry screen (sticky forms?) TIA, David Peter On Sun, 3 Nov 2002, David Jackson wrote: Howdy -- How do I dynamically generate the value for radio buttons off the DB (MySQL) backend? Here's some code that almost works TIA, David - Almost works ?php $header = mysql_query (SELECT * FROM chart ORDER BY acct ); if ($row = mysql_fetch_array($header)) { do { print(tr bgcolor=\white\ ); print 'td width=5input type=radio name=gl_acct value=acct[]/td'; print(td width=\12\); print $row[acct]; print /tdtd width=\12\; print $row[cat]; print /tdtd ; print $row[descript]; print(/td/tr\n); } while($row = mysql_fetch_array($header)); } else {print Sorry, no records were found!;} ? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php --- Peter BeckmanSystems Engineer, Fairfax Cable Access Corporation [EMAIL PROTECTED] http://www.purplecow.com/ --- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] boolean instead of array
On Sunday 03 November 2002 20:58, John Coder wrote: Try adding some error checking into your code (see manual examples) and using mysql_error() to find out what's going. What error checking to insert into this code I'm clueless. I found out Again, have a look at the examples in the manual (the MySQL functions section). The example which starts the chapter shows quite explicitly how you should (i) establish a connection to the mysql server (ii) select a database to query (iii) perform a query (iv) display the results of the query And for good measure you should alter the die() statements to incorporate a mysql generated error message: die( . mysql_error()); Once you get that example working, you can modify (one step at a time) to suit your needs. -- Jason Wong - Gremlins Associates - www.gremlins.com.hk Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * /* Spock: The odds of surviving another attack are 13562190123 to 1, Captain. */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] mysql_connect problem rh7.3
Thanks! I was able to get native mysql support by adding extension=mysql.so to php.ini. So now mysql_connect() works John Coder wrote: While Micah is correct, you do have mysql support on php but as a dbs not the built in php fuctions. Therefore you must use the dbx functions instead. John Coder On Sat, 2002-11-02 at 14:35, Micah Stevens wrote: It doesn't appear you have the PHP MySQL functions installed. When you run phpinfo() you should get something like: mysql MySQL Supportenabled Active Persistent Links1 Active Links1 Client API version3.23.39 MYSQL_MODULE_TYPEbuiltin MYSQL_SOCKET/var/lib/mysql/mysql.sock MYSQL_INCLUDE MYSQL_LIBS The command I've always used for this during compile time is --with-mysql without any options. I'm not sure what =shared, /tmp does, but apparently it's not doing the trick. -Micah At 03:32 PM 11/2/2002 +0100, Wouter wrote: Hello, I've a rather complete php install on redhat 7.3, yet I cant't get php to connect to mysql. I get: Fatal error: Call to undefined function: mysql_connect() in ... It seems that the necessary packages are installed: [rootaxon ~]# rpm -qa | grep php php-4.1.2-7.3.4 php-mysql-4.1.2-7.3.4 asp2php-0.76.2-1 php-devel-4.1.2-7.3.4 php-ldap-4.1.2-7.3.4 php-imap-4.1.2-7.3.4 [rootaxon ~]# rpm -qa | gi mysql mysql-3.23.49-3 mysql-server-3.23.49-3 php-mysql-4.1.2-7.3.4 mysql-devel-3.23.49-3 mysqlclient9-3.23.22-6 I've attached the start of phpinfo() at the end... Any ideas? Maybe php.ini needs some change, but I can't figure which one.. Thanks, Wouter PHP Version 4.1.2 System Linux stripples.devel.redhat.com 2.4.18-11smp #1 SMP Thu Aug 15 06:41:59 EDT 2002 i686 unknown Build Date Aug 21 2002 Configure Command './configure' 'i386-redhat-linux' '--prefix=/usr' '--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc' '--datadir=/usr/share' '--includedir=/usr/include' '--libdir=/usr/lib' '--libexecdir=/usr/libexec' '--localstatedir=/var' '--sharedstatedir=/usr/com' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--prefix=/usr' '--with-config-file-path=/etc' '--enable-force-cgi-redirect' '--disable-debug' '--enable-pic' '--disable-rpath' '--enable-inline-optimization' '--with-bz2' '--with-db3' '--with-curl' '--with-dom=/usr' '--with-exec-dir=/usr/bin' '--with-freetype-dir=/usr' '--with-png-dir=/usr' '--with-gd' '--enable-gd-native-ttf' '--with-ttf' '--with-gdbm' '--with-gettext' '--with-ncurses' '--with-gmp' '--with-iconv' '--with-jpeg-dir=/usr' '--with-mm' '--with-openssl' '--with-png' '--with-pspell' '--with-regex=system' '--with-xml' '--with-expat-dir=/usr' '--with-zlib' '--with-layout=GNU' '--enable-bcmath' '--enable-debugger' '--enable-exif' '--enable-ftp' '--enable-magic-quotes' '--enable-safe-mode' '--enable-sockets' '--enable-sysvsem' '--enable-sysvshm' '--enable-discard-path' '--enable-track-vars' '--enable-trans-sid' '--enable-yp' '--enable-wddx' '--without-oci8' '--with-imap=shared' '--with-imap-ssl' '--with-kerberos=/usr/kerberos' '--with-ldap=shared' '--with-mysql=shared,/usr' '--with-pgsql=shared' '--with-snmp=shared,/usr' '--with-snmp=shared' '--enable-ucd-snmp-hack' '--with-unixODBC=shared' '--enable-memory-limit' '--enable-bcmath' '--enable-shmop' '--enable-versioning' '--enable-calendar' '--enable-dbx' '--enable-dio' '--enable-mbstring' '--enable-mbstr-enc-trans' '--with-apxs=/usr/sbin/apxs' snip dbx dbx support enabled dbx version 1.0.0 supported databases MySQLbr /ODBCbr /PostgreSQLbr /Microsoft SQL Serverbr /FrontBase -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Generating readio buttons
Here's your problem: acct[] doesn't equal anything. $acct[4] might. So: echo input type='radio' name='gl_acct' value='{$acct[4]}'; might give you want you want. The name='acct[]' is used for PHP form processing, putting the correct value in the variable. For example, $acct[Yes] might be set if you used this input and it was checked: input type='checkbox' name='acct[]' value='Yes' Peter On Sun, 3 Nov 2002, David Jackson wrote: Peter Beckman wrote: Peter, Thanks for your prompt reply. Gonna need some additional information, such as: 1. The first three rows your query returns 2. The expected output 3. The actual problem and/or error. What I'm trying todo is build a radio box form for the selection of ledger accounts for a account app. ( http://mustardandrelish.com/ledger) Query returns (from HTML table): input type=radio name=gl_acct value=acct[] input type=radio name=gl_acct value=acct[] input type=radio name=gl_acct value=acct[] Expected results might be: input type=radio name=gl_acct value=1000 input type=radio name=gl_acct value=2000 input type=radio name=gl_acct value=3000 And then gl_acct will be passed to the G/L entry screen (sticky forms?) TIA, David Peter On Sun, 3 Nov 2002, David Jackson wrote: Howdy -- How do I dynamically generate the value for radio buttons off the DB (MySQL) backend? Here's some code that almost works TIA, David - Almost works ?php $header = mysql_query (SELECT * FROM chart ORDER BY acct ); if ($row = mysql_fetch_array($header)) { do { print(tr bgcolor=\white\ ); print 'td width=5input type=radio name=gl_acct value=acct[]/td'; print(td width=\12\); print $row[acct]; print /tdtd width=\12\; print $row[cat]; print /tdtd ; print $row[descript]; print(/td/tr\n); } while($row = mysql_fetch_array($header)); } else {print Sorry, no records were found!;} ? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php --- Peter BeckmanSystems Engineer, Fairfax Cable Access Corporation [EMAIL PROTECTED] http://www.purplecow.com/ --- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php --- Peter BeckmanSystems Engineer, Fairfax Cable Access Corporation [EMAIL PROTECTED] http://www.purplecow.com/ --- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] LIKE statement or IN statement?
if you want to search for multiple words, u have to use multiple like operators: select count(distinct itemid) from business where name like 'word1' or name like 'word2' or name like 'word3'; or the IN statement with wildcards: select count(distinct itemid) from business where name IN ('%word1%','%word2%','%word3%'); -- im not too sure of this, would the experts please shed some more light on this one if its correct? Amit On 4 Nov 2002, Chris Barnes wrote: Hi, I've got a dilly of a problem. I'm probably doing something wrong but I don't know what. I'm trying to use the LIKE statement in a query where more than one word is used in with LIKE..e.g. select count(distinct itemid) from business where name or description like 'word1 word2 word3%' The problem I'm having is probably obvious to you but I don't know why this returns no matches but if i specify only 1 word in the LIKE statement then it returns a match. Am i not able to specify more than 1 word with LIKE or am I just doing it wrong? It has been designed to take input from a web form by the variable $search_string and then the query string is constructed from that e.g. $query = select count(distinct itemid) from business where name or description like' . $search_string . '; Any help or suggestions greatly appreciated. --- Peter BeckmanSystems Engineer, Fairfax Cable Access Corporation [EMAIL PROTECTED] http://www.purplecow.com/ --- -- 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] PHP Case Sensitivity
Hey all, I've had a bizarre experience. When I uploaded a php script it worked fine and when I was looking through my code I found that it shouldn't have worked because two variables had been used instead of one. What I'm meaning is, I used $Year and $year where I was just supposed to use $Year, the case insensitivity didn't seem to make a blind bit of difference. I've corrected it now and the script runs as it did previously. Did PHP just correct this at run time? Anyone know why this worked? Cheers, Graeme :) P.S. Seabird: I had a quick look at your site, it seems to work fine but I didn't look at it in any great depth. But so far so good ! -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] LIKE statement or IN statement?
Yeah I really need to search for multiple words. Can anyone confirm if the IN statement will work for me in this situation? On Mon, 2002-11-04 at 09:31, [EMAIL PROTECTED] wrote: if you want to search for multiple words, u have to use multiple like operators: select count(distinct itemid) from business where name like 'word1' or name like 'word2' or name like 'word3'; or the IN statement with wildcards: select count(distinct itemid) from business where name IN ('%word1%','%word2%','%word3%'); -- im not too sure of this, would the experts please shed some more light on this one if its correct? Amit On 4 Nov 2002, Chris Barnes wrote: Hi, I've got a dilly of a problem. I'm probably doing something wrong but I don't know what. I'm trying to use the LIKE statement in a query where more than one word is used in with LIKE..e.g. select count(distinct itemid) from business where name or description like 'word1 word2 word3%' The problem I'm having is probably obvious to you but I don't know why this returns no matches but if i specify only 1 word in the LIKE statement then it returns a match. Am i not able to specify more than 1 word with LIKE or am I just doing it wrong? It has been designed to take input from a web form by the variable $search_string and then the query string is constructed from that e.g. $query = select count(distinct itemid) from business where name or description like' . $search_string . '; Any help or suggestions greatly appreciated. --- Peter BeckmanSystems Engineer, Fairfax Cable Access Corporation [EMAIL PROTECTED] http://www.purplecow.com/ --- -- 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 signature.asc Description: This is a digitally signed message part
RE: [PHP-DB] LIKE statement or IN statement?
You can't use wildcards with IN, only with LIKE or regular expressions. ---John Holmes... -Original Message- From: [EMAIL PROTECTED] [mailto:Amit_Wadhwa;Dell.com] Sent: Sunday, November 03, 2002 5:31 PM To: [EMAIL PROTECTED] Subject: RE: [PHP-DB] LIKE statement or IN statement? if you want to search for multiple words, u have to use multiple like operators: select count(distinct itemid) from business where name like 'word1' or name like 'word2' or name like 'word3'; or the IN statement with wildcards: select count(distinct itemid) from business where name IN ('%word1%','%word2%','%word3%'); -- im not too sure of this, would the experts please shed some more light on this one if its correct? Amit On 4 Nov 2002, Chris Barnes wrote: Hi, I've got a dilly of a problem. I'm probably doing something wrong but I don't know what. I'm trying to use the LIKE statement in a query where more than one word is used in with LIKE..e.g. select count(distinct itemid) from business where name or description like 'word1 word2 word3%' The problem I'm having is probably obvious to you but I don't know why this returns no matches but if i specify only 1 word in the LIKE statement then it returns a match. Am i not able to specify more than 1 word with LIKE or am I just doing it wrong? It has been designed to take input from a web form by the variable $search_string and then the query string is constructed from that e.g. $query = select count(distinct itemid) from business where name or description like' . $search_string . '; Any help or suggestions greatly appreciated. --- Peter BeckmanSystems Engineer, Fairfax Cable Access Corporation [EMAIL PROTECTED] http://www.purplecow.com/ --- -- 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] LIKE statement or IN statement?
Chris Barnes wrote: Yeah I really need to search for multiple words. Can anyone confirm if the IN statement will work for me in this situation? Chris -- Why not just try it you self and let's us know. Also check to MySQL doc at http://mysql.org David On Mon, 2002-11-04 at 09:31, [EMAIL PROTECTED] wrote: if you want to search for multiple words, u have to use multiple like operators: select count(distinct itemid) from business where name like 'word1' or name like 'word2' or name like 'word3'; or the IN statement with wildcards: select count(distinct itemid) from business where name IN ('%word1%','%word2%','%word3%'); -- im not too sure of this, would the experts please shed some more light on this one if its correct? Amit On 4 Nov 2002, Chris Barnes wrote: Hi, I've got a dilly of a problem. I'm probably doing something wrong but I don't know what. I'm trying to use the LIKE statement in a query where more than one word is used in with LIKE..e.g. select count(distinct itemid) from business where name or description like 'word1 word2 word3%' The problem I'm having is probably obvious to you but I don't know why this returns no matches but if i specify only 1 word in the LIKE statement then it returns a match. Am i not able to specify more than 1 word with LIKE or am I just doing it wrong? It has been designed to take input from a web form by the variable $search_string and then the query string is constructed from that e.g. $query = select count(distinct itemid) from business where name or description like' . $search_string . '; Any help or suggestions greatly appreciated. --- Peter BeckmanSystems Engineer, Fairfax Cable Access Corporation [EMAIL PROTECTED] http://www.purplecow.com/ --- -- 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] Generating readio buttons
Peter Beckman wrote: Here's your problem: acct[] doesn't equal anything. $acct[4] might. So: echo input type='radio' name='gl_acct' value='{$acct[4]}'; Peter -- Thanks again for you help. I wonder if it's not a quoting issue on my part? How would I use the $row[column_name], in the above statement? Since it not a $_POST[] filed? Thanks in advance, David -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] LIKE statement or IN statement?
ok so you would have to use : --select count(distinct itemid) from business where name like 'word1' or name like 'word2' or name like 'word3'; no other go. .. You can't use wildcards with IN, only with LIKE or regular expressions. ---John Holmes... -Original Message- From: [EMAIL PROTECTED] [mailto:Amit_Wadhwa;Dell.com] Sent: Sunday, November 03, 2002 5:31 PM To: [EMAIL PROTECTED] Subject: RE: [PHP-DB] LIKE statement or IN statement? if you want to search for multiple words, u have to use multiple like operators: select count(distinct itemid) from business where name like 'word1' or name like 'word2' or name like 'word3'; or the IN statement with wildcards: select count(distinct itemid) from business where name IN ('%word1%','%word2%','%word3%'); -- im not too sure of this, would the experts please shed some more light on this one if its correct? Amit On 4 Nov 2002, Chris Barnes wrote: Hi, I've got a dilly of a problem. I'm probably doing something wrong but I don't know what. I'm trying to use the LIKE statement in a query where more than one word is used in with LIKE..e.g. select count(distinct itemid) from business where name or description like 'word1 word2 word3%' The problem I'm having is probably obvious to you but I don't know why this returns no matches but if i specify only 1 word in the LIKE statement then it returns a match. Am i not able to specify more than 1 word with LIKE or am I just doing it wrong? It has been designed to take input from a web form by the variable $search_string and then the query string is constructed from that e.g. $query = select count(distinct itemid) from business where name or description like' . $search_string . '; Any help or suggestions greatly appreciated. --- Peter BeckmanSystems Engineer, Fairfax Cable Access Corporation [EMAIL PROTECTED] http://www.purplecow.com/ --- -- 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] boolean instead of array
On Sun, 2002-11-03 at 15:01, Jason Wong wrote: On Sunday 03 November 2002 20:58, John Coder wrote: Try adding some error checking into your code (see manual examples) and using mysql_error() to find out what's going. What error checking to insert into this code I'm clueless. I found out Again, have a look at the examples in the manual (the MySQL functions section). The example which starts the chapter shows quite explicitly how you should (i) establish a connection to the mysql server (ii) select a database to query (iii) perform a query (iv) display the results of the query And for good measure you should alter the die() statements to incorporate a mysql generated error message: die( . mysql_error()); This all I have done and it generates no errors since it returns a value althogh a boolean type as opposed to Array. Out of 4 different queries this one is the one that returns a boolean. when I said I have no idea how to generate an error message I meant how to generate a error message concerning wrong type of return not no return. Sorry if I wasn't clear enough before. John Coder PS everything goes at it should without this query. it's actually shoes the same with or without the query. but this query is just to generate a list of names for a graph. the graph itself is generated but the names aren't -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] LIKE statement or IN statement?
ok so you would have to use : --select count(distinct itemid) from business where name like 'word1' or name like 'word2' or name like 'word3'; no other go. If you're not going to use wildcards, then you can use IN. The whole idea of using LIKE is that you can use _ and % as wildcards when searching. ---John Holmes... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Getting affected rows before executing query?
I keep forgetting where clauses. It's my dumbest mistake, and I always make it. I just lost the password of everyone on my site trying to change my own - not good. Anyway, I'm trying to edit PhpMyAdmin to warn if there's more than a certain number of affected rows for a query. Is there a way to tell number of affected rows before executing the query? -- The above message is encrypted with double rot13 encoding. Any unauthorized attempt to decrypt it will be prosecuted to the full extent of the law. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] error messages to variables
You can suppress the error message on failure by prepending a http://www.php.net/manual/en/language.operators.errorcontrol.php to the function name.. How can you get the error string into a local variable? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Connecting to DB on separate server?
I have a php page on server #1 trying to access a database on server #2. What do I put in the following blanks: $hostname: ___ (have tried IP, http, localhost, nothing works) $username: blah $password: blah $database: _ $link=mysql_connect($hostname, $user, $pass) or die(Failure to communicate with database); $close=mysql_select_db($database, $link); All I get is the Failure to communicate. message. Server #1: ellerweb.eller.arizona.edu Server #2: datamonster.sbs.arizona.edu $database is cassy, but do I need to add anything to that? I've tried asking two people who are really good at this and they have no answers. THANK YOU IN ADVANCE! Cassy Rowe -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Connecting to DB on separate server?
Cassy M Rowe wrote: I have a php page on server #1 trying to access a database on server #2. What do I put in the following blanks: $hostname: ___ (have tried IP, http, localhost, nothing works) $username: blah $password: blah $database: _ $link=mysql_connect($hostname, $user, $pass) or die(Failure to communicate with database); $close=mysql_select_db($database, $link); All I get is the Failure to communicate. message. Server #1: ellerweb.eller.arizona.edu Server #2: datamonster.sbs.arizona.edu $database is cassy, but do I need to add anything to that? I've tried asking two people who are really good at this and they have no answers. THANK YOU IN ADVANCE! Cassy Rowe Maybe you have to specify the port of the database on the remote machine. Maybe the MySQL daemon is not running? -- From Mozilla and GNU/Linux -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Generating readio buttons
OK, this works but there has to be a pretty way? David - Works - html headtitleOperation Sticky Bun/title/head body h3 align=centerOperation Sticky Bun /h3 ?php require('connect.php'); ? ?php print 'form action=hello.php method=post'; $header = mysql_query (SELECT * FROM chart ORDER BY acct ); if ($row = mysql_fetch_array($header)) { do { print 'input type=radio name=ledger_acct value='; print $row[acct];print ''; print $row[descript];print 'br'; } while($row = mysql_fetch_array($header)); } else {print Sorry, no records were found!;} print '/form'; ? /body /html -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Check If Table Exists
How do I check to see if a table exists?
Re: [PHP-DB] error messages to variables
On Monday 04 November 2002 12:10, Bob Lockie wrote: You can suppress the error message on failure by prepending a http://www.php.net/manual/en/language.operators.errorcontrol.php to the function name.. How can you get the error string into a local variable? Look at the track_errors setting in php.ini. -- Jason Wong - Gremlins Associates - www.gremlins.com.hk Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * /* I can't stand squealers; hit that guy. -- Albert Anastasia */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Check If Table Exists
RTFM?
Re: [PHP-DB] Getting affected rows before executing query?
On Monday 04 November 2002 10:47, Leif K-Brooks wrote: I keep forgetting where clauses. It's my dumbest mistake, and I always make it. I just lost the password of everyone on my site trying to change my own - not good. Anyway, I'm trying to edit PhpMyAdmin to warn if there's more than a certain number of affected rows for a query. Is there a way to tell number of affected rows before executing the query? AFAIK there isn't. What you can do are: 1) Get into the habit of writing WHERE clauses. 2) Write SELECT queries instead, once you're sure you've got it right change it to a DELETE query. 3) Backup your database/tables before doing anything drastic. -- Jason Wong - Gremlins Associates - www.gremlins.com.hk Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * /* Art is a jealous mistress. -- Ralph Waldo Emerson */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] PHP Case Sensitivity
On Monday 04 November 2002 07:25, Graeme McLaren wrote: Hey all, I've had a bizarre experience. When I uploaded a php script it worked fine and when I was looking through my code I found that it shouldn't have worked because two variables had been used instead of one. What I'm meaning is, I used $Year and $year where I was just supposed to use $Year, the case insensitivity didn't seem to make a blind bit of difference. I've corrected it now and the script runs as it did previously. Did PHP just correct this at run time? Anyone know why this worked? PHP is case-sensitive for variables. There are two possibilities: 1) Your code is buggy 2) PHP is buggy I suspect it's the former :) but if you think it's the latter then post your code here. -- Jason Wong - Gremlins Associates - www.gremlins.com.hk Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * /* One big pile is better than two little piles. -- Arlo Guthrie */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php