Re: [PHP-DB] Advice for dataupload
Addressed to: Michael Andersson [EMAIL PROTECTED] [EMAIL PROTECTED] ** Reply to note from Michael Andersson [EMAIL PROTECTED] Fri, 12 Apr 2002 11:58:31 +0200 Jason Wong [EMAIL PROTECTED] skrev i meddelandet news:[EMAIL PROTECTED]... On Monday 08 April 2002 19:15, Michael Andersson wrote: What happens to a blob field with lets say a image when dumping a mysql table to a file? I don't use BLOB fields. You try it and let me know ;-) Well now i tried, and it doesnt work at all, just so you know :) So now i have to fugure out a way to dump the table with blob:s in it to a file cause my isp dont allow me to dump to another mysql dbase over the net or any other way exept for a file... The FROM ISP doesn't allow it. What about the TO ISP? If you can get them to allow access from the old server: $Con1 = mysql_connect( 'oldhost', 'olduser', 'oldpassword' ); mysql_select_db( 'olddbname', $Con1 ); $Con2 = mysql_connect( 'newhost', 'newuser', 'newpassword' ); mysql_select_db( 'newdbname', $Con2 ); $R1 = mysql_query( SELECT * FROM tablename, $Con1 ); while( $Data = mysql_fetch_array( $R1 ); mysql_query( INSERT INTO tablename ~data~, $Con2 ); } Of course you will need to translate '~data~' into a valid SET or VALUES() block for each table, but this may allow you to get your data out of the old ISP's server without their help. Rick Rick Widmer Internet Marketing Specialists http://www.developersdesk.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Advice for dataupload
On Monday 08 April 2002 19:15, Michael Andersson wrote: What happens to a blob field with lets say a image when dumping a mysql table to a file? I don't use BLOB fields. You try it and let me know ;-) 3) Install phpMyAdmin on both machines. How do i replicate 2 mysql db:s with phpmyadmin? Have you actually installed it yet? It's pretty straightforward and self-explanatory. -- Jason Wong - Gremlins Associates - www.gremlins.com.hk Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * /* Your best consolation is the hope that the things you failed to get weren't really worth having. */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Advice for dataupload
Dear all, I have two design-identical database, one on my intranet, the other on the internet, is there any procedure that Synchronizes the content of two databases? I'm using PHP applications and MySQL Database, WindowsNT4 IIS Please advice Best Regards Hayan -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Advice for dataupload
On Sunday 07 April 2002 17:08, Hayan Al Mamoun wrote: Dear all, I have two design-identical database, one on my intranet, the other on the internet, is there any procedure that Synchronizes the content of two databases? I'm using PHP applications and MySQL Database, WindowsNT4 IIS You've got several options and it all depends on how synchronised you need/want them to be. If you need up-to-the-minute sync then the mysql replication feature is the only way to go. Other methods are: Using mysqldump: 1) Dump from local mysql straight to remote mysql: mysqldump --opt name_of_database | mysql --compress -h remote.mysql.host name_of_database 2) Dump from local mysql and compress to file: mysqldump --opt name_of_db | gzip name_of_db.gz Then ftp to remote, decompress and import. 3) Install phpMyAdmin on both machines. -- Jason Wong - Gremlins Associates - www.gremlins.com.hk Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * /* BARBARA STANWYCK makes me nervous!! */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Advice to PHP beginners
Just some advice... You should use a consistent programming style, especially with PHP. You can read some guys advice here. http://www.phpbuilder.com/columns/tim20010101.php3?page=1 Some of the advantages of having a consistent style, is when you are looking for bugs. If you look over your code and see something unusual, then you can target that area to see if it is the culprit. If you don't have a consistent style, then sometimes that can cause serious heartache, as everything will look unusual. A few issues that trip up most people when beginning to use PHP, is the syntax errors. Usually these arise from quote issues, to semi-colon and brace issues. A lot of this trouble can be avoided (or easily debugged) by simply using tabs to your advantage. Consider the following: ?php if ($condition){ echo correct;} else { echo 'what'; if (!$condition2){ include 'thing.php'; while (!$dead) { if ($jam!= $yes){ $dead = true; } else{ for ($i=0;$i100;$i++) { $thing = processSomething('something', something2); $string = 'something'.$here.too; } ? Technically I *think* this would be syntactically correct, but if I was looking for a bug, I would be shot in the foot. A better way to write this would be the following: ?php if ($condition){ echo correct; } else { echo what; if (!$condition2){ include ('thing.php'); while (!$dead){ if ($jam != $yes){ $dead = true; } else { for ($i=0;$i100;$i++){ $thing = processSomething(something, something2); $string = something $here too; } } } } } ? So its a couple more lines, but if I came back to that script a month or two months later trying to fix something, or add a new feature, it would be easy. Couple that style with comments and you're on fire!!! Hope this helps for someone out there... Adam -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: OT - [PHP-DB] Advice to PHP beginners
did the tabs get stripped in your mail, or is there a reason the code couldn't be written like the following? i'm curious, since this is the way i do 90% of my code - makes it easy to see what's going on... but i dunno about performance or parsing impact (never gave it much thought until now)...? newbily yours... ?php if ($condition){ echo correct; } else { echo what; if (!$condition2){ include ('thing.php'); while (!$dead){ if ($jam != $yes){ $dead = true; } else { for ($i=0;$i100;$i++){ $thing = processSomething(something, something2); $string = something $here too; } } } } } ? - Original Message - From: Adam Royle [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, March 27, 2002 4:44 PM Subject: [PHP-DB] Advice to PHP beginners Just some advice... You should use a consistent programming style, especially with PHP. You can read some guys advice here. http://www.phpbuilder.com/columns/tim20010101.php3?page=1 Some of the advantages of having a consistent style, is when you are looking for bugs. If you look over your code and see something unusual, then you can target that area to see if it is the culprit. If you don't have a consistent style, then sometimes that can cause serious heartache, as everything will look unusual. A few issues that trip up most people when beginning to use PHP, is the syntax errors. Usually these arise from quote issues, to semi-colon and brace issues. A lot of this trouble can be avoided (or easily debugged) by simply using tabs to your advantage. Consider the following: ?php if ($condition){ echo correct;} else { echo 'what'; if (!$condition2){ include 'thing.php'; while (!$dead) { if ($jam!= $yes){ $dead = true; } else{ for ($i=0;$i100;$i++) { $thing = processSomething('something', something2); $string = 'something'.$here.too; } ? Technically I *think* this would be syntactically correct, but if I was looking for a bug, I would be shot in the foot. A better way to write this would be the following: ?php if ($condition){ echo correct; } else { echo what; if (!$condition2){ include ('thing.php'); while (!$dead){ if ($jam != $yes){ $dead = true; } else { for ($i=0;$i100;$i++){ $thing = processSomething(something, something2); $string = something $here too; } } } } } ? So its a couple more lines, but if I came back to that script a month or two months later trying to fix something, or add a new feature, it would be easy. Couple that style with comments and you're on fire!!! Hope this helps for someone out there... Adam -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Advice On Building Dynamic MySQL Queries
I actually created an array of different conditions like: $ConditionsArray = array("Var1 500","Var2 1800","ID=43"); and then: $Conditions = join(" AND ", $ConditionsArray); This constructs: $Conditions = "Var1 500 AND Var2 1800 AND ID=43"; shrug Worked well for me. Jonathan Hilgeman -Original Message- From: JD Daniels [mailto:[EMAIL PROTECTED]] Sent: Thursday, April 19, 2001 10:41 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] Advice On Building Dynamic MySQL Queries I am building a query from a search form. This is the code I have now: if (!empty($whereclause)) { $whereclause=urldecode($whereclause); $whereclause=stripslashes($whereclause); } extract($HTTP_POST_VARS); if (!empty($Price)) { if(empty($whereclause)) { $whereclause.="Price$Price"; } else { $whereclause.=" AND 'Price $Price"; } } if (!empty($Area)) { if(empty($whereclause)) { $whereclause.="Area LIKE '$Area'"; } else { $whereclause.=" AND Area LIKE '$Area'"; } } if (!empty($MLS_Number)) { if(empty($whereclause)) { $whereclause.="MLS_Number LIKE '$MLS_Number'"; } else { $whereclause.=" AND MLS_Number LIKE '$MLS_Number'"; } } if (!empty($File_Number)) { if(empty($whereclause)) { $whereclause.="File_Number LIKE '$File_Number'"; } else { $whereclause.=" AND File_Number LIKE '$File_Number'"; } } if (!empty($Description)) { if(empty($whereclause)) { $whereclause.="Description LIKE '%$Description%'"; } else { $whereclause.=" AND Description LIKE '%$Description%'"; } } $query="SELECT lid,Price,Address,Area,Description,File_Number,Realtor_First_name FROM listings LEFT JOIN areas ON (listings.aid=areas.aid) LEFT JOIN realtors ON (listings.rid1=realtors.rid) LEFT JOIN prop_types ON (listings.ptid=prop_types.ptid) LEFT JOIN prop_styles ON (listings.psid=prop_styles.psid) WHERE $whereclause order by Price ASC"; #echo "$querybr"; if(empty($whereclause)) { echo"centerh2You Did Not Specify Anything To Search For!/h2br a href=\"javascript:history.back()\"Back/a/center"; } else { $results=$CONNECTION-Execute("$query") or DIE($CONNECTION-ErrorMsg()); $results__numRows=0; $results__totalRows=$results-RecordCount(); echo $results-Fields("aid"); echo "$querybrbr"; while ($results__numRows$results__totalRows) { #SNIP Display stuff $results__numRows++; $results-MoveNext(); } $results-Close(); } It Just became apparent that I am going to need to add a whole bunch more search criteria.. Does anyone have any advice/suggestions for getting rid of all those if statements? JD -- 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] Advice On Building Dynamic MySQL Queries
Thanks for the replies :) Victor's suggestion put me on the right track. (I still have trouble with language constructs) Heres what I have now.. All I need to do is name my form fields with the same name as the column names from the mysql table, and presto! now I can just add/remove from the search form without changing the code. (I hope.. It has worked so far). while (list ($key, $val) = each ($HTTP_POST_VARS)) { if (!is_int($key) $key!="Submit" $key!="submit" $key!="offset") { if (!empty($val)) { if (!empty($whereclause)) { if($key=="Price") { $whereclause.=" AND Price$val"; }else{ $whereclause.=" AND $key='$val'"; } } else { if($key=="Price") { $whereclause.=" Price$val"; }else{ $whereclause.=" $key='$val'"; } } } } } Thnaks JD -- 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] Advice On Building Dynamic MySQL Queries
Hello JD, on 19.04.2001 you wrote: I am building a query from a search form. This is the code I have now: if (!empty($whereclause)) { $whereclause=urldecode($whereclause); $whereclause=stripslashes($whereclause); } extract($HTTP_POST_VARS); if (!empty($Price)) { if(empty($whereclause)) --- blah blah blah --- It Just became apparent that I am going to need to add a whole bunch more search criteria.. Does anyone have any advice/suggestions for getting rid of all those if statements? JD what about using a foreach statement and going through all the variables you need like this ? $myvars = array('Price', 'Stuff', 'Thing'); foreach ($myvars as $varname) { if (!empty($$varname)) { // do funky stuff here } } HTH Victor -- 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] Advice On Building Dynamic MySQL Queries
My solution was almost as elegent... $query="select * from customers"; $queryand=false; if(!empty($f_Account)) { $query.=" WHERE upper(P.Account) like upper('$f_Account')"; $queryand=true; } if(!empty($f_First_Name)) { $query.=($queryand?" AND ":" WHERE ")."upper(p.First_Name) like upper('$f_First_Name')"; $queryand=true; } ... For searchs, case doesn't matter (in my example), but you do need to index your table accordingly for best results. Also note upper() is the oracle uppercase function. I believe the uppercase function varies from one RDBMS to another. "Victor Foitzik" [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Hello JD, on 19.04.2001 you wrote: if (!empty($Price)) { if(empty($whereclause)) { $whereclause.="Price$Price"; } else { $whereclause.=" AND 'Price $Price"; } } and even better would be: if (!empty($$varname)) { $whereclause .= ($whereclause ? ' AND ' : ''). "$varname =" . $$varname; } or something like this ;-) HTH Vic -- 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] advice
imp is really good, developed by the guys at horde http://www.horde.org/imp/ uses php and a mysql db. At 11:29 PM 2/20/01 -0800, Pedro M. S. Oliveira wrote: i need to set up a web mail service. i use pop, mysql, php and pearl. does anyone knows a program that would do the trick? i don't need to develop this as i know that there are alot of packages that do this, but i would like to know if any of you as experience with this kind of software. thank you all folks! *** Pedro Miguel Silva Oliveira Cell Phone: +351 96 5867227 SMS: [EMAIL PROTECTED] Email: [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] -- Beau Lebens - Web Master Insurance My Way, Your Friendly Online Broker (08) 9226 5888 http://www.insurancemyway.com.au/ -- 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]