Re: [PHP-DB] mysql/php time out issue
have u checked max_execution_time Chaitanya On Fri, Apr 9, 2010 at 7:17 PM, Stephen Sunderlin stephen.sunder...@verizon.net wrote: I'm running php 5.1.6 with mysql 5.0.45 on CentOS 5.3 box trying to loop through a while statement to send about 3000 email using phpmailer. It's worked well in the past but after an upgrade it seems to be timing out now after 200-300 emails over 1 minute or two. I've added set_time_limit(30) within the while loop to reset the time out. I've added a sleep(1) statement to throttle the program (I've tried sending with and without these additions). I've altered several config files to see if it would send to completion to no avail: mysql.connect_timeout = -1 memory_limit = 100M max_input_time = 60 max_input_time = 600 max_input_time = 0 and the following mysql config: key_buffer = 256M max_allowed_packet = 50M table_cache = 1024 sort_buffer_size = 1M read_buffer_size = 1M read_rnd_buffer_size = 4M myisam_sort_buffer_size = 64M thread_cache_size = 64 tmp_table_size = 40M join_buffer_size = 1M query_cache_limit = 12M query_cache_size= 32M query_cache_type = 1 max_connections = 60 thread_stack = 128K thread_concurrency = 4 Any where else I should be looking. Thanks! -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] mysql/php time out issue
these are the entire core values of mine try making a replica of the required.. i am able to send for 3 mails. are u using an smtp sever to send mails.. allow_call_time_pass_referenceOnOn allow_url_fopenOnOn allow_url_includeOnOn always_populate_raw_post_dataOffOff arg_separator.input arg_separator.outputamp;amp; asp_tagsOffOff auto_append_file*no value**no value* auto_globals_jitOnOn auto_prepend_file*no value**no value* browscap C:\xampp\php\extras\browscap.iniC:\xampp\php\extras\browscap.ini default_charset*no value**no value* default_mimetypetext/htmltext/html define_syslog_variablesOffOff disable_classes*no value**no value* disable_functions*no value**no value* display_errorsOnOn display_startup_errorsOnOn doc_root*no value**no value* docref_ext*no value* *no value* docref_root*no value**no value* enable_dlOnOn error_append_string *no value**no value* error_log*no value**no value* error_prepend_string*no value**no value* error_reporting2251922519 exit_on_timeoutOffOff expose_php OnOn extension_dirC:\xampp\php\extC:\xampp\php\ext file_uploadsOnOn highlight.bg#FF#FF highlight.comment#FF8000#FF8000 highlight.default #BB#BB highlight.html#00#00 highlight.keyword#007700#007700 highlight.string#DD#DD html_errorsOnOn ignore_repeated_errorsOffOff ignore_repeated_sourceOffOff ignore_user_abortOffOff implicit_flushOffOff include_path.;C:\xampp\php\PEAR.;C:\xampp\php\PEAR log_errorsOffOff log_errors_max_len10241024 magic_quotes_gpcOnOn magic_quotes_runtimeOffOff magic_quotes_sybaseOffOff mail.add_x_headerOffOff mail.force_extra_parameters*no value**no value* mail.log*no value**no value* max_execution_time60006000 max_input_nesting_level6464 max_input_time600600 memory_limit128M128M open_basedir*no value**no value* output_buffering*no value**no value* output_handler*no value**no value* post_max_size128M128M precision1414 realpath_cache_size16K16K realpath_cache_ttl120120 register_argc_argvOnOn register_globalsOffOff register_long_arraysOffOff report_memleaksOnOn report_zend_debugOnOn request_order*no value**no value* safe_modeOffOff safe_mode_exec_dir*no value**no value* safe_mode_gidOffOff safe_mode_include_dir*no value**no value* sendmail_from*no value**no value* sendmail_path*no value**no value* serialize_precision100100 short_open_tagOn On smtp_port2525 sql.safe_modeOffOff track_errorsOffOff unserialize_callback_func*no value**no value* upload_max_filesize128M128M upload_tmp_dirC:\xampp\tmpC:\xampp\tmp user_dir*no value**no value* user_ini.cache_ttl300300 user_ini.filename.user.ini.user.ini variables_order GPCSGPCS xmlrpc_error_number00 xmlrpc_errorsOffOff y2k_complianceOnOn zend.enable_gcOnOn Chaitanya On Fri, Apr 9, 2010 at 8:20 PM, Stephen Sunderlin stephen.sunder...@verizon.net wrote: Set that to 6oo. Stopped after 125 loops in under a minute. _ Stephen Sunderlin 2162 Broadway, 4th Fl. New York, NY 10024 (212) 799-3753 -Original Message- From: Chaitanya Yanamadala dr.virus.in...@gmail.com Date: Fri, 09 Apr 2010 19:26:22 To: Stephen Sunderlinstephen.sunder...@verizon.net Cc: php-db@lists.php.net Subject: Re: [PHP-DB] mysql/php time out issue have u checked max_execution_time Chaitanya On Fri, Apr 9, 2010 at 7:17 PM, Stephen Sunderlin stephen.sunder...@verizon.net wrote: I'm running php 5.1.6 with mysql 5.0.45 on CentOS 5.3 box trying to loop through a while statement to send about 3000 email using phpmailer. It's worked well in the past but after an upgrade it seems to be timing out now after 200-300 emails over 1 minute or two. I've added set_time_limit(30) within the while loop to reset the time out. I've added a sleep(1) statement to throttle the program (I've tried sending with and without these additions). I've altered several config files to see if it would send to completion to no avail: mysql.connect_timeout = -1 memory_limit = 100M max_input_time = 60 max_input_time = 600 max_input_time = 0 and the following mysql config: key_buffer = 256M max_allowed_packet = 50M table_cache = 1024 sort_buffer_size = 1M read_buffer_size = 1M read_rnd_buffer_size = 4M myisam_sort_buffer_size = 64M thread_cache_size = 64 tmp_table_size = 40M join_buffer_size = 1M query_cache_limit = 12M query_cache_size= 32M query_cache_type = 1 max_connections = 60 thread_stack = 128K thread_concurrency = 4 Any where else I should be looking. Thanks! -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] mysql/php time out issue
Thanks Chaitanya. I've tried both Sendmail and SMTP. I'll let you know how this works out. On 4/9/2010 10:57 AM, Chaitanya Yanamadala wrote: these are the entire core values of mine try making a replica of the required.. i am able to send for 3 mails. are u using an smtp sever to send mails.. allow_call_time_pass_reference On On allow_url_fopen On On allow_url_include On On always_populate_raw_post_data Off Off arg_separator.input arg_separator.outputamp; amp; asp_tagsOff Off auto_append_file/no value/ /no value/ auto_globals_jitOn On auto_prepend_file /no value/ /no value/ browscap C:\xampp\php\extras\browscap.ini C:\xampp\php\extras\browscap.ini default_charset /no value/ /no value/ default_mimetypetext/html text/html define_syslog_variables Off Off disable_classes /no value/ /no value/ disable_functions /no value/ /no value/ display_errors On On display_startup_errors On On doc_root/no value/ /no value/ docref_ext /no value/ /no value/ docref_root /no value/ /no value/ enable_dl On On error_append_string /no value/ /no value/ error_log /no value/ /no value/ error_prepend_string/no value/ /no value/ error_reporting 22519 22519 exit_on_timeout Off Off expose_php On On extension_dir C:\xampp\php\extC:\xampp\php\ext file_uploadsOn On highlight.bg http://highlight.bg#FF #FF highlight.comment #FF8000 #FF8000 highlight.default #BB #BB highlight.html #00 #00 highlight.keyword #007700 #007700 highlight.string#DD #DD html_errors On On ignore_repeated_errors Off Off ignore_repeated_source Off Off ignore_user_abort Off Off implicit_flush Off Off include_path.;C:\xampp\php\PEAR .;C:\xampp\php\PEAR log_errors Off Off log_errors_max_len 10241024 magic_quotes_gpcOn On magic_quotes_runtimeOff Off magic_quotes_sybase Off Off mail.add_x_header Off Off mail.force_extra_parameters /no value/ /no value/ mail.log/no value/ /no value/ max_execution_time 60006000 max_input_nesting_level 64 64 max_input_time 600 600 memory_limit128M128M open_basedir/no value/ /no value/ output_buffering/no value/ /no value/ output_handler /no value/ /no value/ post_max_size 128M128M precision 14 14 realpath_cache_size 16K 16K realpath_cache_ttl 120 120 register_argc_argv On On register_globalsOff Off register_long_arraysOff Off report_memleaks On On report_zend_debug On On request_order /no value/ /no value/ safe_mode Off Off safe_mode_exec_dir /no value/ /no value/ safe_mode_gid Off Off safe_mode_include_dir /no value/ /no value/ sendmail_from /no value/ /no value/ sendmail_path /no value/ /no value/ serialize_precision 100 100 short_open_tag On On smtp_port 25 25 sql.safe_mode Off Off track_errorsOff Off unserialize_callback_func /no value/ /no value/ upload_max_filesize 128M128M upload_tmp_dir C:\xampp\tmpC:\xampp\tmp user_dir/no value/ /no value/ user_ini.cache_ttl 300 300 user_ini.filename .user.ini .user.ini variables_order GPCSGPCS xmlrpc_error_number 0 0 xmlrpc_errors Off Off y2k_compliance On On zend.enable_gc On On Chaitanya On Fri, Apr 9, 2010 at 8:20 PM, Stephen Sunderlin stephen.sunder...@verizon.net mailto:stephen.sunder...@verizon.net wrote: Set that to 6oo. Stopped after 125 loops in under a minute. _ Stephen Sunderlin 2162 Broadway, 4th Fl. New York, NY 10024 (212) 799-3753 -Original Message- From: Chaitanya Yanamadala dr.virus.in...@gmail.com mailto:dr.virus.in...@gmail.com Date: Fri, 09 Apr 2010 19:26:22 To: Stephen Sunderlinstephen.sunder...@verizon.net mailto:stephen.sunder...@verizon.net Cc: php-db@lists.php.net mailto:php-db@lists.php.net Subject: Re: [PHP-DB] mysql/php time out issue have u checked max_execution_time Chaitanya On Fri, Apr 9, 2010 at 7:17 PM, Stephen Sunderlin stephen.sunder...@verizon.net mailto:stephen.sunder...@verizon.net wrote: I'm running php 5.1.6 with mysql 5.0.45 on CentOS 5.3 box trying to loop through a while statement to send about 3000 email using phpmailer. It's worked well in the past but after an upgrade it seems to be timing out now
Re: [PHP-DB] mysql/php time out issue
expose_php On On extension_dir C:\xampp\php\extC:\xampp\php\ext file_uploadsOn On highlight.bg http://highlight.bg#FF #FF highlight.comment #FF8000 #FF8000 highlight.default #BB #BB highlight.html #00 #00 highlight.keyword #007700 #007700 highlight.string#DD #DD html_errors On On ignore_repeated_errors Off Off ignore_repeated_source Off Off ignore_user_abort Off Off implicit_flush Off Off include_path.;C:\xampp\php\PEAR .;C:\xampp\php\PEAR log_errors Off Off log_errors_max_len 10241024 magic_quotes_gpcOn On magic_quotes_runtimeOff Off magic_quotes_sybase Off Off mail.add_x_header Off Off mail.force_extra_parameters /no value/ /no value/ mail.log/no value/ /no value/ max_execution_time 60006000 max_input_nesting_level 64 64 max_input_time 600 600 memory_limit128M128M open_basedir/no value/ /no value/ output_buffering/no value/ /no value/ output_handler /no value/ /no value/ post_max_size 128M128M precision 14 14 realpath_cache_size 16K 16K realpath_cache_ttl 120 120 register_argc_argv On On register_globalsOff Off register_long_arraysOff Off report_memleaks On On report_zend_debug On On request_order /no value/ /no value/ safe_mode Off Off safe_mode_exec_dir /no value/ /no value/ safe_mode_gid Off Off safe_mode_include_dir /no value/ /no value/ sendmail_from /no value/ /no value/ sendmail_path /no value/ /no value/ serialize_precision 100 100 short_open_tag On On smtp_port 25 25 sql.safe_mode Off Off track_errorsOff Off unserialize_callback_func /no value/ /no value/ upload_max_filesize 128M128M upload_tmp_dir C:\xampp\tmpC:\xampp\tmp user_dir/no value/ /no value/ user_ini.cache_ttl 300 300 user_ini.filename .user.ini .user.ini variables_order GPCSGPCS xmlrpc_error_number 0 0 xmlrpc_errors Off Off y2k_compliance On On zend.enable_gc On On Chaitanya On Fri, Apr 9, 2010 at 8:20 PM, Stephen Sunderlin stephen.sunder...@verizon.net mailto:stephen.sunder...@verizon.net wrote: Set that to 6oo. Stopped after 125 loops in under a minute. _ Stephen Sunderlin 2162 Broadway, 4th Fl. New York, NY 10024 (212) 799-3753 -Original Message- From: Chaitanya Yanamadala dr.virus.in...@gmail.com mailto:dr.virus.in...@gmail.com Date: Fri, 09 Apr 2010 19:26:22 Cc: php-db@lists.php.net mailto:php-db@lists.php.net Subject: Re: [PHP-DB] mysql/php time out issue have u checked max_execution_time Chaitanya On Fri, Apr 9, 2010 at 7:17 PM, Stephen Sunderlin stephen.sunder...@verizon.net mailto:stephen.sunder...@verizon.net wrote: I'm running php 5.1.6 with mysql 5.0.45 on CentOS 5.3 box trying to loop through a while statement to send about 3000 email using phpmailer. It's worked well in the past but after an upgrade it seems to be timing out now after 200-300 emails over 1 minute or two. I've added set_time_limit(30) within the while loop to reset the time out. I've added a sleep(1) statement to throttle the program (I've tried sending with and without these additions). I've altered several config files to see if it would send to completion to no avail: mysql.connect_timeout = -1 memory_limit = 100M max_input_time = 60 max_input_time = 600 max_input_time = 0 and the following mysql config: key_buffer = 256M max_allowed_packet = 50M table_cache = 1024 sort_buffer_size = 1M read_buffer_size = 1M read_rnd_buffer_size = 4M myisam_sort_buffer_size = 64M thread_cache_size = 64 tmp_table_size = 40M join_buffer_size = 1M query_cache_limit = 12M query_cache_size= 32M query_cache_type = 1 max_connections = 60 thread_stack = 128K thread_concurrency = 4 Any where else I should be looking. Thanks! -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL + PHP on WinXP x64 = ??
YVES SUCAET wrote: Hi List, I'm experiencing the problem as described at http://forums.mysql.com/read.php?37,39779,136287#msg-136287 I'm using the following script to test: ?php $p = 0; $n = 0; for ($i = 0; $i 120; $i++) { $conn = mysql_connect(www.myserver.org, user, secret); if ($conn) { echo Success!\n; mysql_close($conn); $p++; } else { echo Failed test $i\n; $n++; } sleep(1); } echo \n$p successes, $n failures\n; ? Results are very unpredictable. E.g. out of 120 connection attempts, I'll have 114 successes and 6 failures. Well to be honest my question would be why do you need 120 connections in one script? The solution that's mentioned is to enable connection pooling, yet since I'm using the x64 edition, that doesn't work for me. Why doesn't it work for you? What package were you going to use for connection pooling? Is there an alternative package to try? -- Postgresql php tutorials http://www.designmagick.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL + PHP on WinXP x64 = ?? - clarification
Hi Chris, I don't need 120 concurrent connections. The problem arises from subsequently opening connections and the script is a way to simulate the problem: the first 100 connections e.g. open up fine; then the next 5 mess up; then the next 7 are good to go again etc... I'm using the basic PHP php_mysql.dll driver. I've used MDB2 from PEAR as well: same result. I think both of these use the C API, and not the ODBC-driver. Yves -- Original Message -- Received: Thu, 12 Mar 2009 04:30:33 PM CDT From: Chris dmag...@gmail.com To: YVES SUCAET yves.suc...@usa.netCc: php-db@lists.php.net Subject: Re: [PHP-DB] MySQL + PHP on WinXP x64 = ?? YVES SUCAET wrote: Hi List, I'm experiencing the problem as described at http://forums.mysql.com/read.php?37,39779,136287#msg-136287 I'm using the following script to test: ?php $p = 0; $n = 0; for ($i = 0; $i 120; $i++) { $conn = mysql_connect(www.myserver.org, user, secret); if ($conn) { echo Success!\n; mysql_close($conn); $p++; } else { echo Failed test $i\n; $n++; } sleep(1); } echo \n$p successes, $n failures\n; ? Results are very unpredictable. E.g. out of 120 connection attempts, I'll have 114 successes and 6 failures. Well to be honest my question would be why do you need 120 connections in one script? The solution that's mentioned is to enable connection pooling, yet since I'm using the x64 edition, that doesn't work for me. Why doesn't it work for you? What package were you going to use for connection pooling? Is there an alternative package to try? -- Postgresql php tutorials http://www.designmagick.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL + PHP on WinXP x64 = ?? - clarification
YVES SUCAET wrote: Hi Chris, I don't need 120 concurrent connections. The problem arises from subsequently opening connections and the script is a way to simulate the problem: the first 100 connections e.g. open up fine; then the next 5 mess up; then the next 7 are good to go again etc... I'm using the basic PHP php_mysql.dll driver. I've used MDB2 from PEAR as well: same result. I think both of these use the C API, and not the ODBC-driver. Have you changed the max_connections setting? http://dev.mysql.com/doc/refman/5.0/en/server-system-variables.html#sysvar_max_connections If you have, what is mysql_error() reporting when it can't connect? -- Postgresql php tutorials http://www.designmagick.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL/PHP Left Join Question
One thing I've done in situations like this is just load your returned DB data into an array. Something like this would do: $dvdarr[$result['call_number']]['Title'] = $result['title']; $dvdarr[$result['call_number']]['Publisher'] = $result['publisher']; $dvdarr[$result['call_number']]['Comments'][] = $result['comment']; Put that in a loop of your results. Notice the [] on the comments. That'll collect all your comments under the umbrella of 'Comments'. Then when you go to do your output, you'd do something like this: forach ($dvdarr as $callnumber = $dvddata) { $title = $dvddata['Title']; $publisher = $dvddata['Publisher']; $comments = $dvddata['Comments']; foreach ($comments as $comment) { // do whatever } } There are other ways to handle this.. this might be one of the easier ones (if I'm understanding your problem correctly). -TG = = = Original message = = = Hello, all. I don't know if this is a php-mysql question or just a mysql, but here goes: I have a list of DVDs that my library loans out, and I'd like to allow people to add comments to each item. Since this list gets regenerated periodically (it's extracted from another system, the library catalog), there isn't a consistent ID in the dvd tables, so I'm using the call number (which will look like DVD 2324) as the key. Anyhow, I join the tables like this to get all the DVDs and all the comments associated with the DVDs: SELECT distinct dvds.title, dvds.publisher, dvds.publication_date, dvds.call_number, comment.id, comment.parent_id, comment.comment, comment.name FROM dvds LEFT JOIN comment ON dvds.call_number=comment.parent_id WHERE dvds.title LIKE 'A%' ORDER BY dvds.title With this, I'll get results like DVD 101A.I. This movie rocked DVD 101A.I. This Movie stunk DVD 102Adaptation . . . DVD 103After Hours . . . When I loop in PHP through the records, of course, I want just the one DVD with however many comments associated with it. Is it possible to do this (i.e., screen out DVD dupes) in MySQL, or do I have to do it in PHP? If this is a dumb question, my humblest apologies, and I'd be interested if there was a better way to handle this . . . . Andrew ___ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] MySQL/PHP Left Join Question
I approach this by assigning a value to a variable and then comparing to see if i need to write out a new title $oldDVD = ; while ($rows=mysql_fetch_array($result)) { //decide whether to show the DVD title if ($oldDVD != $rows['title']) { echo trtd.$rows['title']./td/tr; $oldDVD = $rows['title']; } //echo out the rest of the data echo trtd.$rows['comment']./td/tr; } hth Bastien From: Andrew Darby [EMAIL PROTECTED] To: php-db@lists.php.net Subject: [PHP-DB] MySQL/PHP Left Join Question Date: Thu, 25 May 2006 11:28:56 -0400 Hello, all. I don't know if this is a php-mysql question or just a mysql, but here goes: I have a list of DVDs that my library loans out, and I'd like to allow people to add comments to each item. Since this list gets regenerated periodically (it's extracted from another system, the library catalog), there isn't a consistent ID in the dvd tables, so I'm using the call number (which will look like DVD 2324) as the key. Anyhow, I join the tables like this to get all the DVDs and all the comments associated with the DVDs: SELECT distinct dvds.title, dvds.publisher, dvds.publication_date, dvds.call_number, comment.id, comment.parent_id, comment.comment, comment.name FROM dvds LEFT JOIN comment ON dvds.call_number=comment.parent_id WHERE dvds.title LIKE 'A%' ORDER BY dvds.title With this, I'll get results like DVD 101A.I. This movie rocked DVD 101A.I. This Movie stunk DVD 102Adaptation . . . DVD 103After Hours . . . When I loop in PHP through the records, of course, I want just the one DVD with however many comments associated with it. Is it possible to do this (i.e., screen out DVD dupes) in MySQL, or do I have to do it in PHP? If this is a dumb question, my humblest apologies, and I'd be interested if there was a better way to handle this . . . . Andrew -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL/PHP Left Join Question
Some good examples of how to deal with this in PHP have already been given, especially the associative array solution. The question I have is with something like this, how do you weight out the pros/cons of code development versus speed? i.e. for code development breaking the logic up into 2 queries would yield a much more readable result, but speed wise what is better multiple queries with smaller more precise record sets, or having PHP parse through the result set to properly weed out duplicate titles based on the outer join applied? This is assuming that there is no SQL construct to solve this problem, which personally I know of none. -Brad Andrew Darby wrote: Hello, all. I don't know if this is a php-mysql question or just a mysql, but here goes: I have a list of DVDs that my library loans out, and I'd like to allow people to add comments to each item. Since this list gets regenerated periodically (it's extracted from another system, the library catalog), there isn't a consistent ID in the dvd tables, so I'm using the call number (which will look like DVD 2324) as the key. Anyhow, I join the tables like this to get all the DVDs and all the comments associated with the DVDs: SELECT distinct dvds.title, dvds.publisher, dvds.publication_date, dvds.call_number, comment.id, comment.parent_id, comment.comment, comment.name FROM dvds LEFT JOIN comment ON dvds.call_number=comment.parent_id WHERE dvds.title LIKE 'A%' ORDER BY dvds.title With this, I'll get results like DVD 101A.I. This movie rocked DVD 101A.I. This Movie stunk DVD 102Adaptation . . . DVD 103After Hours . . . When I loop in PHP through the records, of course, I want just the one DVD with however many comments associated with it. Is it possible to do this (i.e., screen out DVD dupes) in MySQL, or do I have to do it in PHP? If this is a dumb question, my humblest apologies, and I'd be interested if there was a better way to handle this . . . . Andrew -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL/PHP Left Join Question
Thanks to Bastien and TG for their suggestions. I'd been looking at it Bastien's way, but TG's is probably better suited to what I want to do. I'd forgotten about that possibility, cramming it all into an array . . . . Again, thanks for the help, Andrew p.s. I'd be curious about the relative speeds of these methods, too. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL/PHP Left Join Question
test both and let us know bastien From: Andrew Darby [EMAIL PROTECTED] To: php-db@lists.php.net Subject: Re: [PHP-DB] MySQL/PHP Left Join Question Date: Thu, 25 May 2006 12:33:15 -0400 Thanks to Bastien and TG for their suggestions. I'd been looking at it Bastien's way, but TG's is probably better suited to what I want to do. I'd forgotten about that possibility, cramming it all into an array . . . . Again, thanks for the help, Andrew p.s. I'd be curious about the relative speeds of these methods, too. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL/PHP how to put the results of one query in another query
This is what I use when needing to do this: 1. Put all the values you want to search for in an array $vals (loop around the first result) 2. $query = select count(Nome) from Aeromodelistas where year(AnoQuota)=2005 and Sexo='Masculino' and Distrito IN .sqlIn($vals) ; function sqlIn($vals, $quote=') { if (!is_array($vals)) $vals = array($vals); $s = '('; $c = ''; foreach ($vals as $val) { $s .= $c.$quote.addslashes($val).$quote; $c = ','; } return $s.')'; } Pedro Quaresma de Almeida wrote: Hi I have two MySQL databases, on for aeromodelistas (aeromodelling) and another for Códigos Postais (Postal Codes). I whant to do the following query SELECT CódigoPostal FROM Aeromodelistas WHERE CódigoPostal IN (SELECT distinct(CP4) FROM codigopostal.LOCART,codigopostal.DISTRITO WHERE codigopostal.LOCART.DD=codigopostal.DISTRITO.DD AND codigopostal.DISTRITO.DESIG='Coimbra'); This query is not working, and I do not know why. If I try the two queries individualy they work, togheter they don't!? But the question I want to put to the members of this list is the following. Is it possible to do the following? // first do the subquery $sql_CP4s = select distinct(CP4) from codigopostal.LOCART,codigopostal.DISTRITO where codigopostal.LOCART.DD=codigopostal.DISTRITO.DD and codigopostal.DISTRITO.DESIG='$nomeDistrito'; $resultado_CP4s = mysql_query($sql_CP4s,$ligacao); $linha_CP4s = mysql_fetch_assoc($resultado_CP4s); // then use it's results in the main query $sql_Aero_Dist_Masc = select count(Nome) from Aeromodelistas where year(AnoQuota)=2005 and Sexo='Masculino' and Distrito IN $linha_CP4s; How can we include the results (not just one) of one query in another query? Is it possible? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] mysql, php error
James wrote: I'm pretty new to this...I've set this book example up on my PC and it's fine. I've attempted this on two Macs... Here's the error I get when I try to run the application. What does the error mean? UNHANDLED ERROR on line 84 in /Library/WebServer/Documents/wda2-winestore/index.php. [PHP Error 20050307145950]Error: Non-static method DB::connect() should not be called statically (error #2048). [snip] You're calling a classes method statically when it cannot be called as such - the function makes references to $this, or has otherwise been shown to be non-static. You need to create an instance of the object, then call the method through it. E.G. instead of: DB::connect('some','variables'); you have to use: $mydb = new DB; $mydb-connect('some','variables'); Without the exact code, I can only give you examples of about how it should look - but that's the gist of it. cheers, -- - Martin Norland, Sys Admin / Database / Web Developer, International Outreach x3257 The opinion(s) contained within this email do not necessarily represent those of St. Jude Children's Research Hospital. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL PHP hosting
You could also try www.vitalspeeds.com they dont host any microsoft stuff like .Net or ASP but they are reliable and cheap. Hope this helps. Regards, Marcus Joyce J. Connolly wrote: Is there a site that someone could recommend that does PHP, Mysql hosting? If they do .NET that would be good also. This is for practice and development not for a company so I am looking to keep the costs down. There are so many sites, I thought maybe someone here might have a good solution. jzf -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL PHP hosting
On Tue, 2005-02-08 at 16:07 -0500, J. Connolly wrote: Is there a site that someone could recommend that does PHP, Mysql hosting? If they do .NET that would be good also. This is for practice and development not for a company so I am looking to keep the costs down. There are so many sites, I thought maybe someone here might have a good solution. jzf http://www.planetargon.com/hosting/ -- /*** * Robby Russell | Owner.Developer.Geek * PLANET ARGON | www.planetargon.com * Portland, OR | [EMAIL PROTECTED] * 503.351.4730 | blog.planetargon.com * PHP/PostgreSQL Hosting Development * --- Now hosting Ruby on Rails Apps --- / -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] MySQL PHP hosting
i buy my hosting on ebay. haven't had a problem bastien From: J. Connolly [EMAIL PROTECTED] To: PHP list php-db@lists.php.net Subject: [PHP-DB] MySQL PHP hosting Date: Tue, 08 Feb 2005 16:07:47 -0500 Is there a site that someone could recommend that does PHP, Mysql hosting? If they do .NET that would be good also. This is for practice and development not for a company so I am looking to keep the costs down. There are so many sites, I thought maybe someone here might have a good solution. jzf -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL PHP hosting
joe, thanks for the advicei just can't host where i work and trying to develop only on my laptop only at work is becoing tedious. The sys admin is not happy about me running iis or apache on my laptop here. But at least I didn't ask how you how to configure my php and mysql richard, thanks for ipower that look kind of like what i am looking for jozef Joe Harman wrote: Hey J. I really like both of these companies http://www.spinweb.net http://www.rochen.com both are big with PHP... both have top notch service and great pricing... spinweb is great if you are into editing your confige files... Good Luck! Joe PS... people here on this board don't like these kinds of question.. just a FYI for you! On Tue, 08 Feb 2005 16:07:47 -0500, J. Connolly [EMAIL PROTECTED] wrote: Is there a site that someone could recommend that does PHP, Mysql hosting? If they do .NET that would be good also. This is for practice and development not for a company so I am looking to keep the costs down. There are so many sites, I thought maybe someone here might have a good solution. jzf -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySql PHP API
On Mon, 1 Mar 2004 17:16:01 -0800 (PST), Mike Ni wrote: Hey everyone, Does anyone outhere is running Apache/Linux/PHP/Mysql? I am having hard time with MYSQL PHP API. Apache/PHP simply would not recognize any cmysql function call such as mysql_connect. I have recompile the php with mysql extension and th problem continue tobe there. I run the phpifo and it work. In smuuary: * Beside Mysql, PHP seems to be working including phpino * According to phpinfo( ), it suuport mysql. Yet, wouldn't recognize the functin call Plese let me know if you have any thought. Thanks! Mike: You don't say if you are trying to get a new installation running for the first time or are these scripts that were working at one time and something has changed that has caused them to stop working? Is the installation on your local machine or on a remote server? More importantly, you need to provide a cut-and-paste copy of the portion of the code that isn't working and all error messages being returned by the system. Finally, please don't cross port to several lists at once. Regards, Doug -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySql PHP API
I'm confused. I replied to your inquiry to tell you what information you need to provide if you are to receive help.. Why are you asking me questions about *your* problem? And keep the discussion on the list. Doug Mike Ni wrote: Do you know for certain whether it is a matter of installation or a matter of db_programming? Mike --- Doug Thompson [EMAIL PROTECTED] wrote: On Mon, 1 Mar 2004 17:16:01 -0800 (PST), Mike Ni wrote: Hey everyone, Does anyone outhere is running Apache/Linux/PHP/Mysql? I am having hard time with MYSQL PHP API. Apache/PHP simply would not recognize any cmysql function call such as mysql_connect. I have recompile the php with mysql extension and th problem continue tobe there. I run the phpifo and it work. In smuuary: * Beside Mysql, PHP seems to be working including phpino * According to phpinfo( ), it suuport mysql. Yet, wouldn't recognize the functin call Plese let me know if you have any thought. Thanks! Mike: You don't say if you are trying to get a new installation running for the first time or are these scripts that were working at one time and something has changed that has caused them to stop working? Is the installation on your local machine or on a remote server? More importantly, you need to provide a cut-and-paste copy of the portion of the code that isn't working and all error messages being returned by the system. Finally, please don't cross port to several lists at once. Regards, Doug -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] mysql + php
James, (B (BThe consensus of developers here seems to have been not to store binary objects in the (Bdatabase. Rather store them in the file system and simply store reference records in (Bthe database. It is much easier this way. If doing it differently is not an option (Bfor you hopefully someone else on the list has done this. Unfortunately, I'm pretty (Bsure most of us haven't even tried since it is so much simpler to store them in the (Bfile system. (B (BHope this is helpful. (B (B Ryan (B (B-Original Message- (BFrom: Will Contact [mailto:[EMAIL PROTECTED] (BSent: Monday, December 08, 2003 1:10 PM (BTo: [EMAIL PROTECTED] (BSubject: [PHP-DB] mysql + php (B (Bhi! (B (BI am first question of php in this news group. I would like to ask my question about (Bphp + mysql. Now I am programming php+mysql. I put word, excel, mpeg and any (Bbinaries into the mySQL database using php on linux server,But I can take out these (Bbinay from mySQL database. I would like to see the files and save my pc from server. (BSo how can I take out from these binaries? If you know it how to take out and show it, (Bplease teach and help me how!!. (BThe information table of mySQL is "objects." So here is the program below; (B (B// database information (Bcreate table objects (B b_col blob, (B name varchar(30), (B file_size varchar(30), (B file_date datetime (B} (B// it works from "insert" SQL abc.php (B$db = mysql_connect("*", "***", ""); (Bmysql_select_db("***",$db); (B$sql_insert = "INSERT INTO objects(b_col, file_name, file_size, (Bfile_type,file_date) VALUES (B('$UploadedFile','$UploadedFile_name','$UploadedFile_size','$UploadedFile_type',now())"; (B (B mysql_query($sql_insert); (B (B// (B// But it does not work at. I can not see anything in my browser (B$sql_select = "select b_col, file_name, file_size, file_type, file_date from (Bobjects where file_name like 'gball.gif'"; (Bif(!($result=mysql_query($sql_select,$db))){ (Bdie; (B} (B (B $file_name = mysql_result ($result,0,"file_name"); (B echo $file_name; (B (B (B (BRegards, (Bjames (B (B_ $BM'C#$H(J24$B;~4V%[%C%H%i%$%s!V(JMSN $B%a%C%;%s%8%c!http://messenger.msn.co.jp (B (B-- (BPHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: (Bhttp://www.php.net/unsub.php (B (B-- (BPHP Database Mailing List (http://www.php.net/) (BTo unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] mysql + php
From: "Will Contact" [EMAIL PROTECTED] (B (B Now I am programming php+mysql. I put word, excel, mpeg and (B any binaries into (B the mySQL database using php on linux server,But I can take out these (Bbinay (B from mySQL database. I would like to see the files and save my pc from (B server. So how can I take out from (B these binaries? (B[snip] (B $sql_insert = "INSERT INTO objects(b_col, file_name, file_size, (B file_type,file_date) VALUES (B (B('$UploadedFile','$UploadedFile_name','$UploadedFile_size','$UploadedFile_ty (Bpe',now())"; (B (Bmysql_query($sql_insert); (B (BAre you sure anything is even being put in the database here? There's no (Berror checking. Is the blob empty? (B (B // But it does not work at. I can not see anything in my browser (B $sql_select = "select b_col, file_name, file_size, file_type, (Bfile_date (B from objects where file_name like 'gball.gif'"; (B if(!($result=mysql_query($sql_select,$db))){ (B die; (B } (B (B$file_name = mysql_result ($result,0,"file_name"); (Becho $file_name; (B (BYou need to check what's actually in your database. If you don't get a (Bresult here, then there's nothing matching "gball.gif" in your database (B(even if you think there is). (B (BAs for displaying these files again (obligatory mention that storing binary (Bfiles in the database is a BAD idea, IMHO) it's a simple matter of using (Bheader() to send an appropriate CONTENT header matching whatever kind of (Bfile you're sending "text/plain", "image/jpg", etc and then echoing the data (Bfrom the blob. (B (B---John Holmes... (B (B-- (BPHP Database Mailing List (http://www.php.net/) (BTo unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL, PHP or ghost?
Hmmm... You have a point; the doc is not quite clear. Illegal YEAR values are converted to My understanding is that any illegal value will be first converted into '', then into the corresponding year inside the 1901-2155 interval, ie 2000 Well, all this is quite logical. I have no quarrel with this behaviour. Ignatius _ - Original Message - From: Peter Beckman [EMAIL PROTECTED] To: Ignatius Reilly [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Wednesday, August 27, 2003 4:13 PM Subject: Re: [PHP-DB] MySQL, PHP or ghost? On Wed, 27 Aug 2003, Ignatius Reilly wrote: Read the MySQL manual. Hmmm, I thought I did. 6.2.2.4: Illegal YEAR values are converted to . 0 value is interpreted as 2000. Your empty string is converted to an integer, thus 0. What confuses me (what I can't find) is why a quoted empty string is converted to a quoted integer 0 for a YEAR type. Based on the manual, I assumed an empty string is considered an Illegal YEAR and thus converted to . The empty string is NOT converted to an UNQUOTED digit 0, because otherwise the field would be set to (the intended and expected action). You must specify it as a string '0' or '00' or it will be interpreted as . Can you point me to the correct portion of the manual that explains that? What you explain sounds like MySQL is working as designed, but I'm a bit embarrassed that I missed that in the manual, so I want to read up on it. Seems a bit obscure; I've been using mysql for 4+ years and have never came across this. Thanks, Beckman - Original Message - From: Peter Beckman [EMAIL PROTECTED] Seems that either I don't understand mysql, or something. My table, with the non-important things removed... mysql explain plate; +-+---+--+-+-+-- --+ | Field | Type | Null | Key | Default | Extra | +-+---+--+-+-+-- --+ | pid | mediumint(8) unsigned | | PRI | NULL | auto_increment | | year| year(4) | YES | | NULL | | [...] So my assumption is that if I insert with year= it should use the default. Or at least . mysql update plate set year=NULL where pid=65; Query OK, 1 row affected (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql select * from plate where pid=65; +-+-+--+- | pid | plate | year | +-+-+--+- | 65 | DVF0343 | NULL | +-+-+--+- But if I do this: mysql update plate set year= where pid=65; Query OK, 1 row affected (0.01 sec) Rows matched: 1 Changed: 1 Warnings: 1 mysql select * from plate where pid=65; +-+-+--+- | pid | plate | year | +-+-+--+- | 65 | DVF0343 | 2000 | +-+-+--+- 2000? What? Why? Confused. PHP or Mysql fault? -- - Peter Beckman Internet Guy [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] MySQL, PHP or ghost?
El Mié 27 Ago 2003 11:34, Ignatius Reilly escribió: Hmmm... You have a point; the doc is not quite clear. Illegal YEAR values are converted to My understanding is that any illegal value will be first converted into '', then into the corresponding year inside the 1901-2155 interval, ie 2000 Well, all this is quite logical. I have no quarrel with this behaviour. Not at all. This is totally ilogical. Wrong date values should give error messages. See what happens when you try to bend a bad input value: http://archives.postgresql.org/pgsql-general/2003-07/msg00599.php Please don't use MySQL in monetary aplications!! -- Porqué usar una base de datos relacional cualquiera, si podés usar PostgreSQL? - Martín Marqués |[EMAIL PROTECTED] Programador, Administrador, DBA | Centro de Telematica Universidad Nacional del Litoral - -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL, PHP or ghost?
Well, it IS logical provided one is aware of the rules of the game, meaning, as you rightly point out, that MySQL does not reject SQL statements for incorrect values, but attempts at converting them at any price. I have no clue whether it is or not a shortcoming of the implementation (I do not know what SQL-92 says about this). Therefore data validation should be done outside MySQL. Ignatius _ - Original Message - From: Martin Marques [EMAIL PROTECTED] To: Ignatius Reilly [EMAIL PROTECTED]; Peter Beckman [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Thursday, August 28, 2003 2:36 PM Subject: Re: [PHP-DB] MySQL, PHP or ghost? El Mié 27 Ago 2003 11:34, Ignatius Reilly escribió: Hmmm... You have a point; the doc is not quite clear. Illegal YEAR values are converted to My understanding is that any illegal value will be first converted into '', then into the corresponding year inside the 1901-2155 interval, ie 2000 Well, all this is quite logical. I have no quarrel with this behaviour. Not at all. This is totally ilogical. Wrong date values should give error messages. See what happens when you try to bend a bad input value: http://archives.postgresql.org/pgsql-general/2003-07/msg00599.php Please don't use MySQL in monetary aplications!! -- Porqué usar una base de datos relacional cualquiera, si podés usar PostgreSQL? - Martín Marqués |[EMAIL PROTECTED] Programador, Administrador, DBA | Centro de Telematica Universidad Nacional del Litoral - -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL, PHP or ghost?
El Jue 28 Ago 2003 11:25, Ignatius Reilly escribió: Well, it IS logical provided one is aware of the rules of the game, meaning, as you rightly point out, that MySQL does not reject SQL statements for incorrect values, but attempts at converting them at any price. I have no clue whether it is or not a shortcoming of the implementation (I do not know what SQL-92 says about this). Therefore data validation should be done outside MySQL. The thing that IS ilogical is the way MySQL plays the game. What would you think if all of a sudden the date command in linux did something like that (try to add some strange date when the given date isn't a valid date)? Now lets suppose this is a good idea, and one would have to program to get the data integrity (data integrity isn't only when the database server fails). Then why do I have to put different data types? Let's use text everywhere! Or if I do use different data types, what if I have a bug? I could have people loading erronous data in the database and not getting an error, and after loading lots of information I find the bug, but see that all the data is bogus (like the numeric example I gave earlier). To state it more clearly, I havn't seen Oracle, Informix or PostgreSQL do things like this, which reminds me of what someone told me once: MySQL is just a FS with an lousy SQL language (and pretty incomplete). Maybe the problem is that most people never read Codd's 12 rules for a RDBMS: http://www.byte.com/art/9406/sec8/art11.htm -- 16:23:01 up 6 days, 8:13, 4 users, load average: 0.16, 0.31, 0.18 - Martín Marqués |[EMAIL PROTECTED] Programador, Administrador, DBA | Centro de Telematica Universidad Nacional del Litoral - -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL, PHP or ghost?
Well, you're certainly right (except I didn't get the meaning of 'FS' - anything obscene?). However: 1. The job of this ML is to help people get things done 2. For criticisms concerning the design of MySQL, you may get better results posting directly at the MySQL dev team. 3. You may decide that another RDBMS may suit your needs better. Someone told me that Oracle is quite nice. Ig _ - Original Message - From: Martin Marques [EMAIL PROTECTED] To: Ignatius Reilly [EMAIL PROTECTED]; Peter Beckman [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Thursday, August 28, 2003 9:37 PM Subject: Re: [PHP-DB] MySQL, PHP or ghost? El Jue 28 Ago 2003 11:25, Ignatius Reilly escribió: Well, it IS logical provided one is aware of the rules of the game, meaning, as you rightly point out, that MySQL does not reject SQL statements for incorrect values, but attempts at converting them at any price. I have no clue whether it is or not a shortcoming of the implementation (I do not know what SQL-92 says about this). Therefore data validation should be done outside MySQL. The thing that IS ilogical is the way MySQL plays the game. What would you think if all of a sudden the date command in linux did something like that (try to add some strange date when the given date isn't a valid date)? Now lets suppose this is a good idea, and one would have to program to get the data integrity (data integrity isn't only when the database server fails). Then why do I have to put different data types? Let's use text everywhere! Or if I do use different data types, what if I have a bug? I could have people loading erronous data in the database and not getting an error, and after loading lots of information I find the bug, but see that all the data is bogus (like the numeric example I gave earlier). To state it more clearly, I havn't seen Oracle, Informix or PostgreSQL do things like this, which reminds me of what someone told me once: MySQL is just a FS with an lousy SQL language (and pretty incomplete). Maybe the problem is that most people never read Codd's 12 rules for a RDBMS: http://www.byte.com/art/9406/sec8/art11.htm -- 16:23:01 up 6 days, 8:13, 4 users, load average: 0.16, 0.31, 0.18 - Martín Marqués |[EMAIL PROTECTED] Programador, Administrador, DBA | Centro de Telematica Universidad Nacional del Litoral - -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL, PHP or ghost?
El Jue 28 Ago 2003 17:20, Ignatius Reilly escribió: Well, you're certainly right (except I didn't get the meaning of 'FS' - anything obscene?). However: File System. 1. The job of this ML is to help people get things done 2. For criticisms concerning the design of MySQL, you may get better results posting directly at the MySQL dev team. 3. You may decide that another RDBMS may suit your needs better. Someone told me that Oracle is quite nice. Except for (2), I have the same opinion as you have. My mail was because I got really disturbed while reading the mail, and I think people should know about other was of designing an SQL application (or even better was of designing your PHP app). Hopfully I will be giving a 2 hour course at the Linux meeting here at my local city (Santa Fe, Argentina) about using PEAR (or other tools of abstraction) to get better, and easier to maintain PHP programs. And to finish, I don't have the same opinion as you have on (2) because I have read to much junk from the MySQL dev team (things like primary keys are useless). Just my 2 cents. P.D.: Yes, Oracle is pretty nice. -- 17:57:01 up 6 days, 9:47, 4 users, load average: 0.96, 0.75, 0.57 - Martín Marqués |[EMAIL PROTECTED] Programador, Administrador, DBA | Centro de Telematica Universidad Nacional del Litoral - -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL, PHP or ghost?
Read the MySQL manual. 0 value is interpreted as 2000. Your empty string is converted to an integer, thus 0. HTH Ignatius _ - Original Message - From: Peter Beckman [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, August 27, 2003 3:39 AM Subject: [PHP-DB] MySQL, PHP or ghost? Seems that either I don't understand mysql, or something. My table, with the non-important things removed... mysql explain plate; +-+---+--+-+-+-- --+ | Field | Type | Null | Key | Default | Extra | +-+---+--+-+-+-- --+ | pid | mediumint(8) unsigned | | PRI | NULL| auto_increment | | year| year(4) | YES | | NULL| | [...] So my assumption is that if I insert with year= it should use the default. Or at least . mysql update plate set year=NULL where pid=65; Query OK, 1 row affected (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql select * from plate where pid=65; +-+-+--+- | pid | plate | year | +-+-+--+- | 65 | DVF0343 | NULL | +-+-+--+- But if I do this: mysql update plate set year= where pid=65; Query OK, 1 row affected (0.01 sec) Rows matched: 1 Changed: 1 Warnings: 1 mysql select * from plate where pid=65; +-+-+--+- | pid | plate | year | +-+-+--+- | 65 | DVF0343 | 2000 | +-+-+--+- 2000? What? Why? Confused. PHP or Mysql fault? Beckman -- - Peter Beckman Internet Guy [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
Re: [PHP-DB] MySQL, PHP or ghost?
Peter -- ...and then Peter Beckman said... % % Seems that either I don't understand mysql, or something. Looks like it, though I admit that the manual doesn't adequately explain your results. Check out section 6.2.2.4 for details. % % My table, with the non-important things removed... ... % % So my assumption is that if I insert with year= it should use the % default. Or at least . That makes sense. And so what is the default? Looks like it is, for some reason, 2000. [This isn't a TIMESTAMP field, so we don't necessarily expect it to be this year.] % ... % mysql update plate set year= where pid=65; ... % +-+-+--+- % | 65 | DVF0343 | 2000 | % +-+-+--+- % % 2000? What? Why? Confused. PHP or Mysql fault? Looks like it's standard mysql behavior: mysql create table ytest (pid int unsigned not null auto_increment primary key, y year(4)); Query OK, 0 rows affected (0.00 sec) mysql describe ytest; +---+--+--+-+-++ | Field | Type | Null | Key | Default | Extra | +---+--+--+-+-++ | pid | int(10) unsigned | | PRI | NULL| auto_increment | | y | year(4) | YES | | NULL|| +---+--+--+-+-++ 2 rows in set (0.00 sec) mysql insert into ytest values ('',1),('',''),('','2000'); Query OK, 3 rows affected (0.00 sec) Records: 3 Duplicates: 0 Warnings: 4 mysql select * from ytest; +-+--+ | pid | y| +-+--+ | 1 | 2001 | | 2 | 2000 | | 3 | 2000 | +-+--+ 3 rows in set (0.00 sec) mysql update ytest set y = where pid = 3; Query OK, 0 rows affected (0.00 sec) Rows matched: 1 Changed: 0 Warnings: 1 mysql select * from ytest; +-+--+ | pid | y| +-+--+ | 1 | 2001 | | 2 | 2000 | | 3 | 2000 | +-+--+ 3 rows in set (0.00 sec) mysql update ytest set y = '0' where pid =3 ; Query OK, 0 rows affected (0.00 sec) Rows matched: 1 Changed: 0 Warnings: 0 mysql update ytest set y = '45678' where pid = 2; Query OK, 1 row affected (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 1 mysql select * from ytest; +-+--+ | pid | y| +-+--+ | 1 | 2001 | | 2 | | | 3 | 2000 | +-+--+ 3 rows in set (0.00 sec) Note that I sometimes get warnings and sometimes don't. I haven't dug into them, though. % % Beckman % --- % Peter Beckman Internet Guy % [EMAIL PROTECTED] http://www.purplecow.com/ % --- HTH HAND :-D -- David T-G * There is too much animal courage in (play) [EMAIL PROTECTED] * society and not sufficient moral courage. (work) [EMAIL PROTECTED] -- Mary Baker Eddy, Science and Health http://justpickone.org/davidtg/ Shpx gur Pbzzhavpngvbaf Qrprapl Npg! pgp0.pgp Description: PGP signature
Re: [PHP-DB] MySQL, PHP or ghost?
On Wed, 27 Aug 2003, Ignatius Reilly wrote: Read the MySQL manual. Hmmm, I thought I did. 6.2.2.4: Illegal YEAR values are converted to . 0 value is interpreted as 2000. Your empty string is converted to an integer, thus 0. What confuses me (what I can't find) is why a quoted empty string is converted to a quoted integer 0 for a YEAR type. Based on the manual, I assumed an empty string is considered an Illegal YEAR and thus converted to . The empty string is NOT converted to an UNQUOTED digit 0, because otherwise the field would be set to (the intended and expected action). You must specify it as a string '0' or '00' or it will be interpreted as . Can you point me to the correct portion of the manual that explains that? What you explain sounds like MySQL is working as designed, but I'm a bit embarrassed that I missed that in the manual, so I want to read up on it. Seems a bit obscure; I've been using mysql for 4+ years and have never came across this. Thanks, Beckman - Original Message - From: Peter Beckman [EMAIL PROTECTED] Seems that either I don't understand mysql, or something. My table, with the non-important things removed... mysql explain plate; +-+---+--+-+-+-- --+ | Field | Type | Null | Key | Default | Extra | +-+---+--+-+-+-- --+ | pid | mediumint(8) unsigned | | PRI | NULL| auto_increment | | year| year(4) | YES | | NULL| | [...] So my assumption is that if I insert with year= it should use the default. Or at least . mysql update plate set year=NULL where pid=65; Query OK, 1 row affected (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql select * from plate where pid=65; +-+-+--+- | pid | plate | year | +-+-+--+- | 65 | DVF0343 | NULL | +-+-+--+- But if I do this: mysql update plate set year= where pid=65; Query OK, 1 row affected (0.01 sec) Rows matched: 1 Changed: 1 Warnings: 1 mysql select * from plate where pid=65; +-+-+--+- | pid | plate | year | +-+-+--+- | 65 | DVF0343 | 2000 | +-+-+--+- 2000? What? Why? Confused. PHP or Mysql fault? --- Peter Beckman Internet Guy [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] MySQL, PHP or ghost?
its nothing to do with php as your working from the shell in your eg. mysql will default to 2000 for a year value if you pass it as an entry because it will accept short values for the years this century, eg pass it 1 and it'll give you 2001, so it thinks is nothing. if you want to default to this year pass it NOW(). -Original Message- From: Peter Beckman [mailto:[EMAIL PROTECTED] Sent: 27 August 2003 02:40 To: [EMAIL PROTECTED] Subject: [PHP-DB] MySQL, PHP or ghost? Seems that either I don't understand mysql, or something. My table, with the non-important things removed... mysql explain plate; +-+---+--+-+-++ | Field | Type | Null | Key | Default | Extra | +-+---+--+-+-++ | pid | mediumint(8) unsigned | | PRI | NULL| auto_increment | | year| year(4) | YES | | NULL| | [...] So my assumption is that if I insert with year= it should use the default. Or at least . mysql update plate set year=NULL where pid=65; Query OK, 1 row affected (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql select * from plate where pid=65; +-+-+--+- | pid | plate | year | +-+-+--+- | 65 | DVF0343 | NULL | +-+-+--+- But if I do this: mysql update plate set year= where pid=65; Query OK, 1 row affected (0.01 sec) Rows matched: 1 Changed: 1 Warnings: 1 mysql select * from plate where pid=65; +-+-+--+- | pid | plate | year | +-+-+--+- | 65 | DVF0343 | 2000 | +-+-+--+- 2000? What? Why? Confused. PHP or Mysql fault? Beckman --- Peter Beckman Internet Guy [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
Re: [PHP-DB] MySQL, PHP or ghost?
On Wed, 27 Aug 2003, David T-G wrote: Looks like it, though I admit that the manual doesn't adequately explain your results. Check out section 6.2.2.4 for details. I did; see my previous (moments ago) email on my read on that manual section. % So my assumption is that if I insert with year= it should use the % default. Or at least . That makes sense. And so what is the default? Looks like it is, for some reason, 2000. [This isn't a TIMESTAMP field, so we don't necessarily expect it to be this year.] The default at the time was . After I saw the problem I changed it to the below, but that didn't solve the problem: | year| year(4) | YES | | NULL| Before the change it was: | year| year(4) | NO | | | Looks like it's standard mysql behavior: But that's what I'm questioning. Should it be that way? If so, the manual page for YEAR should be altered. If it shouldn't work that way, it should be submitted as a bug. Note that I sometimes get warnings and sometimes don't. I haven't dug into them, though. Hmmm. Unfortunately I can't use show warnings to show the warnings since I don't have 4.1.0, I have 3.23.49. I can't find the manual on the MySQL site for 3.23.49, just 4.1.1. I've checked the .err file in my /var/db/mysql directory but no avail on the warning. Obviously I shouldn't be using year=, and I've since stopped. However, I do want to learn what is going on and why when given an empty quoted string MySQL translates that to 2000 versus the default value (if not null, ; if null, NULL). Beckman --- Peter Beckman Internet Guy [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] MySQL, PHP or ghost?
Peter, et al -- ...and then Peter Beckman said... % % On Wed, 27 Aug 2003, David T-G wrote: % % Looks like it, though I admit that the manual doesn't adequately explain % your results. Check out section 6.2.2.4 for details. % % I did; see my previous (moments ago) email on my read on that manual % section. Ah; I will when it comes through :-) % % % So my assumption is that if I insert with year= it should use the % % default. Or at least . % % That makes sense. And so what is the default? Looks like it is, for % some reason, 2000. [This isn't a TIMESTAMP field, so we don't % necessarily expect it to be this year.] % % The default at the time was . At the time of the mysql release, you might mean? Certainly at the time of the manual writing... % ... % Looks like it's standard mysql behavior: % % But that's what I'm questioning. Should it be that way? If so, the % manual page for YEAR should be altered. If it shouldn't work that way, it % should be submitted as a bug. Makes sense. Having removed all php elements, you'd probably get a better answer on the mysql list. HTH HAND Good luck! :-D -- David T-G * There is too much animal courage in (play) [EMAIL PROTECTED] * society and not sufficient moral courage. (work) [EMAIL PROTECTED] -- Mary Baker Eddy, Science and Health http://justpickone.org/davidtg/ Shpx gur Pbzzhavpngvbaf Qrprapl Npg! pgp0.pgp Description: PGP signature
Re: [PHP-DB] MySQL, PHP or ghost?
Hi Peter Beckman, Seems that either I don't understand mysql, or something. My table, with the non-important things removed... mysql explain plate; +-+---+--+-+-++ | Field | Type | Null | Key | Default | Extra | +-+---+--+-+-++ | pid | mediumint(8) unsigned | | PRI | NULL| auto_increment | | year| year(4) | YES | | NULL| | [...] mysql select * from plate where pid=65; +-+-+--+- | pid | plate | year | +-+-+--+- | 65 | DVF0343 | NULL | +-+-+--+- But if I do this: mysql update plate set year= where pid=65; Query OK, 1 row affected (0.01 sec) Rows matched: 1 Changed: 1 Warnings: 1 mysql select * from plate where pid=65; +-+-+--+- | pid | plate | year | +-+-+--+- | 65 | DVF0343 | 2000 | +-+-+--+- you have chosen a wrong format. The format for year is . With string the field years don't know what to do. Regards, Ruprecht --- Ruprecht Helms IT-Service Softwareentwicklung Tel./Fax +49[0]7621 16 99 16 Homepage: http://www.rheyn.de email:[EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] MySQL, PHP or ghost?
It dosent say this in the docs but I presume its because you need to pass the value as a string or the value will result in , which in year terms is wrong because there never was a year . I guess their reasoning is that if you have passed a then you havent broken this rule and so it shouldnt default to a none existant year, i.e. . like i said, its not in the docs (at least I couldnt find anything in the time / dates part), if you feel its important you could maybe insert a comment in the the YEAR section of the docs. -Original Message- From: Peter Beckman [mailto:[EMAIL PROTECTED] Sent: 27 August 2003 15:29 To: Griffiths, Daniel Subject: RE: [PHP-DB] MySQL, PHP or ghost? On Wed, 27 Aug 2003, Griffiths, Daniel wrote: mysql will default to 2000 for a year value if you pass it as an entry because it will accept short values for the years this century, eg pass it 1 and it'll give you 2001, so it thinks is nothing. if you want to default to this year pass it NOW(). I guess that's why I'm confused. An empty quoted string shouldn't assume that I mean 0; if I meant 0 I would enter 0. It should assume I mean to make it nothing, and by nothing I mean an unquoted 0, or . I just want to know where in the manual it says that passing YEAR an empty quoted value will cause MySQL to understand that value as a quoted 0 and then make the year 2000. It's not in the YEAR section. Beckman --- Peter Beckman Internet Guy [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] MySQL, PHP or ghost?
On Wed, 27 Aug 2003, Ruprecht Helms wrote: you have chosen a wrong format. The format for year is . With string the field years don't know what to do. Right -- and if it doesn't know what to do, why would it insert a value that isn't correct and not give me an error? It does give a warning, but I haven't figured out how to view the warnings (or detect them) in PHP, much less in MySQL. Thanks to all who responded -- I wanted to make sure it was a MySQL thing rather than a PHP thing before I posted on the MySQL lists. Beckman --- Peter Beckman Internet Guy [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] MySQL, PHP or ghost?
Yeah, but Peter stated that he entered year= and the query inserted 2000 in the column. mysql update plate set year= where pid=65; Query OK, 1 row affected (0.01 sec) Rows matched: 1 Changed: 1 Warnings: 1 mysql select * from plate where pid=65; +-+-+--+- | pid | plate | year | +-+-+--+- | 65 | DVF0343 | 2000 | +-+-+--+- If year= is converted to the integer 0 as you state, then, according to the MySQL manual, it should have inserted into the database, not 2000. See below: From the MySql Manual: As a two-digit number in the range 1 to 99. Values in the ranges 1 to 69 and 70 to 99 are converted to YEAR values in the ranges 2001 to 2069 and 1970 to 1999. Note that the range for two-digit numbers is slightly different than the range for two-digit strings, because you cannot specify zero directly as a number and have it be interpreted as 2000. You must specify it as a string '0' or '00' or it will be interpreted as . So it looks like an empty string, year= is actually converted to the STRING 0, resulting in the value 2000 being inserted into the table. According to the manual, the YEAR type expects/requires either a two or four digit integer or a two or four digit number as a string. If it gets anything else, it's supposed to spit out . Therefore, instead of converting Peter's year= to something else, it should just insert . It sounds like a small bug in the way the YEAR type handles data. Maybe a search through the MySQL bug list would yield something in the way of an explanation. I'm just as puzzled by this as Peter is/was and I'm just interested in the explanation. I'm not trying to start an argument here. Rich -Original Message- From: Ignatius Reilly [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 27, 2003 9:31 AM To: Peter Beckman; [EMAIL PROTECTED] Subject: Re: [PHP-DB] MySQL, PHP or ghost? Read the MySQL manual. 0 value is interpreted as 2000. Your empty string is converted to an integer, thus 0. HTH Ignatius _ - Original Message - From: Peter Beckman [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, August 27, 2003 3:39 AM Subject: [PHP-DB] MySQL, PHP or ghost? Seems that either I don't understand mysql, or something. My table, with the non-important things removed... mysql explain plate; +-+---+--+-+-- ---+-- --+ | Field | Type | Null | Key | Default | Extra | +-+---+--+-+-- ---+-- --+ | pid | mediumint(8) unsigned | | PRI | NULL | auto_increment | | year| year(4) | YES | | NULL | | [...] So my assumption is that if I insert with year= it should use the default. Or at least . mysql update plate set year=NULL where pid=65; Query OK, 1 row affected (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql select * from plate where pid=65; +-+-+--+- | pid | plate | year | +-+-+--+- | 65 | DVF0343 | NULL | +-+-+--+- But if I do this: mysql update plate set year= where pid=65; Query OK, 1 row affected (0.01 sec) Rows matched: 1 Changed: 1 Warnings: 1 mysql select * from plate where pid=65; +-+-+--+- | pid | plate | year | +-+-+--+- | 65 | DVF0343 | 2000 | +-+-+--+- 2000? What? Why? Confused. PHP or Mysql fault? Beckman -- - Peter Beckman Internet Guy [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] MySQL, PHP, and XML
A quick google search produced this: Creating XML from MySQL (it also talks about importing XML) http://www.zdnet.com.au/builder/architect/database/story/0,234918,20266023,00.htm On Wed, 11 Jun 2003 21:53:56 -0500, [EMAIL PROTECTED] wrote: Is there an automatic way to insert an XML file into a MySQL DB through say, Load Data InFILE? Or does one have to Pick apart the XML with PHP and insert data into the fields one by one, record by record? /T -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php --- Listserv only address. Jeff Shapiro -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] mysql, php, mp3 - a variable problem
Hi, Where do you get $info2 from? I only see $info in this function. .: Allowee function scan_dir($dir) { $info = New mphp3(2); $handle = @opendir($dir); while ($file = @readdir ($handle)) { if (eregi(^\.{1,2}$,$file)) { continue; } if(is_dir($dir.$file)) { scan_dir($dir.$file./); } else { $info-load(/.$dir.$file); $query =insert into mp3 ( file, path, artist, title, album) values ( '$info2-filename', '$dir', '$info2-v2_artist', '$info2-v2_title', '$info2-v2_album');; mysql_query($query); } } @closedir($handle); } scan_dir(mp3/); ? but all it does is to put the path ($dir) into the database. everything else is ignored. an error does not occur. since the simple demo works fine i think its a problem with the validity of variables. i'm new to php, so could anybody give me a hint on what mightbe wrong with my code please? thanx a lot -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] mysql, php, mp3 - a variable problem
hi allowee, sorry, this was not meant to be. $info2 is supposed to be $info. my fault. but that is not the actual problem. Hi, Where do you get $info2 from? I only see $info in this function. .: Allowee function scan_dir($dir) { $info = New mphp3(2); $handle = @opendir($dir); while ($file = @readdir ($handle)) { if (eregi(^\.{1,2}$,$file)) { continue; } if(is_dir($dir.$file)) { scan_dir($dir.$file./); } else { $info-load(/.$dir.$file); $query =insert into mp3 ( file, path, artist, title, album) values ( '$info2-filename', '$dir', '$info2-v2_artist', '$info2-v2_title', '$info2-v2_album');; mysql_query($query); } } @closedir($handle); } scan_dir(mp3/); ? but all it does is to put the path ($dir) into the database. everything else is ignored. an error does not occur. since the simple demo works -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] mysql, php, mp3 - a variable problem
hmmm, maybe this code.. $info-load(/.$dir.$file); if $dir = mp3s and $file = test.mp3 then it will load '/mp3s/test.mp3' you got that directory? I've seen the class and you are hiding the fopen error message, which could be the problem. .: Allowee On Saturday 07 June 2003 11:11, Ole Hornauer wrote: hi allowee, sorry, this was not meant to be. $info2 is supposed to be $info. my fault. but that is not the actual problem. Hi, Where do you get $info2 from? I only see $info in this function. .: Allowee function scan_dir($dir) { $info = New mphp3(2); $handle = @opendir($dir); while ($file = @readdir ($handle)) { if (eregi(^\.{1,2}$,$file)) { continue; } if(is_dir($dir.$file)) { scan_dir($dir.$file./); } else { $info-load(/.$dir.$file); $query =insert into mp3 ( file, path, artist, title, album) values ( '$info2-filename', '$dir', '$info2-v2_artist', '$info2-v2_title', '$info2-v2_album');; mysql_query($query); } } @closedir($handle); } scan_dir(mp3/); ? but all it does is to put the path ($dir) into the database. everything else is ignored. an error does not occur. since the simple demo works -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] mysql, php, mp3 - a variable problem
Hi, Where do you get $info2 from? I only see $info in this function. I guess that the $info-values are formfieldvalues. $info-[db-field] is normaly used within a whileloop for outputing a select-statement. In the case of formfieldvalues you can use $formfieldname. .: Allowee function scan_dir($dir) ... $query =insert into mp3 ( file, path, artist, title, album) values ( '$info2-filename', '$dir', '$info2-v2_artist', '$info2-v2_title', '$info2-v2_album');; mysql_query($query); ... Regards, Ruprecht -- Ruprecht Helms IT-Service und Softwareentwicklung Tel./Fax +49[0]7621 16 99 16 email: [EMAIL PROTECTED] Homep.http://www.rheyn.de -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] mysql, php, mp3 - a variable problem
On Saturday 07 June 2003 11:20, Allowee wrote: hmmm, maybe this code.. $info-load(/.$dir.$file); if $dir = mp3s and $file = test.mp3 then it will load '/mp3s/test.mp3' you got that directory? I've seen the class and you are hiding the fopen error message, which could be the problem. .: Allowee hmmm. that won't work.. you can try $info-load(./.$dir./.$file); or simple.. $info-load($dir./.$file); .: Allowee -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] mysql, php, mp3 - a variable problem
well, you are right. the dir '/mp3' does not exist. 'mp3' is a subdir from my htdocs dir. so i think the right path should be 'mp3/someartist/somesong', right? i fixed that, but the original problem is still the same :( hmmm, maybe this code.. $info-load(/.$dir.$file); if $dir = mp3s and $file = test.mp3 then it will load '/mp3s/test.mp3' you got that directory? I've seen the class and you are hiding the fopen error message, which could be the problem. .: Allowee On Saturday 07 June 2003 11:11, Ole Hornauer wrote: hi allowee, sorry, this was not meant to be. $info2 is supposed to be $info. my fault. but that is not the actual problem. Hi, Where do you get $info2 from? I only see $info in this function. .: Allowee function scan_dir($dir) { $info = New mphp3(2); $handle = @opendir($dir); while ($file = @readdir ($handle)) { if (eregi(^\.{1,2}$,$file)) { continue; } if(is_dir($dir.$file)) { scan_dir($dir.$file./); } else { $info-load(/.$dir.$file); $query =insert into mp3 ( file, path, -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] mysql, php, mp3 - a variable problem
moin, sorry, my php-knowledge is not the best. what do you mean with formfieldvalues? i think $info-value is used to get the id3-tag info from the class, right? this worked for me in a more simple way without the recursive scan: ? include(mphp3.php); $info = New mphp3(2); mysql_connect(192.168.100.12,user,password); mysql_select_db(music); $info-load(test.mp3); $abfrage =insert into mp3 ( file, artist, title, album) values ( '$info-filename', '$info-v2_artist', '$info-v2_title', '$info-v2_album');; mysql_query($abfrage); ? Hi, Where do you get $info2 from? I only see $info in this function. I guess that the $info-values are formfieldvalues. $info-[db-field] is normaly used within a whileloop for outputing a select-statement. In the case of formfieldvalues you can use $formfieldname. .: Allowee function scan_dir($dir) ... $query =insert into mp3 ( file, path, artist, title, album) values ( '$info2-filename', '$dir', '$info2-v2_artist', '$info2-v2_title', '$info2-v2_album');; mysql_query($query); ... Regards, Ruprecht -- Ruprecht Helms IT-Service und Softwareentwicklung Tel./Fax +49[0]7621 16 99 16 email: [EMAIL PROTECTED] Homep.http://www.rheyn.de -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySql, PHP, and Dates
On Sunday 30 March 2003 11:11, Bruce Feist wrote: I wonder why the PHP/MySql interface doesn't simply return dates as dates instead of strings. *frowns* How do you mean? PHP doesn't have a date type. -- 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 -- /* Blutarsky's Axiom: Nothing is impossible for the man who will not listen to reason. */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySql, PHP, and Dates
Jason Wong wrote: On Sunday 30 March 2003 11:11, Bruce Feist wrote: I wonder why the PHP/MySql interface doesn't simply return dates as dates instead of strings. *frowns* How do you mean? PHP doesn't have a date type. Ummm That's a good reason! As I said, I'm a newbie to PHP, and somewhere along the line I got the idea that there was an actual date data type. I don't know where I got that idea; the book I've been using certainly doesn't say that it does, although I thought I did. It's times like this that I wish that I had smaller feet or a larger mouth, to make it easier to remove the one from the other! Thanks. Bruce Feist -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySql, PHP, and Dates
I originally wrote: when I retrieve a date from MySQL into PHP, it shows up as a string instead of a date data type What's the best way of controlling date format? John W. Holmes replied: If you want a Unix timestamp, which is compatible with the date() function in PHP, then use the UNIX_TIMESTAMP() function in your SQL. This seems to be the ideal solution. Thanks, John, and also those of you who responded via private e-mail. I wonder why the PHP/MySql interface doesn't simply return dates as dates instead of strings. *frowns* Bruce Feist -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] MySql, PHP, and Dates
I'm experienced with SQL, but new to MySql and PHP, which I'm using together to create a dynamic web site. Right now, I'm having minor difficulties with date formatting. It seems that when I retrieve a date from MySQL into PHP, it shows up as a string instead of a date data type, with format -MM-DD HH:MM:SS. Is there any way that I can get it returned as a PHP date instead? Also, exactly what is it that controls the output format of the date as a string? Is PHP somehow requesting that MySql return the date as a string, or is it getting a date from MySql and then converting it to a string on the PHP side? What's the best way of controlling date format? Obviously, I could use string operators to extract the year, month, and day and do whatever I want to with them, but that's sensitive to how PHP and/or MySql are configured, I assume; it would be better for me to request the date in a specific form (ideally one taken from operating system preferences). A couple different ways you can handle this. To format the timestamp from -MM-DD HH:MM:SS to something else, you can use the DATE_FORMAT() function within your SQL. It works almost exactly like the date() function in PHP. If you want to get the output from MySQL as an integer, you can use SELECT column+0 which will return the timestamp in a MMDDHHMMSS format. If you want a Unix timestamp, which is compatible with the date() function in PHP, then use the UNIX_TIMESTAMP() function in your SQL. You could also use the strtotime() function in PHP to take the MySQL timestamp and convert it to a Unix timestamp. ---John W. Holmes... PHP Architect - A monthly magazine for PHP Professionals. Get your copy today. http://www.phparch.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] mysql +php
while ($row= mysql_fetch_array($result)) //retrieve a row and store in echo A HREF= .$row['UrlColumnName'].; That's how I'd do it. Ryan -Original Message- From: G [mailto:[EMAIL PROTECTED]] Sent: Monday, February 17, 2003 8:16 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] mysql +php Hi I was wonder if any knows how 2 display sound clips held in a mysql database using a php page ? I have stored the urls of the clips in mysql database and I belive I need some like to (below) to display them but its not quite working. while ($row= mysql_fetch_row($result)) //retrieve a row and store in array $row { for($i=0; $imysql_num_fields($result);$i++) // echo (A HREF= $row[$i]); // any ideas -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] mysql +php
BTW... you'll need something in the anchor: while ($row= mysql_fetch_array($result)) //retrieve a row and store in echo A HREF= .$row['UrlColumnName'].Something/a; -Original Message- From: Ryan Jameson (USA) Sent: Monday, February 17, 2003 12:16 PM To: [EMAIL PROTECTED] Subject: RE: [PHP-DB] mysql +php while ($row= mysql_fetch_array($result)) //retrieve a row and store in echo A HREF= .$row['UrlColumnName'].; That's how I'd do it. Ryan -Original Message- From: G [mailto:[EMAIL PROTECTED]] Sent: Monday, February 17, 2003 8:16 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] mysql +php Hi I was wonder if any knows how 2 display sound clips held in a mysql database using a php page ? I have stored the urls of the clips in mysql database and I belive I need some like to (below) to display them but its not quite working. while ($row= mysql_fetch_row($result)) //retrieve a row and store in array $row { for($i=0; $imysql_num_fields($result);$i++) // echo (A HREF= $row[$i]); // any ideas -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] mysql +php
Thanks got it working -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] [mysql - php] Newline to BR problem
You want to look at nl2br() function. It takes newlines from a text like: Hello My name is Aaron Which when outputted normally would look like: Hello my name is aaron Using echo nl2br($dbquery); would produce: Hellobrbr My name isbrbr Aaronbrbr In your HTML code which then would output in a browse like the above. Aaron -Original Message- From: Ro Stonemountain [mailto:[EMAIL PROTECTED]] Sent: January 9, 2003 10:53 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] [mysql - php] Newline to BR problem I'm trying to place a text from a textfield into a database and displaying it on another page. All works fine and well but my problem is: If i place newline characters (press enter) in the forms textfield they don't show up on my display page. This is logical because newlines are not br codes. So i must replace the newline thingies with br code. Should this be done BEFORE i put the text in the database or AFTER i put the text in the database and what functions can i use Maybe it's a newbie question but it's on my mind for a few days now and i haven't found an answer yet, thanx! -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] MySQL/PHP dropping characters
-Original Message- From: Micah Stevens [mailto:[EMAIL PROTECTED]] Sent: 23 September 2002 18:09 I've been running into a strange problem on my server with scripts that take form input and reformat it into SQL. It only happens with statements that insert or update data, the first four characters of the POST variables starting at the fourth variable passed are dropped. There are several bug reports at http://bugs.php.net for this -- basically, it seems to be related to transparent multi-byte string encoding (or something like that). If you don't need that support, you should turn it off -- search the bug database for the appropriate bugs, which will give you more information than my brain can! 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] MySQL/PHP
try a little thought... http://www.google.com/search?sourceid=navclientq=php+mysql+tutorial // -Original Message- // From: Bryan McLemore [mailto:[EMAIL PROTECTED]] // Sent: Friday, 30 August 2002 2:52 PM // To: PHP LIST // Subject: [PHP-DB] MySQL/PHP // // // Where can I find a good manual/tutorial on how to access // mySQL w/PHP. Keep in mind that I am new to both PHP and // mySQL, and my database theory is sketchy at best. // // Thanks. // -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL/PHP Update
i think the problem is bad syntax: you should try: mysql_query(update prod_list set prod_manu=$prod_man where sku='.$prod.'); that is because when you have single quotes you will not evaluate the expression so your querry will do the update only for sku equally with the string '$prod'... hope this help, cristi radulescu MU Jason a écrit : I'm trying to update my MySQL database, but it doesn't seem to be taking. my code is: mysql_query(update prod_list set prod_manu=$prod_man where sku='$prod'); where prod_manu is an int $prod_man is an int sku is a varchar $prod is text mysql_query() comes back successful, and just to be sure I echoed mysql_error() and nothing came back. What am I doing wrong? MU if you already have an row with that data, mysql doesn't update the db... MU do an echo $query to see what exactly is executed. MU ($query = update prod_list set prod_manu=$prod_man where sku='$prod') _ Do You Yahoo!? Get your free yahoo.com address at http://mail.yahoo.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] MySQL/PHP Update
Jason, this is intriguing. Please show us a bit more code before the mysql_query() call. -Original Message- From: Jason [mailto:[EMAIL PROTECTED]] Sent: Thursday, March 28, 2002 1:54 AM To: Php-Db Subject: [PHP-DB] MySQL/PHP Update I'm trying to update my MySQL database, but it doesn't seem to be taking. my code is: mysql_query(update prod_list set prod_manu=$prod_man where sku='$prod'); where prod_manu is an int $prod_man is an int sku is a varchar $prod is text mysql_query() comes back successful, and just to be sure I echoed mysql_error() and nothing came back. What am I doing wrong? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL/PHP Update
On Thursday 28 March 2002 17:04, cristi radulescu wrote: i think the problem is bad syntax: you should try: mysql_query(update prod_list set prod_manu=$prod_man where sku='.$prod.'); that is because when you have single quotes you will not evaluate the expression so your querry will do the update only for sku equally with the string '$prod'... I'm afraid that is incorrect. Try it for yourself: ? $doo = 'dah'; echo Doo is '$doo'; ? His problem lies elsewhere. -- Jason Wong - Gremlins Associates - www.gremlins.com.hk /* Nature abhors a virgin -- a frozen asset. -- Clare Booth Luce */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] MySQL/PHP Update
Actually... this turned out to be something totally unrelated. Thanks for all the interest tho. Missing little things like variable spelling is why you shouldn't code for 18 hours straight. Jason Cathcart Check Out My Site: http://www.biohazardous.org -Original Message- From: Rick Emery [mailto:[EMAIL PROTECTED]] Sent: March 28, 2002 7:20 AM To: 'Jason'; Php-Db Subject: RE: [PHP-DB] MySQL/PHP Update Jason, this is intriguing. Please show us a bit more code before the mysql_query() call. -Original Message- From: Jason [mailto:[EMAIL PROTECTED]] Sent: Thursday, March 28, 2002 1:54 AM To: Php-Db Subject: [PHP-DB] MySQL/PHP Update I'm trying to update my MySQL database, but it doesn't seem to be taking. my code is: mysql_query(update prod_list set prod_manu=$prod_man where sku='$prod'); where prod_manu is an int $prod_man is an int sku is a varchar $prod is text mysql_query() comes back successful, and just to be sure I echoed mysql_error() and nothing came back. What am I doing wrong? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL/PHP Update
I'm trying to update my MySQL database, but it doesn't seem to be taking. my code is: mysql_query(update prod_list set prod_manu=$prod_man where sku='$prod'); Try: mysql_query(update prod_list set prod_manu='$prod_man' where sku='$prod'); Maxwell -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL/PHP Update
Jason a écrit : I'm trying to update my MySQL database, but it doesn't seem to be taking. my code is: mysql_query(update prod_list set prod_manu=$prod_man where sku='$prod'); where prod_manu is an int $prod_man is an int sku is a varchar $prod is text mysql_query() comes back successful, and just to be sure I echoed mysql_error() and nothing came back. What am I doing wrong? if you already have an row with that data, mysql doesn't update the db... do an echo $query to see what exactly is executed. ($query = update prod_list set prod_manu=$prod_man where sku='$prod') -- Marius Ursache (3563 || 3494) \|/ \|/ '/ ,. \` /_| \__/ |_\ \__U_/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] MySQL/PHP date functions
On Wed, 2002-02-20 at 13:16, Sven Jacobs wrote: You can do it like this calculate the current day and extract 7 days of it ehm? extract 7 days of it? from what?-) I'm not quite following... then with an array the current day until the calculated day :-) ehm, call me stupid, but I didn't get it. ;) You wouldn't mind posting a snippet? might be easier for poor retarded me to understand. :) May not 100 % what you are looking for but it works What I just came up with, teasing my (few) little gray ones, is calculate backwards until date(W) gives 8, add one, and we have monday the whateverth, right?-) Cheers, Markus -- Markus Lervik Linux-administrator with a kungfoo grip Vaasa City Library - Regional Library [EMAIL PROTECTED] +358-6-325 3589 / +358-40-832 6709 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL / PHP Database Help
Hello, something that you can help is the follow try var_dump($newquery); then you see the complete query and run it in phpmyadmin. Jeroen - Original Message - From: Jonathan Underfoot [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, February 08, 2002 2:43 PM Subject: [PHP-DB] MySQL / PHP Database Help I'm trying to write a script that checks for multiple entries on a table in a database. So far I've been plagued by MySQL errors. I'm fairly confident my scripting is ok (Then again, I've been wrong before.) I think moreover there might be some difficulty with my theory. Then again, I could try and do this with MySQL join statements. Any feedback would be appreciated. $sqlquery = mysql_query(SELECT * FROM local_shows); while ($row = mysql_fetch_array($sqlquery)) { $newquery = mysql_query(SELECT * FROM local_shows WHERE show_date='$row[show_date]' AND venue='$row[venue]'); var_dump($newquery); /* for example to see the query */ while ($row2 = mysql_fetch_array($newquery)) { $num_rows = mysql_num_rows($row2); if ($num_rows1) { print etc etc (Do things with my $row2 data) I get loads of: Warning: Supplied argument is not a valid MySQL result resource in /home/ufr2/underfoot-www/admin/dupeshows.html on line 51 Can you not reselect in another while while selecting? Does that make any sense to anyone but me? I shouldent have to open another DB connection? Anyhow... your I would appreciate any help. -Jonathan -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] MySQL / PHP Database Help
Yes, you can re-select from the same database without opeing a new connection. I recommend that you print the contents od $newquery to verify it contains the string you think it should. Perhaps the apostrophes you've enclosed the $row[] variable are not expanding. -Original Message- From: Jonathan Underfoot [mailto:[EMAIL PROTECTED]] Sent: Friday, February 08, 2002 7:43 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] MySQL / PHP Database Help I'm trying to write a script that checks for multiple entries on a table in a database. So far I've been plagued by MySQL errors. I'm fairly confident my scripting is ok (Then again, I've been wrong before.) I think moreover there might be some difficulty with my theory. Then again, I could try and do this with MySQL join statements. Any feedback would be appreciated. $sqlquery = mysql_query(SELECT * FROM local_shows); while ($row = mysql_fetch_array($sqlquery)) { $newquery = mysql_query(SELECT * FROM local_shows WHERE show_date='$row[show_date]' AND venue='$row[venue]'); while ($row2 = mysql_fetch_array($newquery)) { $num_rows = mysql_num_rows($row2); if ($num_rows1) { print etc etc (Do things with my $row2 data) I get loads of: Warning: Supplied argument is not a valid MySQL result resource in /home/ufr2/underfoot-www/admin/dupeshows.html on line 51 Can you not reselect in another while while selecting? Does that make any sense to anyone but me? I shouldent have to open another DB connection? Anyhow... your I would appreciate any help. -Jonathan -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL / PHP Database Help
Jonathan, I'm trying to write a script that checks for multiple entries on a table in a database. So far I've been plagued by MySQL errors. I'm fairly confident my scripting is ok (Then again, I've been wrong before.) I think moreover there might be some difficulty with my theory. Then again, I could try and do this with MySQL join statements. Any feedback would be appreciated. ... Warning: Supplied argument is not a valid MySQL result resource in /home/ufr2/underfoot-www/admin/dupeshows.html on line 51 I notice that others have addressed your PHP/interfacing issues... You asked about theory. The current solution will require n+1 calls to the database (where there are n-rows in the local_shows table). That's quite 'expensive'. Which is likely to be the 'best tool for the job' - an external scripting language (PHP) or the RDBMS itself (MySQL)? Consider a 'MySQL-oriented' solution:- 1 if the two fields (show_date and venue) were made into a UNIQUE index, then the check would become superfluous because MySQL would ensure the situation never arose - at the cost of the time to perform the check/index insertion at every row INSERT or UPDATE (although you may gain a speed increase for certain SELECTS) 2 performing the existing PHP routine using SQL - you show only a list of 'duplicates' (and no DELETE), so: select show_date, venue, count(*) as freq from local_shows group by show_date, venue having freq1 will give you what you have attempted to code thus far. (you may wish/need to juggle the sequence of show_date and venue to suit) Regards, =dn -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL / PHP Database Help
What does bool(false) mean? Thats off the vardump -J - Original Message - From: Jeroen Timmers [EMAIL PROTECTED] To: Jonathan Underfoot [EMAIL PROTECTED] Cc: [PHP-DB] [EMAIL PROTECTED] Sent: Friday, February 08, 2002 8:58 AM Subject: Re: [PHP-DB] MySQL / PHP Database Help Hello, something that you can help is the follow try var_dump($newquery); then you see the complete query and run it in phpmyadmin. Jeroen - Original Message - From: Jonathan Underfoot [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, February 08, 2002 2:43 PM Subject: [PHP-DB] MySQL / PHP Database Help I'm trying to write a script that checks for multiple entries on a table in a database. So far I've been plagued by MySQL errors. I'm fairly confident my scripting is ok (Then again, I've been wrong before.) I think moreover there might be some difficulty with my theory. Then again, I could try and do this with MySQL join statements. Any feedback would be appreciated. $sqlquery = mysql_query(SELECT * FROM local_shows); while ($row = mysql_fetch_array($sqlquery)) { $newquery = mysql_query(SELECT * FROM local_shows WHERE show_date='$row[show_date]' AND venue='$row[venue]'); var_dump($newquery); /* for example to see the query */ while ($row2 = mysql_fetch_array($newquery)) { $num_rows = mysql_num_rows($row2); if ($num_rows1) { print etc etc (Do things with my $row2 data) I get loads of: Warning: Supplied argument is not a valid MySQL result resource in /home/ufr2/underfoot-www/admin/dupeshows.html on line 51 Can you not reselect in another while while selecting? Does that make any sense to anyone but me? I shouldent have to open another DB connection? Anyhow... your I would appreciate any help. -Jonathan -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] MySQL / PHP Database Help
You don't need to use var_dump. Just use the following statements: $newquery = mysql_query(SELECT * FROM local_shows WHERE show_date='$row[show_date]' AND venue='$row[venue]'); print $newquery; -Original Message- From: Jonathan Underfoot [mailto:[EMAIL PROTECTED]] Sent: Friday, February 08, 2002 8:48 AM To: Jeroen Timmers Cc: [PHP-DB] Subject: Re: [PHP-DB] MySQL / PHP Database Help What does bool(false) mean? Thats off the vardump -J - Original Message - From: Jeroen Timmers [EMAIL PROTECTED] To: Jonathan Underfoot [EMAIL PROTECTED] Cc: [PHP-DB] [EMAIL PROTECTED] Sent: Friday, February 08, 2002 8:58 AM Subject: Re: [PHP-DB] MySQL / PHP Database Help Hello, something that you can help is the follow try var_dump($newquery); then you see the complete query and run it in phpmyadmin. Jeroen - Original Message - From: Jonathan Underfoot [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, February 08, 2002 2:43 PM Subject: [PHP-DB] MySQL / PHP Database Help I'm trying to write a script that checks for multiple entries on a table in a database. So far I've been plagued by MySQL errors. I'm fairly confident my scripting is ok (Then again, I've been wrong before.) I think moreover there might be some difficulty with my theory. Then again, I could try and do this with MySQL join statements. Any feedback would be appreciated. $sqlquery = mysql_query(SELECT * FROM local_shows); while ($row = mysql_fetch_array($sqlquery)) { $newquery = mysql_query(SELECT * FROM local_shows WHERE show_date='$row[show_date]' AND venue='$row[venue]'); var_dump($newquery); /* for example to see the query */ while ($row2 = mysql_fetch_array($newquery)) { $num_rows = mysql_num_rows($row2); if ($num_rows1) { print etc etc (Do things with my $row2 data) I get loads of: Warning: Supplied argument is not a valid MySQL result resource in /home/ufr2/underfoot-www/admin/dupeshows.html on line 51 Can you not reselect in another while while selecting? Does that make any sense to anyone but me? I shouldent have to open another DB connection? Anyhow... your I would appreciate any help. -Jonathan -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL / PHP Database Help
you need to print the qeury and i guess you print the result in the var_dump i use always var_dump instead a print because the var_dump have more info. jeroen - Original Message - From: Jonathan Underfoot [EMAIL PROTECTED] To: Jeroen Timmers [EMAIL PROTECTED] Cc: [PHP-DB] [EMAIL PROTECTED] Sent: Friday, February 08, 2002 3:47 PM Subject: Re: [PHP-DB] MySQL / PHP Database Help What does bool(false) mean? Thats off the vardump -J - Original Message - From: Jeroen Timmers [EMAIL PROTECTED] To: Jonathan Underfoot [EMAIL PROTECTED] Cc: [PHP-DB] [EMAIL PROTECTED] Sent: Friday, February 08, 2002 8:58 AM Subject: Re: [PHP-DB] MySQL / PHP Database Help Hello, something that you can help is the follow try var_dump($newquery); then you see the complete query and run it in phpmyadmin. Jeroen - Original Message - From: Jonathan Underfoot [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, February 08, 2002 2:43 PM Subject: [PHP-DB] MySQL / PHP Database Help I'm trying to write a script that checks for multiple entries on a table in a database. So far I've been plagued by MySQL errors. I'm fairly confident my scripting is ok (Then again, I've been wrong before.) I think moreover there might be some difficulty with my theory. Then again, I could try and do this with MySQL join statements. Any feedback would be appreciated. $sqlquery = mysql_query(SELECT * FROM local_shows); while ($row = mysql_fetch_array($sqlquery)) { $newquery = mysql_query(SELECT * FROM local_shows WHERE show_date='$row[show_date]' AND venue='$row[venue]'); var_dump($newquery); /* for example to see the query */ while ($row2 = mysql_fetch_array($newquery)) { $num_rows = mysql_num_rows($row2); if ($num_rows1) { print etc etc (Do things with my $row2 data) I get loads of: Warning: Supplied argument is not a valid MySQL result resource in /home/ufr2/underfoot-www/admin/dupeshows.html on line 51 Can you not reselect in another while while selecting? Does that make any sense to anyone but me? I shouldent have to open another DB connection? Anyhow... your I would appreciate any help. -Jonathan -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL / PHP Database Help
Jonathan, [have put the cc back to the list] Is it possible to make BOTH the date and venue into a single unique index? =Why not? Like a good woman, treat her right, and SQL will do almost anything for you: 6.5.3 CREATE TABLE Syntax CREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name [(create_definition,...)] [table_options] [select_statement] create_definition: col_name type [NOT NULL | NULL] [DEFAULT default_value] [AUTO_INCREMENT] [PRIMARY KEY] [reference_definition] orPRIMARY KEY (index_col_name,...) orKEY [index_name] (index_col_name,...) orINDEX [index_name] (index_col_name,...) ... Note the ellipses (...) at the end of that last line - many people are used to writing [PRIMARY] KEY or INDEX immediately after field name and definition, forgetting that if it is a separate clause of the CREATE stmt, multiple columns may be specified! (Not that this works for me.) But I'm qcurious about this. I understand where this could be useful as a single unique index.. (as opposed to two unique indexes) Is this possible? How so? =yes it is possible, as above. =the short answer is: wherever you find yourself doing SELECT...WHERE field/index-condition1 AND field/index-condition2 =If only the first field/column is indexed, then obviously the SELECT will be faster than when accessing an unindexed table. However if there is a large fan-out between the two fields columns, (ie there are a large number of different values in field/column2 which share the same value in field/column1) then it may pay to combine the two fields into a single index for even faster results. Of course, the smaller your table, the harder it is to 'see' any return on the investment! (In my case multiple entries are ok, just as long as I can run a report to spot them, and then edit them which usually requires human interaction.) =If your system's data-entry stage is time-constrained then I would be tempted to agree. Otherwise conventional wisdom suggests that it is better to prevent 'dirty' data entering the system or data integrity issues creeping in, than it is to develop a strategy to 'clean' the db post-fact. Usually the person entering the data knows most about it - or has the best opportunity to ask the 'data source' for clarification! Your second suggestion worked rather well... although its not quite generating the output that would be best suited to me. The MySQL docs on Group By and Count are quite weak.. do you have something else you could send me / can you explain these commands. I was sure there is / was a way to do it in MySQL my SQL just isn't what it should be. =if you post the code you've developed thus far, and some sample source data and results, together with some specific criticism, we might be able to help with issues like best suited, or tweak the code I sent earlier to provide for situations that may not have been evident (at least to me) in your first post. =GROUP BY and COUNT() can be combined in many different ways, so what seems straightforward on the surface can yield enormous power when you start to tinker under the hood. I assume what you mean is that the manual is not really a tutorial. =Apart from the manual, I use books (I've picked up a few over the years - some probably now out of print; Paul DuBois' MySQL is current and the most specific - and has a PHP interface chapter, plus other more-PHP books, eg Welling Thomson) and there are a number of tutorial web sites either covering SQL generally or MySQL in particular (start at the MySQL site or any search engine). =Regards, =dn -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] mysql - php DATE QUESTION...
Check the MySQL manual DATE/TIME functions. try: DELETE FROM mytable WHERE date_column ( CURRDATE()-30 ) -Original Message- From: Koutsogiannopoulos Karolos [mailto:[EMAIL PROTECTED]] Sent: Wednesday, October 03, 2001 7:41 AM To: 'Php-Db (E-mail) Subject: [PHP-DB] mysql - php DATE QUESTION... Can someone offer some help...? Lets say i have a date collumn in a mysql table that includes dates that get stored each time i enter an entry... How can i check when i enter the page that displays the entries to delete all entries older than 30 days? thanks. -- 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 - php DATE QUESTION...
sorry for misspelling: curdate() -Original Message- From: Rick Emery [mailto:[EMAIL PROTECTED]] Sent: Wednesday, October 03, 2001 8:23 AM To: 'Koutsogiannopoulos Karolos' Cc: [EMAIL PROTECTED] Subject: RE: [PHP-DB] mysql - php DATE QUESTION... Check the MySQL manual DATE/TIME functions. try: DELETE FROM mytable WHERE date_column ( CURRDATE()-30 ) -Original Message- From: Koutsogiannopoulos Karolos [mailto:[EMAIL PROTECTED]] Sent: Wednesday, October 03, 2001 7:41 AM To: 'Php-Db (E-mail) Subject: [PHP-DB] mysql - php DATE QUESTION... Can someone offer some help...? Lets say i have a date collumn in a mysql table that includes dates that get stored each time i enter an entry... How can i check when i enter the page that displays the entries to delete all entries older than 30 days? thanks. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP-DB] MYSQL/PHP what is the difference between unset() and mysql_free_result() ?
You free-up the dataspace pointed-to by $string with unset(). PHP knows that this variable points-to character data or numeric or whatever. unset() then releases the dataspace held by the $string itself and erases its name from the symbol table. Using mysql_free_result($string) will not work because $string does not point-to a result returned from a mysql_query(). After executing mysql_free_result($result), $result still exists in the symbol table. You would have to unset($result) to delete the pointer itself. -Original Message- From: Bas Jobsen [mailto:[EMAIL PROTECTED]] Sent: Wednesday, September 05, 2001 4:46 PM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] MYSQL/PHP what is the difference between unset() and mysql_free_result() ? Hello, unset() simply deletes the pointer to the data without releasing the space held by the data. mysql_free_result() releases the data storage pointed-to by the $result pointer. This is important because $result could be pointing-to a dataspace containing a large number or rows returned by the mysql_query(). You WANT to recover this dataspace. Well, oke, tnx. But if unset() doesn't releas the data-space, what then is it's functionality? only voor tests like: if(isset($var)) ;? And how can i free the data-space from a string or somting like that? b.e. $string=a very long string; free($string);#? #could i use mysql_free_result($string); Tnx, Bas -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] MYSQL/PHP what is the difference between unset() and mysql_free_result() ?
And how can i free the data-space from a string or somting like that? b.e. $string=a very long string; free($string);#? #could i use mysql_free_result($string); Maybe I can use: unset($string=); or unset($array=array()); to free the data-space also -- 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/PHP what is the difference between unset() and mysql_free_result() ?
nope. see my previous reply -Original Message- From: Bas Jobsen [mailto:[EMAIL PROTECTED]] Sent: Thursday, September 06, 2001 10:11 AM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] MYSQL/PHP what is the difference between unset() and mysql_free_result() ? And how can i free the data-space from a string or somting like that? b.e. $string=a very long string; free($string);#? #could i use mysql_free_result($string); Maybe I can use: unset($string=); or unset($array=array()); to free the data-space also -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP-DB] MYSQL/PHP what is the difference between unset() and mysql_free_result() ?
unset() simply deletes the pointer to the data without releasing the space held by the data. mysql_free_result() releases the data storage pointed-to by the $result pointer. This is important because $result could be pointing-to a dataspace containing a large number or rows returned by the mysql_query(). You WANT to recover this dataspace. -Original Message- From: Bas Jobsen [mailto:[EMAIL PROTECTED]] Sent: Wednesday, September 05, 2001 4:00 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] MYSQL/PHP what is the difference between unset() and mysql_free_result() ? Hello, Maybe someone can tell me, the difference b.e. $result = mysql_query ($query); unset($result); #or better mysql_free_result($result); tnx, Bas Jobsen -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] MYSQL/PHP what is the difference between unset() and mysql_free_result() ?
Hello, unset() simply deletes the pointer to the data without releasing the space held by the data. mysql_free_result() releases the data storage pointed-to by the $result pointer. This is important because $result could be pointing-to a dataspace containing a large number or rows returned by the mysql_query(). You WANT to recover this dataspace. Well, oke, tnx. But if unset() doesn't releas the data-space, what then is it's functionality? only voor tests like: if(isset($var)) ;? And how can i free the data-space from a string or somting like that? b.e. $string=a very long string; free($string);#? #could i use mysql_free_result($string); Tnx, Bas -- 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-php
If I were U I would convert it to UNIX date first subtract and then restore to normal format what do U think !?!?! Mikail [EMAIL PROTECTED] escreveu na mensagem 008c01c0d2f2$2e0df880$bb02a8c0@maz">news:008c01c0d2f2$2e0df880$bb02a8c0@maz... hi, I'm a newbie from Italy I use php with mysql and I need to find a way to visualize the difference between two dates. For ex in a row I have column [A] and column [B] [A] 2001-05-02 10:00:00 [B] 2001-05-02 10:01:30 If I use SELECT TIME_FORMAT([B]-[A], '%H:%i:%s') result is 00:01:30 But it's the same if I use SELECT TIME_FORMAT([A]-[B], '%H:%i:%s') why? I need a - (minus)! Thanks -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] mysql/php select using date in where clause
Here's how I'd do it: SELECT * FROM customers WHERE Site='egebjergnet' AND TO_DAYS(NOW()) - TO_DAYS(date_column) = '45' where date_column contains record dates... Martin Dan Eskildsen [EMAIL PROTECTED] wrote in message 9crq7l$mfb$[EMAIL PROTECTED]">news:9crq7l$mfb$[EMAIL PROTECTED]... ***NEWBIE ALERT*** (I am only very new at this) PHP and MySQL OK - I have a table with data and one of the fields is a Date field. Now I would like to SELECT all records where the date is less that 45 days old. Eh, How do I do that? I have tried this: #Declaring variables $today=date(Y-m-d); $lastmonth = $today-30 $query = SELECT * FROM customers WHERE Site='egebjergnet' AND DatoOprettet'$lastmonth' ORDER BY FirmaNavn; AND I get an error, of course. hmmm -- == Regards from Denmark, Europe Please cc your reply to [EMAIL PROTECTED] == I haven't lost my mind, I've got it backed up on TAPE somewhere... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] mysql/php select using date in where clause
IT works! Thanks! martin helie [EMAIL PROTECTED] skrev i en meddelelse 9crqud$voj$[EMAIL PROTECTED]">news:9crqud$voj$[EMAIL PROTECTED]... Here's how I'd do it: SELECT * FROM customers WHERE Site='egebjergnet' AND TO_DAYS(NOW()) - TO_DAYS(date_column) = '45' where date_column contains record dates... Martin Dan Eskildsen [EMAIL PROTECTED] wrote in message 9crq7l$mfb$[EMAIL PROTECTED]">news:9crq7l$mfb$[EMAIL PROTECTED]... ***NEWBIE ALERT*** (I am only very new at this) PHP and MySQL OK - I have a table with data and one of the fields is a Date field. Now I would like to SELECT all records where the date is less that 45 days old. Eh, How do I do that? I have tried this: #Declaring variables $today=date(Y-m-d); $lastmonth = $today-30 $query = SELECT * FROM customers WHERE Site='egebjergnet' AND DatoOprettet'$lastmonth' ORDER BY FirmaNavn; AND I get an error, of course. hmmm -- == Regards from Denmark, Europe Please cc your reply to [EMAIL PROTECTED] == I haven't lost my mind, I've got it backed up on TAPE somewhere... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP 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 -- php
At 21:20 8-4-01 +0200, Adam wrote: Hello, I have a fresh instalation of mysql from the ditribution of RH7. What do I have to put into the user and host tables so that I can use MySQL through PHP (I doesn't have to be super-secure, just so that not everybody could get to my databases) I don't claim a very good long or short term memory.. but this is the second time I see this question.. Keep a question in the proper location two seperate threads is a bad idea. People on the installphp list don't know if you already received an answer.. The same goes for the PHP DB list.. Bye, B. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP-DB] MySQL/PHP Form Addslashes() command
I am a beginner but did it like this, with a little help from my friends!! $query = "INSERT INTO guests "; $query .= "(guest_id, guest_name, "; $query .= "guest_email, guest_time, guest_message) "; $query .= "values(, '$name', '$email', NULL, '" . str_replace("\n","br", $message) . "')"; Where $message is the TEXTAREA box submitted All the best Lisa -Original Message- From: James Smith [mailto:[EMAIL PROTECTED]] Sent: Thursday, January 25, 2001 8:50 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] MySQL/PHP Form Addslashes() command Alright, you have a textarea in a form, say some one right this: Today, during the meeting blah blah blah... (now they want to start a new paragraph, so they press enter twice.) After the construction meeting blah blah blah... Ok... Now the question. The addslashes() command won't add the NULL spots to make it a new paragraph when you open this row in a page. How do I get that to work... Thank You, James Smith __ Do You Yahoo!? Yahoo! Auctions - Buy the things you want at great prices. http://auctions.yahoo.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]
Re: [PHP-DB] MySQL/PHP Form Addslashes() command
There is the "nl2br()" function too : // From php manual : nl2br -- Converts new lines to HTML line breaks. Description string nl2br(string string); Returns string with 'BR' inserted before all new lines. HTH Jayme. http://www.conex.com.br/jjeffman -Mensagem Original- De: Rubanowicz, Lisa [EMAIL PROTECTED] Para: 'James Smith' [EMAIL PROTECTED]; [EMAIL PROTECTED] Enviada em: sexta-feira, 26 de janeiro de 2001 07:59 Assunto: RE: [PHP-DB] MySQL/PHP Form Addslashes() command I am a beginner but did it like this, with a little help from my friends!! $query = "INSERT INTO guests "; $query .= "(guest_id, guest_name, "; $query .= "guest_email, guest_time, guest_message) "; $query .= "values(, '$name', '$email', NULL, '" . str_replace("\n","br", $message) . "')"; Where $message is the TEXTAREA box submitted All the best Lisa -Original Message- From: James Smith [mailto:[EMAIL PROTECTED]] Sent: Thursday, January 25, 2001 8:50 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] MySQL/PHP Form Addslashes() command Alright, you have a textarea in a form, say some one right this: Today, during the meeting blah blah blah... (now they want to start a new paragraph, so they press enter twice.) After the construction meeting blah blah blah... Ok... Now the question. The addslashes() command won't add the NULL spots to make it a new paragraph when you open this row in a page. How do I get that to work... Thank You, James Smith __ Do You Yahoo!? Yahoo! Auctions - Buy the things you want at great prices. http://auctions.yahoo.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]
Re: [PHP-DB] MySQL/PHP Form Addslashes() command
Hello! JJeffman wrote: There is the "nl2br()" function too : // From php manual : nl2br -- Converts new lines to HTML line breaks. Description string nl2br(string string); Returns string with 'BR' inserted before all new lines. Sure, but never add any html tag to the data before insert into the database. Instead, use this function when you output the text. Mage -- 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]