[PHP-DB] temporary files
Im trying to create a way of storing php scripts in a mySQL database and then execute them using temporary files as executable script buffers.. Ive got a mysql table with 4 fields: execID, execName, execDesc and execProc The last one contains php code. This is what i have so far: ?php mysql_connect($host,$user,$pw); mysql_select_db($db); $query = SELECT execProc FROM exec WHERE execID = 1; $result = mysql_query($query); while($row = mysql_fetch_array($result)) { $proc = $row['execProc']; } $handle = tmpfile(); fwrite($handle, $proc); include(name of the temporary file); fclose($handle); ? But i need to get the name of the tempfile in order to include it.. all i have now is the handle_id any help appreciated. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] temporary files
You might consider using tmpnam() instead. tmpnam() doesn't give you a file handle (like tmpfile() does), but rather a file name. Just pass it a directory (like /tmp) and a prefix to help identify it (can be ). It returns the unique file's name, and you could open a file handle to it with fopen(). Keep in mind that you have to unlink() it when you're done. Hope this helps! --Dave Lars Tvedt wrote: Im trying to create a way of storing php scripts in a mySQL database and then execute them using temporary files as executable script buffers.. Ive got a mysql table with 4 fields: execID, execName, execDesc and execProc The last one contains php code. This is what i have so far: ?php mysql_connect($host,$user,$pw); mysql_select_db($db); $query = SELECT execProc FROM exec WHERE execID = 1; $result = mysql_query($query); while($row = mysql_fetch_array($result)) { $proc = $row['execProc']; } $handle = tmpfile(); fwrite($handle, $proc); include(name of the temporary file); fclose($handle); ? But i need to get the name of the tempfile in order to include it.. all i have now is the handle_id any help appreciated. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] mysql database ****.sql thru a php script
I have a large sql file that I would like to load into mysql database from a remote client. Is there a way through a php script to do this? I have tried $query = contents of database.sql ; (where the contents of the sql file was pasted into the query) then $results = mysql_db_query(database, $query); but it fails. Any ideas or experience? R Race -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] DB CODEING HELP!!!!!
this is bugging me. I have tried everything and I cant develop the code without an error. Can someone plese write me simple code that will go through a table and print 3 collums of that table? I cant figure it out
[PHP-DB] finding out the date of the first day of the current week
I am trying to make a small function that will me the date in Y-m-d of the start of the current week (the sunday) I have only the idea of doing it by making a long drawn out script with if, elseif clauses for every day of the week... and then doing something like if ( date('D') = mon ) { $sunday = mktime (0,0,0,date(m) ,date(d)-1,date(Y)); } does anyone know a simple way to do this _ Overloaded with spam? With MSN 8, you can filter it out http://join.msn.com/?page=features/junkmailpgmarket=en-gbXAPID=32DI=1059 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] DB CODEING HELP!!!!!
this is bugging me. I have tried everything and I cant develop the code without an error. Can someone plese write me simple code that will go through a table and print 3 collums of that table? I cant figure it out I don't know which database you're using but say for example it was MySQL here's a very quick and dirty example ? $link = mysql_connect('localhost','user','password') or die(mysql_error()); if (mysql_select_db('mydatabase',$link)) { $rs = mysql_query('select col1, col2, col3 from mytable') or die (mysql_error()); $num = mysql_num_rows($rs); for ($i=0;$i$num;$i++) { $row = mysql_fetch_assoc($rs); echo 'Col 1: '.$row['col1'].' Col 2: '.$row['col2'].' Col 3: '.$row['col3'].'br /'; } } mysql_close($link); ? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] finding out the date of the first day of the current week
I am trying to make a small function that will me the date in Y-m-d of the start of the current week (the sunday) I have only the idea of doing it by making a long drawn out script with if, elseif clauses for every day of the week... and then doing something like if ( date('D') = mon ) { $sunday = mktime (0,0,0,date(m) ,date(d)-1,date(Y)); Try this: $Sunday = mktime(0,0,0,date('m'),date('d')-date('w'),date('Y')); ---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 database ****.sql thru a php script
I have a large sql file that I would like to load into mysql database from a remote client. Is there a way through a php script to do this? I have tried $query = contents of database.sql ; (where the contents of the sql file was pasted into the query) then $results = mysql_db_query(database, $query); but it fails. Any ideas or experience? You can only run one query at a time. If it is a really large file, you'll probably want to make an exec() call to have mysql load the file itself. $result = `mysql -uroot -ppassword database_name filename.sql` Those are backticks, not single quotes. $result should be empty if everything went well. Adapt to your needs. Or, here's part of a little script I wrote that'll read and execute *.sql files (from MySQLDump). The str_replace() adds in a table prefix. This works with my script using ADOdb, so adapt to your needs. $sql_file = 'survey2.inc'; $file = file($sql_file); foreach($file as $line) { if($line{0} != '#' strlen($line) 0) { $query .= trim($line); if(substr($query,-1) == ;) { $query = str_replace('%PREFIX%',$survey-CONF['db_tbl_prefix'],$query); $query = substr($query,0,-1); $rs = $survey-db-Execute($query); if($rs === FALSE) { $error = TRUE; echo 'brbr' . $survey-db-ErrorMsg(); } $query = ''; } } } ---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] DB CODEING HELP!!!!!
Here, this will pull data and make a select box. Adjust as needed. $result = mysql_query(SELECT company_id, company_name FROM company_table ORDER BY company_name, $db); if (mysql_num_rows($result) 0) { echo SELECT SIZE='5' NAME='edit_company_id'\n\tOPTION VALUE=''\n; while ( $row = mysql_fetch_array($result,MYSQL_ASSOC) ) { echo \tOPTION VALUE='.$row['company_id'].'; if ($row['company_id'] == $edit_company_id) { echo SELECTED; } echo .$row['company_name'].\n; } echo /SELECT; } else echo No Companies Defined\n; -Original Message- From: Mike Delorme [mailto:[EMAIL PROTECTED] Sent: Sunday, March 23, 2003 1:11 PM To: MySQL PHP Database Help Subject: [PHP-DB] DB CODEING HELP! this is bugging me. I have tried everything and I cant develop the code without an error. Can someone plese write me simple code that will go through a table and print 3 collums of that table? I cant figure it out -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] when click on button, how renew info on page?
hello everyone, with this code, a table is loaded with info from the mysql db with id = '1'. but now i want to make a button, and when it is clicked, he has to renew the table with the info from the db with id ='2' does anyone know has this should be done? thanks in advance! Greetings, Gert Vonck html head title /title /head body ?php mysql_connect(localhost,root,) or die (Could not connect to database); mysql_select_db(oh) or die (problems selecting database); ? h2Info_DJ/h2 ?php $result0 = mysql_query(SELECT naam,leeftijd,muziekgenre,favoriet_liedje,motto,picture_right FROM info_dj WHERE id='1') or die (mysql_error()); printtable border=1\n; $field_count = mysql_num_fields($result0); while ($get_info0 = mysql_fetch_row($result0)) { print trtdtable; for($i = 0; $i $field_count - 1 ; $i++){ $value = $get_info0[$i]; $column = mysql_field_name($result0,$i); print \ttrtd$column/tdtd$value/td/tr\n; } $last = $field_count - 1; print /table/tdtdimg src='$get_info0[$last]'/td/tr\n; } print /table\n; mysql_close(); ? /body /html _ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] mysql timestamps
how do i change the format of a MySQL timestamp (i.e hh:mm:ss DD/MM/ instead of MMDDhhmmss) retrieved from a mysql database with php? thanks in advance -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] mysql timestamps
how do i change the format of a MySQL timestamp (i.e hh:mm:ss DD/MM/ instead of MMDDhhmmss) retrieved from a mysql database with php? Use SELECT TO_UNIXTIME(your_column) FROM table ... And then use date() in PHP to format the result to your liking. Or, you can use DATE_FORMAT() in your query to format the result to your liking. ---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
[PHP-DB] Joining two talbes
Can someone help me understand joining tables, and how I can do this: SELECT clients.business_name, details.quoted_price, details.finish_date FROM clients, details WHERE clients.client_id = details.client_id = . $HTTP_GET_VARS['id']; Can I do that? thx -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Joining two talbes
Can someone help me understand joining tables, and how I can do this: SELECT clients.business_name, details.quoted_price, details.finish_date FROM clients, details WHERE clients.client_id = details.client_id = . $HTTP_GET_VARS['id']; Since when can you do WHERE var1 = var2 = var3 ?? You need to do it such as: WHERE var1 = var2 AND var1 = var3 ---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
[PHP-DB] Setting up arrays from queries
When I execute this function: function getTitles() { $this - openConnection(); $title_query = select name from categories; $title_result = mysql_query($title_query); echo here is title_result: .mysql_affected_rows(); $i = 0; while ($titles = mysql_fetch_array($title_result, MYSQL_ASSOC)){ $i++;//titles becomes an associative array } echo #of iterations: .$i; echo here is titles: .end($titles); echo \n here is titles: .prev($titles); echo \n here is titles: .$this-titles[2]; mysql_free_result($title_result); mysql_close(); } The line: while ($titles = mysql_fetch_array($title_result, MYSQL_ASSOC)){ Does not give me an array, any ideas? Here is the error I get: here is title_result: 6#of iterations: 6 Warning: end() [function.end]: Passed variable is not an array or object in /Users/timbest/Sites/cajunmikes/inc/menupage.php on line 16 I do get a succcessful connection because the of the iterations and the title_result which is from mysql_affected_rows(); Thanks, tired Tim -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] when click on button, how renew info on page?
Yeah.. U Just a need a normal Button, target to the same site with id+1 -Ursprüngliche Nachricht- Von: gert vonck [mailto:[EMAIL PROTECTED] Gesendet: Montag, 24. März 2003 00:28 An: [EMAIL PROTECTED] Betreff: [PHP-DB] when click on button, how renew info on page? hello everyone, with this code, a table is loaded with info from the mysql db with id = '1'. but now i want to make a button, and when it is clicked, he has to renew the table with the info from the db with id ='2' does anyone know has this should be done? thanks in advance! Greetings, Gert Vonck html head title /title /head body ?php mysql_connect(localhost,root,) or die (Could not connect to database); mysql_select_db(oh) or die (problems selecting database); ? h2Info_DJ/h2 ?php $result0 = mysql_query(SELECT naam,leeftijd,muziekgenre,favoriet_liedje,motto,picture_right FROM info_dj WHERE id='1') or die (mysql_error()); printtable border=1\n; $field_count = mysql_num_fields($result0); while ($get_info0 = mysql_fetch_row($result0)) { print trtdtable; for($i = 0; $i $field_count - 1 ; $i++){ $value = $get_info0[$i]; $column = mysql_field_name($result0,$i); print \ttrtd$column/tdtd$value/td/tr\n; } $last = $field_count - 1; print /table/tdtdimg src='$get_info0[$last]'/td/tr\n; } print /table\n; mysql_close(); ? /body /html _ -- 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