[PHP-DB] GROUP BY MONTH(DateBilled) misses an entry consistently
Hello I've got the following SQL Query, which consistently pulls up only 3 out of 4 months from the database: $sql = SELECT COUNT(DateBilled) AS count, MONTH(DateBilled) AS BilledMonth, YEAR(DateBilled) AS BilledYear FROM Invoices GROUP BY MONTH(DateBilled) ORDER BY DateBilled ASC; This results in: Month: November Number of Invoices: 17 Month: December Number of Invoices: 22 Month: January Number of Invoices: 15 But when I do change the order of the query from ASC to DESC like this: $sql = SELECT COUNT(DateBilled) AS count, MONTH(DateBilled) AS BilledMonth, YEAR(DateBilled) AS BilledYear FROM Invoices GROUP BY MONTH(DateBilled) ORDER BY DateBilled ASC;$sql = SELECT COUNT(DateBilled) AS count, MONTH(DateBilled) AS BilledMonth, YEAR(DateBilled) AS BilledYear FROM Invoices GROUP BY MONTH(DateBilled) ORDER BY DateBilled DESC; I get: Month: December Number of Invoices: 22 Month: November Number of Invoices: 17 Month: October Number of Invoices: 21 (I gained October and Lost January) The date format in the DB is like this: 2001-12-05 I've tried a whole stack of variations on the above query, but I still seem to be coming up one short. Any idea why I'm not getting a display of all of the months? Thanks. Mike -- Mike Gifford, OpenConcept Consulting, http://www.openconcept.ca Supporting progressive organizations in online campaigns and tools. Feature: Women's Learning Partnership http://learningpartnership.org Truth is that which confirms what we already believe. Northrop Frye -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP-DB] MySQL Result Resource
shouldn't it be PASSWORD('madonna') ?? -Original Message- From: Necro [mailto:[EMAIL PROTECTED]] Sent: 11 January 2002 04:39 To: [EMAIL PROTECTED] Subject: RE: [PHP-DB] MySQL Result Resource http://www.hotscripts.com/Detailed/4219.html --- that is the script But I cannot use crypt() on a winodws system. So I tried MD5, now I try PASSWORD. Any one got any idea how to make the script work with either of those?? Andrew -Original Message- From: Necro [mailto:[EMAIL PROTECTED]] Sent: Friday, 11 January 2002 3:30 PM To: [EMAIL PROTECTED] Subject: RE: [PHP-DB] MySQL Result Resource Daniel, I had tried both with and without quotes. Neither work. Without quotes I get: select password, 1 as auth from acl where username='andrewd' and password = PASSWORD(madonna)1054 : Unknown column 'madonna' in 'where clause' Notice that madonna has not been crypted by the PASSWORD call either. Andrew -Original Message- From: Daniel Barton [mailto:[EMAIL PROTECTED]] Sent: Friday, 11 January 2002 2:40 PM To: Necro Cc: [EMAIL PROTECTED] Subject: Re: [PHP-DB] MySQL Result Resource Andrew: Don't put quotes around your MySQL function call. i.e. PASSWORD($password) not 'PASSWORD($password)' p.s. Looking at this thread, it seems like most of the errors you're encountering have nothing to do with md5() or password(), but with syntax, like placement of quotes, or whether they are single quotes or double quotes. I would suggest experimenting with the syntax a bit, to check out what's kosher, and what's not? Check out the PHP manual's sections on 'Resource id's - I think you may find it to be very important to understanding how PHP interacts with databases. Resource ids, which are returned by quite a few function calls, are not classic variables - they need to be manipulated or interpreted before you use them. Cheers, db Necro wrote: Ok, I have tried to go to PASSWORD after none of the suggestions worked out. The current statement is: $arg = select password, 1 as auth from acl where username='$username' and password = 'PASSWORD($password)'; But the error I get now is: select password, 1 as auth from acl where username='andrewd' and password = 'PASSWORD(madonna)'Resource id #2 Any ideas? Andrew -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Friday, 11 January 2002 8:56 AM To: Necro; [EMAIL PROTECTED] Subject: RE: [PHP-DB] MySQL Result Resource Addressed to: Necro [EMAIL PROTECTED] [EMAIL PROTECTED] ** Reply to note from Necro [EMAIL PROTECTED] Fri, 11 Jan 2002 03:41:43 +1100 select password, 1 as auth from acl where (username='andrewd' and password=(163e06103a371fd95b21b4a849bb4b91))1064 : You have an error in your SQL syntax near 'a371fd95b21b4a849bb4b91))' at line 1 Does that help give any idea at all as to what the problem is? There are no quotes around 163e06103a371fd95b21b4a849bb4b91 The error occurs where it does because '163e06103' is a valid exponential notation value for a nubmer, but having an 'a' follow it is not valid. My solution would be: $Pass = md5( whatever ); # I don't care if you hash just the password # or the username and password as long as # you do it the same way as you entered # the passwords. mysql_query( SELECT password, 1 AS auth . FROM acl . WHERE username = '$username' . AND password = '$Pass' ); But I question what you are doing returning password, so it might work as well as: mysql_query( SELECT count(*) as Authorized . FROM acl . WHERE username = '$username' . AND password = '$Pass' ); This returns 0 or 1 in a field named Authorized depending on if the password matches or not. You might also want to look at the MySQL PASSWORD() function and not mess with md5 at all. Rick Rick Widmer Internet Marketing Specialists http://www.developersdesk.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP 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] -- -- Dan Barton Terrestrial Program Biologist Asst. Data Manager Point Reyes Bird Observatory http://www.prbo.org [EMAIL PROTECTED] [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL
Re: [PHP-DB] GROUP BY MONTH(DateBilled) misses an entry consistently
Mike, Have you posted all of the relevant code - for example, how the 'result' is limited to three month's worth of data??? Have you extracted the SQL from the PHP and applied it directly to the command line or used it in a MySQL Management package? Was the result any different? Please advise, =dn - Original Message - From: Mike Gifford [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: 11 January 2002 08:12 Subject: [PHP-DB] GROUP BY MONTH(DateBilled) misses an entry consistently Hello I've got the following SQL Query, which consistently pulls up only 3 out of 4 months from the database: $sql = SELECT COUNT(DateBilled) AS count, MONTH(DateBilled) AS BilledMonth, YEAR(DateBilled) AS BilledYear FROM Invoices GROUP BY MONTH(DateBilled) ORDER BY DateBilled ASC; This results in: Month: November Number of Invoices: 17 Month: December Number of Invoices: 22 Month: January Number of Invoices: 15 But when I do change the order of the query from ASC to DESC like this: $sql = SELECT COUNT(DateBilled) AS count, MONTH(DateBilled) AS BilledMonth, YEAR(DateBilled) AS BilledYear FROM Invoices GROUP BY MONTH(DateBilled) ORDER BY DateBilled ASC;$sql = SELECT COUNT(DateBilled) AS count, MONTH(DateBilled) AS BilledMonth, YEAR(DateBilled) AS BilledYear FROM Invoices GROUP BY MONTH(DateBilled) ORDER BY DateBilled DESC; I get: Month: December Number of Invoices: 22 Month: November Number of Invoices: 17 Month: October Number of Invoices: 21 (I gained October and Lost January) The date format in the DB is like this: 2001-12-05 I've tried a whole stack of variations on the above query, but I still seem to be coming up one short. Any idea why I'm not getting a display of all of the months? Thanks. Mike -- Mike Gifford, OpenConcept Consulting, http://www.openconcept.ca Supporting progressive organizations in online campaigns and tools. Feature: Women's Learning Partnership http://learningpartnership.org Truth is that which confirms what we already believe. Northrop Frye -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] PHP blocks
ones like phpnuke, myphpnuke, postnuke etc - Original Message - From: olinux [EMAIL PROTECTED] To: Barry Rumsey [EMAIL PROTECTED] Sent: Friday, January 11, 2002 7:26 PM Subject: Re: [PHP-DB] PHP blocks What portals? olinux --- Barry Rumsey [EMAIL PROTECTED] wrote: On these web portals they have things call blocks that arrange the layout of the site. Where can one go to learn how to do this sort of layout. __ Do You Yahoo!? Send FREE video emails in Yahoo! Mail! http://promo.yahoo.com/videomail/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] Create Table from a file in php
Hi All I want to create a table from a file that contains the sql to create the table. I have checked Mysql.com and have seen how to do it from telnet, but i want to do it from a php script. Can anyone please help. Thanks in Advance Dave C The two rules for success are: 1. Never tell them everything you know. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP-DB] PHP4 + ODBC Openlink +ORACLE 8.1 on DIGITAL
Hi Christian, Could you please open a support case at www.openlinksw.com/support/suppindx.htm? Best regards, Andrew Hill Director of Technology Evangelism OpenLink Software http://www.openlinksw.com Universal Data Access Data Integration Technology Providers -Original Message- From: Javalina [mailto:[EMAIL PROTECTED]] Sent: Friday, January 04, 2002 10:42 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] PHP4 + ODBC Openlink +ORACLE 8.1 on DIGITAL Hi to all...i have a problem when i try to connect from php to the oracle 8.1 on a DIGITAL ALPHA MAchine.. i did use openlink , when i try the connection with the SQL aplication test of the OPENLINK driver , function OK...the debug of this query is. oplrqb: 192.168.99.106 called (192.168.99.106.1201) oplrqb: request: domain=Oracle 8.1.x database= serveropts= oplrqb: connectopts= user=system opsys=unix readonly=0 oplrqb: application=www_sv processid=10770 oplrqb: solve mapping: ora81::insecure:other:192.168.99.106:www_sv:rw oplrqb: using mapping: ora81:*:*:*:*:*:* oplrqb: using [generic_ora81] ServerProgram=ora81_mv oplrqb: connect params: domain=Oracle 8.1.x db= serveropts= readonly=0 oplrqb: connectopts= user=system opsys=unix machine=192.168.99.106 application=www_sv oplrqb: spawning /usr/local/openlink/bin/ora81_mv generic_ora81 +debug oplrqb: asking agent for server handle oplrqb: setting Environment ORACLE81 oplrqb: change environment 'ORACLE_HOME' - '/usr/OraHome1' oplrqb: change environment 'ORACLE_SID' - 'Base3' oplrqb: change environment 'SHOW_REMARKS' - 'N' oplrqb: change environment 'CURSOR_SENSITIVITY' - 'LOW' oplrqb: change environment 'LD_LIBRARY_PATH' - '/usr/OraHome1/lib' oplrqb: change environment 'LIBPATH' - '/usr/OraHome1/lib' oplrqb: change environment 'SHLIB_PATH' - '/usr/OraHome1/lib' generic_ora81: server starting oplrqb: got it! oplrqb: asking agent for connection handle oplrqb: got it! oplrqb: accepted [EMAIL PROTECTED] oplrqb: unmap [EMAIL PROTECTED] oplrqb: killing generic_ora81 agent (pid=4627) generic_ora81: got SIGTERM generic_ora81: server shutting down oplrqb: pid 4627 died with exit code 0 oplrqb: agent died (pid=4627) oplrqb: removing agent generic_ora81 with 0 connections the debug of the PHP4 query ,is oplrqb: 192.168.99.106 called (192.168.99.106.1199) oplrqb: request: domain=Oracle 8.1.x database= serveropts= oplrqb: connectopts= user=system opsys=unix readonly=0 oplrqb: application= processid=10751 oplrqb: solve mapping: ora81::insecure:other:192.168.99.106::rw oplrqb: using mapping: ora81:*:*:*:*:*:* oplrqb: using [generic_ora81] ServerProgram=ora81_mv oplrqb: connect params: domain=Oracle 8.1.x db= serveropts= readonly=0 oplrqb: connectopts= user=system opsys=unix machine=192.168.99.106 application= oplrqb: spawning /usr/local/openlink/bin/ora81_mv generic_ora81 +debug oplrqb: asking agent for server handle oplrqb: setting Environment ORACLE81 oplrqb: change environment 'ORACLE_HOME' - '/usr/OraHome1' oplrqb: change environment 'ORACLE_SID' - 'Base3' oplrqb: change environment 'SHOW_REMARKS' - 'N' oplrqb: change environment 'CURSOR_SENSITIVITY' - 'LOW' oplrqb: change environment 'LD_LIBRARY_PATH' - '/usr/OraHome1/lib' oplrqb: change environment 'LIBPATH' - '/usr/OraHome1/lib' oplrqb: change environment 'SHLIB_PATH' - '/usr/OraHome1/lib' generic_ora81: server starting oplrqb: got it! oplrqb: asking agent for connection handle oplrqb: got it! oplrqb: accepted [EMAIL PROTECTED] oplrqb: aborted [EMAIL PROTECTED] generic_ora81: got SIGTERM generic_ora81: server shutting down oplrqb: pid 4616 died with exit code 0 oplrqb: agent died (pid=4616) oplrqb: removing agent generic_ora81 with 0 connections if you saww the only diference is when i try to connect with PHP don't send the www_sv option with the IP of request... the output of the PHP page is Warning: SQL error: [iODBC][Driver Manager]Connection in use, SQL state 08002 in SQLConnect in /usr/local/apache/htdocs/prueba_odbc.php on line 16 the line the is when i try to connect with this code. ? /* some environment variables, you can test to comment them out to see if things * still work. */ putenv(LD_LIBRARY_PATH=/usr/local/openlink/lib:/usr/app/oracle/pr oduct/8.1.7/lib); putenv(UDBCINI=/usr/local/openlink/bin/udbc.ini); putenv(ODBCINI=/usr/local/openlink/bin/odbc.ini); putenv(DebugFile=/tmp/udbc.out);// debug trace output $dsn=ORACLE;// note 'DSN=' is required $user=system; $password=Admtas; $sql=select * from prueba519; $conn_id=odbc_connect($dsn,$user,$password); odbc_close($conn_id); ? thsnk's to all. Cristian -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For
Re: [PHP-DB] GROUP BY MONTH(DateBilled) misses an entry consistently
Hello, Thanks for your quick reply.. I'm trying to improve the stats feature for gcdb (a pretty decent little PHP/MySQL accounting package on SF.net) On Fri, 2002-01-11 at 05:24, DL Neil wrote: Have you posted all of the relevant code - for example, how the 'result' is limited to three month's worth of data??? I didn't provide all of the code in the initial response as it was using a wrapper so I didn't know how relevant it would be.. However, your note made me realize that I could rewrite the code without the wrapper.. It still worked the same way. The code stands as: $sql = SELECT COUNT(DateBilled) AS count, MONTH(DateBilled) AS BilledMonth, YEAR(DateBilled) AS BilledYear FROM Invoices GROUP BY MONTH(DateBilled) ORDER BY DateBilled DESC; $monthly_result = mysql_query($sql, $db); $monthly_row = DBfetch_array($monthly_result); while($monthly_row = mysql_fetch_array($monthly_result)) { ++$i; $InvMonth[$i] = $monthly_row[BilledMonth]; $InvCount[$i] = $monthly_row[count]; echo strongMonth: . date (F, mktime(0,0,0,$InvMonth[$i],1,2002)) . !-- ($InvMonth) -- Number of Invoices: . $InvCount[$i] . /strongbr; } RESULTS: Month: December Number of Invoices: 22 Month: November Number of Invoices: 17 Month: October Number of Invoices: 21 Have you extracted the SQL from the PHP and applied it directly to the command line or used it in a MySQL Management package? Was the result any different? Also a damn good idea (I haven't had root access to MySQL until recently, hadn't thought of that either) mysql SELECT COUNT(DateBilled) AS count, MONTH(DateBilled) AS BilledMonth, YEAR(DateBilled) AS BilledYear FROM Invoices GROUP BY MONTH(DateBilled) ORDER BY DateBilled DESC; +---+-++ | count | BilledMonth | BilledYear | +---+-++ |15 | 1 | 2002 | |22 | 12 | 2001 | |17 | 11 | 2001 | |21 | 10 | 2001 | +---+-++ 4 rows in set (0.00 sec) Ok.. So the problem seems to be with my code.. $sql = SELECT COUNT(DateBilled) AS count, MONTH(DateBilled) AS BilledMonth, YEAR(DateBilled) AS BilledYear FROM Invoices GROUP BY MONTH(DateBilled) ORDER BY DateBilled ASC; $monthly_result = mysql_query($sql, $db); $monthly_row = DBfetch_array($monthly_result); $i=0; while($monthly_row = mysql_fetch_array($monthly_result)) { $InvMonth[$i] = $monthly_row[BilledMonth]; $InvCount[$i] = $monthly_row[count]; echo strongMonth: . date (F, mktime(0,0,0,$InvMonth[$i],1,2002)) . !-- ($InvMonth) -- Number of Invoices: . $InvCount[$i] . /strongbr; ++$i; } RESULTS: Month: November Number of Invoices: 17 Month: December Number of Invoices: 22 Month: January Number of Invoices: 15 I can't see the bug in the PHP I've got, but there certainly must be one.. Any suggestions would be appreciated! Mike - Original Message - From: Mike Gifford [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: 11 January 2002 08:12 Subject: [PHP-DB] GROUP BY MONTH(DateBilled) misses an entry consistently Hello I've got the following SQL Query, which consistently pulls up only 3 out of 4 months from the database: $sql = SELECT COUNT(DateBilled) AS count, MONTH(DateBilled) AS BilledMonth, YEAR(DateBilled) AS BilledYear FROM Invoices GROUP BY MONTH(DateBilled) ORDER BY DateBilled ASC; This results in: Month: November Number of Invoices: 17 Month: December Number of Invoices: 22 Month: January Number of Invoices: 15 But when I do change the order of the query from ASC to DESC like this: $sql = SELECT COUNT(DateBilled) AS count, MONTH(DateBilled) AS BilledMonth, YEAR(DateBilled) AS BilledYear FROM Invoices GROUP BY MONTH(DateBilled) ORDER BY DateBilled ASC;$sql = SELECT COUNT(DateBilled) AS count, MONTH(DateBilled) AS BilledMonth, YEAR(DateBilled) AS BilledYear FROM Invoices GROUP BY MONTH(DateBilled) ORDER BY DateBilled DESC; I get: Month: December Number of Invoices: 22 Month: November Number of Invoices: 17 Month: October Number of Invoices: 21 (I gained October and Lost January) The date format in the DB is like this: 2001-12-05 I've tried a whole stack of variations on the above query, but I still seem to be coming up one short. Any idea why I'm not getting a display of all of the months? Thanks. Mike -- Mike Gifford, OpenConcept Consulting, http://www.openconcept.ca Supporting progressive organizations in online campaigns and tools. Feature: Women's Learning Partnership http://learningpartnership.org Truth is that which confirms what we already believe. Northrop Frye -- 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] -- Mike
[PHP-DB] Copying a MySQL Table
How does one copy a Mysql table? I poked around on the mysql site and found conventions for renaming one, but nothing for duplicating a table (to a new table with a different name). Thanks, -Mike -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] GROUP BY MONTH(DateBilled) misses an entry consistently
On Saturday 12 January 2002 00:20, Mike Gifford wrote: Hello, Thanks for your quick reply.. I'm trying to improve the stats feature for gcdb (a pretty decent little PHP/MySQL accounting package on SF.net) On Fri, 2002-01-11 at 05:24, DL Neil wrote: Have you posted all of the relevant code - for example, how the 'result' is limited to three month's worth of data??? I didn't provide all of the code in the initial response as it was using a wrapper so I didn't know how relevant it would be.. However, your note made me realize that I could rewrite the code without the wrapper.. It still worked the same way. The code stands as: $sql = SELECT COUNT(DateBilled) AS count, MONTH(DateBilled) AS BilledMonth, YEAR(DateBilled) AS BilledYear FROM Invoices GROUP BY MONTH(DateBilled) ORDER BY DateBilled DESC; $monthly_result = mysql_query($sql, $db); $monthly_row = DBfetch_array($monthly_result); You've already used the first row of results (without processing it). -- Jason Wong - Gremlins Associates - www.gremlins.com.hk /* I'd love to go out with you, but I did my own thing and now I've got to undo it. */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] RE: display text in screen
Just add echo statments at whatever steps you want to display comment or detail for; something like: html headtitleSome page/title/head body ? echo Connecting to database: ; $dbconnection = @mysql_connect(localhost,username,password); if($dbconnection !== false){ echo OK; }else{ echo FAILEDbr; echo mysql_error(); echo /body/html; exit; } echo brSelecting database 'foo': ; if(@mysql_select_db(foo, $dbconnection)){ echo OK; }else{ echo FAILEDbr; echo mysql_error($dbconnection); echo /body/html; exit; } //Et cetera... ? /body /html If you're doing this within an HTML table it could get tricky because you would need to close the table structure after an error, but otherwise it's pretty straightforward. It can be really helpful for debugging and making sure a script is working correctly! -Andy -Original Message- From: Sommai Fongnamthip [mailto:[EMAIL PROTECTED]] Subject: display text in screen Hi, I have easy problem to ask someone. I wrote PHP to update data with many step and need to display comment or detail in each step. But I got all comment or detail display after it finished update all step. How could I display each step comment immediately?? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Create Table from a file in php
I don't know how you would do it from a file off the top of my head, so let's invent it, in pseudocode, anyway. The important thing to remember is that all of the commands to create or alter tables / databases are SQL queries. So the mysql_query() function is used to do most of the work. Assumptions: We have the database We have a connection to it We have the proper user/password for creation rights. We have a file with the necessary SQL to create a tablle : CREATE TABLE . etc., with no trailing semi-colon. pseudo code .. Open the file get the file handle Read it all as one chunk, assigning it to a variable, say $sql. If the SQL is broken into lines the file will have to be read and concatenated to the variable. Use the variable in a mysql_query, testing for success. Issue a mysql_list_tables to see that you have the new tables, if that's successful a list_fields for the new table. Refinements . things to check ... 1. Maybe check for the existence of the table and drop it before you create it. That can be done as a mysql_query. 2. You may need to add an opening double-quote and a closing double-quote to what you are assigning to $sql. Offhand, I think not. Alternate approach, although you probably don't have the necessary permission on the server would be to exec( mysql database_name file_containing_table_creation_code); I hope you find this helpful - Miles Thompson At 10:57 AM 1/11/2002 +, Dave Carrera wrote: Hi All I want to create a table from a file that contains the sql to create the table. I have checked Mysql.com and have seen how to do it from telnet, but i want to do it from a php script. Can anyone please help. Thanks in Advance Dave C The two rules for success are: 1. Never tell them everything you know. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] GROUP BY MONTH(DateBilled) misses an entry consistently
It may have been obvious to many, but I stumbled across the solution (eventually).. Changing the while statement to a do statement did the trick: $sql = SELECT COUNT(DateBilled) AS count, MONTH(DateBilled) AS BilledMonth, YEAR(DateBilled) AS BilledYear FROM Invoices GROUP BY MONTH(DateBilled) ORDER BY DateBilled DESC; $monthly_result = mysql_query($sql, $db); $monthly_row = DBfetch_array($monthly_result); $i=0; do { $InvMonth[$i] = $monthly_row[BilledMonth]; $InvCount[$i] = $monthly_row[count]; echo strongMonth: . date (F, mktime(0,0,0,$InvMonth[$i],1,2002)) . !-- ($InvMonth) -- Number of Invoices: . $InvCount[$i] . /strongbr; ++$i; } while($monthly_row = mysql_fetch_array($monthly_result)); On Fri, 2002-01-11 at 11:20, Mike Gifford wrote: Hello, Thanks for your quick reply.. I'm trying to improve the stats feature for gcdb (a pretty decent little PHP/MySQL accounting package on SF.net) On Fri, 2002-01-11 at 05:24, DL Neil wrote: Have you posted all of the relevant code - for example, how the 'result' is limited to three month's worth of data??? I didn't provide all of the code in the initial response as it was using a wrapper so I didn't know how relevant it would be.. However, your note made me realize that I could rewrite the code without the wrapper.. It still worked the same way. The code stands as: $sql = SELECT COUNT(DateBilled) AS count, MONTH(DateBilled) AS BilledMonth, YEAR(DateBilled) AS BilledYear FROM Invoices GROUP BY MONTH(DateBilled) ORDER BY DateBilled DESC; $monthly_result = mysql_query($sql, $db); $monthly_row = DBfetch_array($monthly_result); while($monthly_row = mysql_fetch_array($monthly_result)) { ++$i; $InvMonth[$i] = $monthly_row[BilledMonth]; $InvCount[$i] = $monthly_row[count]; echo strongMonth: . date (F, mktime(0,0,0,$InvMonth[$i],1,2002)) . !-- ($InvMonth) -- Number of Invoices: . $InvCount[$i] . /strongbr; } RESULTS: Month: December Number of Invoices: 22 Month: November Number of Invoices: 17 Month: October Number of Invoices: 21 Have you extracted the SQL from the PHP and applied it directly to the command line or used it in a MySQL Management package? Was the result any different? Also a damn good idea (I haven't had root access to MySQL until recently, hadn't thought of that either) mysql SELECT COUNT(DateBilled) AS count, MONTH(DateBilled) AS BilledMonth, YEAR(DateBilled) AS BilledYear FROM Invoices GROUP BY MONTH(DateBilled) ORDER BY DateBilled DESC; +---+-++ | count | BilledMonth | BilledYear | +---+-++ |15 | 1 | 2002 | |22 | 12 | 2001 | |17 | 11 | 2001 | |21 | 10 | 2001 | +---+-++ 4 rows in set (0.00 sec) Ok.. So the problem seems to be with my code.. $sql = SELECT COUNT(DateBilled) AS count, MONTH(DateBilled) AS BilledMonth, YEAR(DateBilled) AS BilledYear FROM Invoices GROUP BY MONTH(DateBilled) ORDER BY DateBilled ASC; $monthly_result = mysql_query($sql, $db); $monthly_row = DBfetch_array($monthly_result); $i=0; while($monthly_row = mysql_fetch_array($monthly_result)) { $InvMonth[$i] = $monthly_row[BilledMonth]; $InvCount[$i] = $monthly_row[count]; echo strongMonth: . date (F, mktime(0,0,0,$InvMonth[$i],1,2002)) . !-- ($InvMonth) -- Number of Invoices: . $InvCount[$i] . /strongbr; ++$i; } RESULTS: Month: November Number of Invoices: 17 Month: December Number of Invoices: 22 Month: January Number of Invoices: 15 I can't see the bug in the PHP I've got, but there certainly must be one.. Any suggestions would be appreciated! Mike - Original Message - From: Mike Gifford [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: 11 January 2002 08:12 Subject: [PHP-DB] GROUP BY MONTH(DateBilled) misses an entry consistently Hello I've got the following SQL Query, which consistently pulls up only 3 out of 4 months from the database: $sql = SELECT COUNT(DateBilled) AS count, MONTH(DateBilled) AS BilledMonth, YEAR(DateBilled) AS BilledYear FROM Invoices GROUP BY MONTH(DateBilled) ORDER BY DateBilled ASC; This results in: Month: November Number of Invoices: 17 Month: December Number of Invoices: 22 Month: January Number of Invoices: 15 But when I do change the order of the query from ASC to DESC like this: $sql = SELECT COUNT(DateBilled) AS count, MONTH(DateBilled) AS BilledMonth, YEAR(DateBilled) AS BilledYear FROM Invoices GROUP BY MONTH(DateBilled) ORDER BY DateBilled ASC;$sql = SELECT COUNT(DateBilled) AS count, MONTH(DateBilled) AS BilledMonth, YEAR(DateBilled) AS BilledYear FROM Invoices GROUP BY MONTH(DateBilled) ORDER BY DateBilled DESC; I get: Month: December Number of Invoices:
[PHP-DB] Iterate through Multi-Dimensional Arrays
Hi all, I have a multidimesional array that holds consultants and their details. I've tried this a number of ways but to no avail. Could someone help me out iterating through the first and then the second array and display those results on my webpage. I messed it up pretty badly :( heh Here's my code : Thx Joe :) // fetch the data from the database while(odbc_fetch_row($resultset)){ $consultantdetailsarray[0] = odbc_result($resultset, 1); $consultantdetailsarray[1] = odbc_result($resultset, 2); $consultantdetailsarray[2] = odbc_result($resultset, 3); $consultantdetailsarray[3] = odbc_result($resultset, 4); $consultantdetailsarray[4] = odbc_result($resultset, 5); $consultantdetailsarray[5] = odbc_result($resultset, 6); $consultantdetailsarray[6] = odbc_result($resultset, 7); $consultantdetailsarray[7] = odbc_result($resultset, 8); file://dump each consultant into the new array called $consultantarray $consultantarray[$x] = $consultantdetailsarray; $x++; } file://loop through the elements of retrieved array (2nd one holding the consultant details) for($y = 0; $y count($consultantarray); +){ for($z = 0; $z count($consultantdetailsarray[$y][$x]); $z++){ list($consultantid, $firstname, $lastname, $city, $stateprovince, $country, $category, $yearsexp) = $consultantdetailsarray; print trtd align=leftfont color='#663399' face='verdana' size=2a href='consultantdetails.php?cid= . $cid . ' . $firstname . . $lastname . /a/font/tdtd align=leftfont color='#663399' face='verdana' size=2 . $city . /font/tdtd align=leftfont color='#663399' face='verdana' size=2 . $stateprovince . /font/tdtd align=leftfont color='#663399' face='verdana' size=2 . $country . /font/tdtd align=leftfont color='#663399' face='verdana' size=2 . $category . /font/tdtd align=leftfont color='#663399' face='verdana' size=2 . $yearsexp . /font/td/tr; } } -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] odbc and access
I want to connect to an access database via a dsn. Here is the code: ?php $db_link = odbc_connect(tatoo, , ); ? And I got the following error: Warning: SQL error: [Microsoft][Gestionnaire de pilotes ODBC] Source de données introuvable et nom de pilote non spécifié, SQL state IM002 in SQLConnect in C:\Inetpub\wwwroot\php\first.php on line 11 I know it's written in french... sorry: that mean that the driver manager can't find the data source but my dsn is correct. Anyone can help me ? thanx. sam -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP-DB] odbc and access
Sam, If this is Windows, ensure you are using a System DSN. If this is *nix, ensure you have an ODBC driver installed and the odbc.ini file pointed to via a putenv(). Best regards, Andrew Hill Director of Technology Evangelism OpenLink Software http://www.openlinksw.com Universal Data Access Data Integration Technology Providers -Original Message- From: Berthelot [mailto:[EMAIL PROTECTED]] Sent: Monday, January 07, 2002 11:57 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] odbc and access I want to connect to an access database via a dsn. Here is the code: ?php $db_link = odbc_connect(tatoo, , ); ? And I got the following error: Warning: SQL error: [Microsoft][Gestionnaire de pilotes ODBC] Source de données introuvable et nom de pilote non spécifié, SQL state IM002 in SQLConnect in C:\Inetpub\wwwroot\php\first.php on line 11 I know it's written in french... sorry: that mean that the driver manager can't find the data source but my dsn is correct. Anyone can help me ? thanx. sam -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] multiple tables insert
Thanks for that. But it has brought up another question. I'll list the tables so you'll know what i'm on about. TABLE 1 : Album alb_id int(11) NOT NULL auto_increment, art_id int(11) NOT NULL default '0', alb_name varchar(255) NOT NULL default '', alb_image varchar(255) NOT NULL default '', alb_year date NOT NULL default '-00-00', alb_genre varchar(100) NOT NULL default '', PRIMARY KEY (alb_id) TABLE 2 : Artist art_id int(11) NOT NULL auto_increment, art_name varchar(255) NOT NULL default '', art_details mediumtext NOT NULL, PRIMARY KEY (art_id) TABLE 3 : Songs song_id int(11) NOT NULL auto_increment, song_name varchar(255) NOT NULL default '', song_lyrics mediumtext NOT NULL, song_info mediumtext NOT NULL, PRIMARY KEY (song_id) TABLE 4 : Tracks track_id int(11) NOT NULL auto_increment, alb_id int(11) NOT NULL default '0', art_id int(11) NOT NULL default '0', song_id int(11) NOT NULL default '0', PRIMARY KEY (track_id) Ok I'll be able to work out the simple part of the inserts, but what about the auto_increment parts thatt relie on the information in the other files. eg: 'artist.art_id' should be the same as 'album.art_id' the problem is that 'artist.art_id' is auto_increment and 'album.art_id' is not. So if I added an artist in the artist table and the auto_increment gave it the value of 5, how would I update the 'album.art_id' with the same value? - Original Message - From: Miles Thompson [EMAIL PROTECTED] To: Barry Rumsey [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Saturday, January 12, 2002 9:50 AM Subject: Re: [PHP-DB] multiple tables insert Barry See below ... At 09:09 AM 1/12/2002 +1300, Barry Rumsey wrote: Two questions: 1) If I have a url in the db that points to a image , how do I get php to get this image and display it ? Check the IMG tag in an HTML reference 2) I have 4 tables in the db and would like to know of a good tutorial on inserting to multiple tables form a single form. There are many tutorials, the one I most frequently recommend is by Julie Meloni at http://www.thickbook.com pick the one on custom error messages as she develops it very nicely. As for the inserts, in the processing part of the script, you'll know what I mean when you examine the tutorial, execute an INSERT for the data you want to insert in each of the tables. INSERT acts on one table at a time, so you'll have four of them. That should get you going - Miles Thompson -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Oracle date conversion
Thanks for your response. When I use SQL*Plus, I get full date+time. I also get a full datetime from cx_Oracle (a Python module). Is this then a default _PHP_ behavior when querying an Oracle db? Why not return the full info? Ordinarily, I would not complain about the small rewrite you suggest, but my application is an SQL query window in the browser, aimed at users who are not SQL enthusiasts. Thanks again, David Ford, Mike [LSS] wrote: -Original Message- From: David C. Norris [mailto:[EMAIL PROTECTED]] Sent: 26 December 2001 17:00 Oracle DATEs are retrieved (by ora_fetch_into($cursor, $row, ORA_FETCHINTO_NULLS), for example) as plain dates (e.g., '26-DEC-01'), losing the time of day (as in '26-DEC-01 12:34:56'). Is this a bug? No, this is the default ORACLE format for retrieved dates. Is there a workaround that doesn't involve rewriting the query? No, but modifying the query to use a date format is actually the best solution. This would give you something like: SELECT TO_CHAR(DATE, 'DD-MON-YY HH:MI:SS') AS DATE_TIME FROM TBL Look up the definition of the TO_CHAR function for the full list of format elements available for formatting DATEs. 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, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] How do I know when to
Hi, I am really new to MySQL and am wondering this: I understand how to make a database and tables but what I don't understand is when to make a row an int with auto_increment or just a plain int. Or why would you use varchar(50) instead of char(50). Could someone please explain what is happening and why? Thank you Jerry -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] How do I know when to
On Fri, 11 Jan 2002 15:02:00 -0800 Jerry Leonard Jerry Leonard [EMAIL PROTECTED] wrote: Hi, I am really new to MySQL and am wondering this: I understand how to make a database and tables but what I don't understand is when to make a row an int with auto_increment or just a plain int. Or why would you use varchar(50) instead of char(50). Could someone please explain what is happening and why? Thank you Jerry Personally I would never create a row that was 'int' with auto_increment. However, I often create columns that are. When I do, I use those columns as unique identifiers for a particular row. Any of the other data may change in the row, but the unique identifier will always remain the same. The price of an item may change, as well as the packing quantity, the description and even your part number scheme, but the unique ID always remains the same. I use 'varchar(50)' when my data is of variable length because the storage space automagically grows up to 50 characters, thus using less space. 'char(50)' is just what it says, space enough to hold 50 characters. -- Raquel Nothing happens in consequence to nature, only in consequence to what we know of it. --Scully, X-Files -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] How do I know when to
Okay this is the way I understand the statement below. The uid will be a number from 1 to 10, max length of ten digits say starting at 1 then as the next user registers it will automatically make that user number 2. Am I correct? CREATE TABLE users ( uid int(10) unsigned NOT NULL auto_increment, -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] How do I know when to
On Fri, 11 Jan 2002 17:21:28 -0800 Jerry Leonard Jerry Leonard [EMAIL PROTECTED] wrote: Okay this is the way I understand the statement below. The uid will be a number from 1 to 10, max length of ten digits say starting at 1 then as the next user registers it will automatically make that user number 2. Am I correct? CREATE TABLE users ( uid int(10) unsigned NOT NULL auto_increment, You are correct that it will automatically increment the 'uid' of each new record beginning with '1', using the digits 0 - 9 (1 to 99). Check out the manual for Create Table. -- Raquel Nothing happens in consequence to nature, only in consequence to what we know of it. --Scully, X-Files -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] multiple tables insert
I had been looking for a pre made script for a lyric site like phpnuke but the only one I could find was myphplyrics which is quite hopeless ,so I've had no choice but to try and make my own any way I would like to thank you for all your help so far. B.J.Rumsey. - Original Message - From: Miles Thompson [EMAIL PROTECTED] To: Barry Rumsey [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Saturday, January 12, 2002 12:51 PM Subject: Re: [PHP-DB] multiple tables insert Barry, Good question, and you have discovered one of MySQL's limitations, it does not enforce functional constraints. To put it another way, you can design parent-child relationships, but the db will never say You can't add this because the parent record doesn't exist. So you have to do it in code, not a big deal,and it's been done that way for years with other flat file, pseudo-relational database -- FoxPro, dBase, etc. You work around it by capturing the auto_increment value using the mysql_insert_id() function. Hence you can insert the values for the artist table, call mysql_insert_id() and assign it to a variable, say $art_id_key, and use it in the insert for the album table. Then repeat, calling mysql_insert_id() and assigning it to $album_id_key after the insert into the album table so that you will have it for the insert into the tracks table. And so forth. You will be doing all these inserts on the same thread, so if someone else inserts into the same table you should be safe, according to the documentation. If A inserts into artist, B inserts into artist, then A calls mysql_insert_id() the value returned is for A's insert, not B's. MySQL has a separate thread for each of A and B. Now, don't trust me. Read up on the last_insert_id() and mysql_insert_id() functions in both the MySQL and PHP docs. I'll toss this out - what if you decide to capture other information, such as the name of the producer. Can your design handle that? What changes might you have to make to accommodate the change? Regards - Miles Thompson At 10:17 AM 1/12/2002 +1300, Barry Rumsey wrote: Thanks for that. But it has brought up another question. I'll list the tables so you'll know what i'm on about. TABLE 1 : Album alb_id int(11) NOT NULL auto_increment, art_id int(11) NOT NULL default '0', alb_name varchar(255) NOT NULL default '', alb_image varchar(255) NOT NULL default '', alb_year date NOT NULL default '-00-00', alb_genre varchar(100) NOT NULL default '', PRIMARY KEY (alb_id) TABLE 2 : Artist art_id int(11) NOT NULL auto_increment, art_name varchar(255) NOT NULL default '', art_details mediumtext NOT NULL, PRIMARY KEY (art_id) TABLE 3 : Songs song_id int(11) NOT NULL auto_increment, song_name varchar(255) NOT NULL default '', song_lyrics mediumtext NOT NULL, song_info mediumtext NOT NULL, PRIMARY KEY (song_id) TABLE 4 : Tracks track_id int(11) NOT NULL auto_increment, alb_id int(11) NOT NULL default '0', art_id int(11) NOT NULL default '0', song_id int(11) NOT NULL default '0', PRIMARY KEY (track_id) Ok I'll be able to work out the simple part of the inserts, but what about the auto_increment parts thatt relie on the information in the other files. eg: 'artist.art_id' should be the same as 'album.art_id' the problem is that 'artist.art_id' is auto_increment and 'album.art_id' is not. So if I added an artist in the artist table and the auto_increment gave it the value of 5, how would I update the 'album.art_id' with the same value? - Original Message - From: Miles Thompson [EMAIL PROTECTED] To: Barry Rumsey [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Saturday, January 12, 2002 9:50 AM Subject: Re: [PHP-DB] multiple tables insert Barry See below ... At 09:09 AM 1/12/2002 +1300, Barry Rumsey wrote: Two questions: 1) If I have a url in the db that points to a image , how do I get php to get this image and display it ? Check the IMG tag in an HTML reference 2) I have 4 tables in the db and would like to know of a good tutorial on inserting to multiple tables form a single form. There are many tutorials, the one I most frequently recommend is by Julie Meloni at http://www.thickbook.com pick the one on custom error messages as she develops it very nicely. As for the inserts, in the processing part of the script, you'll know what I mean when you examine the tutorial, execute an INSERT for the data you want to insert in each of the tables. INSERT acts on one table at a time, so you'll have four of them. That should get you going - Miles Thompson -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing
[PHP-DB] 2D array into mySQL DB
Hi there... I wrote a PHP script which extracts the title and content from all the HTML files in a directory and puts the filename, title and content into a 2 dimensional array. I know the array is fine because when I print it to the page it dislays properly. When I try to input it into the DB I think mySQL chokes. Is there a better way to put contents of an array in a db, or some way to slow down the process? I have tried using insert delayed, and also doing a complex calculation after each insert to keep the php engine thiking but allowing mysql to fix itself, but this does not work. The results I get in the db is muffled and only contains three rows (instead of about 15) and the information is all jumbled aswell. I tried a test line (commented out) and it worked as expected. This is my code. for ($i=0;$icount($arr_page);$i++){ $sql = INSERT into tblContent (Title, Filename, Parent, DirName, Content) VALUES ('$arr_page[$i][0]','$arr_page[$i][1]','$parent','$dir_name','$arr_page[$i] [2]'); //('$i','$i','$i','$i','$i'); this line instead of previous inserts as expected mysql_query($sql); } Any help would be appreciated. Adam -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] processing data from mysql queries with php
Quick question for you guru's out there: I have a set of dynamic pages. In the mysql database, I have most of my content stored and retrieve it with queries sent from php. Is there a way to have php send the query, get the data which _includes_ php code in it, and then process the code from the query as if it were a normal php code, before going on? I have tried to simply place the php code in the field in the database and then query it out, but it only places the code in the page and does not process it. I am thinking that I must use some sort of a loop to process it, but I do not know if this is the correct solution or not. Any ideas? Thanks, Keith -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] 2D array into mySQL DB
On Saturday 12 January 2002 10:42, Adam Royle wrote: Hi there... I wrote a PHP script which extracts the title and content from all the HTML files in a directory and puts the filename, title and content into a 2 dimensional array. I know the array is fine because when I print it to the page it dislays properly. When I try to input it into the DB I think mySQL chokes. Is there a better way to put contents of an array in a db, or some way to slow down the process? I have tried using insert delayed, and also doing a complex calculation after each insert to keep the php engine thiking but allowing mysql to fix itself, but this does not work. The results I get in the db is muffled and only contains three rows (instead of about 15) and the information is all jumbled aswell. I tried a test line (commented out) and it worked as expected. This is my code. for ($i=0;$icount($arr_page);$i++){ $sql = INSERT into tblContent (Title, Filename, Parent, DirName, Content) VALUES ('$arr_page[$i][0]','$arr_page[$i][1]','$parent','$dir_name','$arr_page[$i ] [2]'); //('$i','$i','$i','$i','$i'); this line instead of previous inserts as expected mysql_query($sql); } You don't say what error, if any, you're getting. My best guess is that you probably need to use addslashes() to treat your data before inserting into the database. hth -- Jason Wong - Gremlins Associates - www.gremlins.com.hk /* I'd love to go out with you, but I did my own thing and now I've got to undo it. */ -- 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]