[PHP-DB] Eliminating character sets from DB entry
Hi there everyone, Is there a way to allow Only English character sets in database entry with MySQL and PHP? I'm getting an awful lot of SPAM which is in Chinese/Japanese and i'd love to be able to block these charactersets from being inserted into my databases. Chris
[PHP-DB] listing question
Hi there everyone, I have a little problem, I could do this with 2 seperate queries but if I can do it with 1 then even better ;-) I have to list items in numeric order IF the field isn't empty (ie: 0 comes at the top, followed by 1 etc ) and that isn't an issue as PHP with MySQL makes that very easy - BUT here's the problem i'm having. Once it's gone through the list, any items that do NOT have a number value are tacked on to the end in no particular order, is it possible that those items that do NOT have any value in the numeric field can be listed in alphabetical order instead? So if they have 0 upwards they displays from the top, then the ones that do not have ANYTHING in that field would display after but alphabetically instead? I'm kind of lost on how to do this with a single query. Thanks everyone Chris
RE: [PHP-DB] listing question
Hi there, I tried something similar: $query = SELECT * FROM videos WHERE videomakers_website_url = '$x' AND privatepublic = 'public' AND producer_website LIKE '%$x%' OR videomakers_website_url LIKE '%$x%' ORDER BY videomakers_site_position ASC, video_title ASC LIMIT $offset, $item_perpage; $querytotal = SELECT count(*) FROM videos WHERE videomakers_website_url = '$x' AND privatepublic = 'public' AND producer_website LIKE '%$x%' OR videomakers_website_url LIKE '%$x%' ORDER BY videomakers_site_position ASC, video_title ASC; My problem is, it displays not alphabetical videos first and then LAST it displays the videos with numbers, and when I can get the numbers at the top of the listing, they are in the wrong order (IE: 0,1,2 is from the bottom up and not 0 being at the top, 1 being next and so on). Chris Is there something stopping you from specifying two columns to order results by, ie: select myNumeric , myText from myTable order by myNumeric asc, myText asc -- No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.1.385 / Virus Database: 268.4.1/308 - Release Date: 4/11/2006 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Database abuse help needed
Ahhh thank you everyone, I came up with the same solution - kind of, but I used about 5 more lines of code to achieve the same thing as below so I was on the same tracks just not quite as efficient :-) Chris Incorporating what Bastien said: $badWordsArray = array(these ,are, bad, words); foreach($_POST as $key = $value){ if( in_array($value, $badWordsArray) ){ //$value was found in $badWordsArray } } http://us2.php.net/in_array -Original Message- From: Chris Payne [mailto:[EMAIL PROTECTED] Sent: Thursday, March 09, 2006 8:40 PM To: php-db@lists.php.net Subject: RE: [PHP-DB] Database abuse help needed Thank you for that. And excuse the inexperience, but how would I use an Array with the below? I mean say I had words such as this,is,a,bad,word (Just as examples as I can't post what I'm trying to block on here) how would I loop through those to check if any of them exist and if they do THEN execute the error script? I'm not too good with Arrays - but I'm learning. Thank you Chris If you POST from your form use $_POST, or $_GET for a form GET foreach($_POST as $key = $value){ if( strpos($value, $findme) !== false ){ //$findme was found in $value } } http://php.net/manual/en/reserved.variables.php http://us2.php.net/manual/en/control-structures.foreach.php http://us2.php.net/strpos Yes, that's !== or === -Original Message- From: Chris Payne [mailto:[EMAIL PROTECTED] Sent: Thursday, March 09, 2006 5:21 PM To: php-db@lists.php.net Subject: [PHP-DB] Database abuse help needed Hi there everyone, Is there a better way I can do this? if ($email == [EMAIL PROTECTED] OR $subject == Rulez666 Basically, if I have data coming from a form to a DB, is there a better way to say check EVERY variable for a specific set of words rather than doing $name, $subject etc seperately? The reason I ask is my scripts are being exploited and I can fix it when the attacks happen, but i'd like to be able to have a string which checks all the form data and takes action if a word I define in a list exists. So, instead of doing if ($name == mememe .. if($email == [EMAIL PROTECTED] ... I could just have a simple statement with a group of words, and if one of the words appears it takes an action I specify such as do not proceed to add to DB etc Any help would be greatly appreciated as I am tired of keep writing the same scripts with different variables, i'd love to just grab all the variables from the form and perform the action ONCE on the incoming form data and then all the variables are affected instead of doing each one. Please save me from going nuts :-) Chris -- -- No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.1.375 / Virus Database: 268.2.1/278 - Release Date: 3/9/2006 -- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.1.375 / Virus Database: 268.2.1/278 - Release Date: 3/9/2006 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Database abuse help needed
Hi there everyone, Is there a better way I can do this? if ($email == [EMAIL PROTECTED] OR $subject == Rulez666 Basically, if I have data coming from a form to a DB, is there a better way to say check EVERY variable for a specific set of words rather than doing $name, $subject etc seperately? The reason I ask is my scripts are being exploited and I can fix it when the attacks happen, but i'd like to be able to have a string which checks all the form data and takes action if a word I define in a list exists. So, instead of doing if ($name == mememe .. if($email == [EMAIL PROTECTED] ... I could just have a simple statement with a group of words, and if one of the words appears it takes an action I specify such as do not proceed to add to DB etc Any help would be greatly appreciated as I am tired of keep writing the same scripts with different variables, i'd love to just grab all the variables from the form and perform the action ONCE on the incoming form data and then all the variables are affected instead of doing each one. Please save me from going nuts :-) Chris
RE: [PHP-DB] Database abuse help needed
Thank you for that. And excuse the inexperience, but how would I use an Array with the below? I mean say I had words such as this,is,a,bad,word (Just as examples as I can't post what I'm trying to block on here) how would I loop through those to check if any of them exist and if they do THEN execute the error script? I'm not too good with Arrays - but I'm learning. Thank you Chris If you POST from your form use $_POST, or $_GET for a form GET foreach($_POST as $key = $value){ if( strpos($value, $findme) !== false ){ //$findme was found in $value } } http://php.net/manual/en/reserved.variables.php http://us2.php.net/manual/en/control-structures.foreach.php http://us2.php.net/strpos Yes, that's !== or === -Original Message- From: Chris Payne [mailto:[EMAIL PROTECTED] Sent: Thursday, March 09, 2006 5:21 PM To: php-db@lists.php.net Subject: [PHP-DB] Database abuse help needed Hi there everyone, Is there a better way I can do this? if ($email == [EMAIL PROTECTED] OR $subject == Rulez666 Basically, if I have data coming from a form to a DB, is there a better way to say check EVERY variable for a specific set of words rather than doing $name, $subject etc seperately? The reason I ask is my scripts are being exploited and I can fix it when the attacks happen, but i'd like to be able to have a string which checks all the form data and takes action if a word I define in a list exists. So, instead of doing if ($name == mememe .. if($email == [EMAIL PROTECTED] ... I could just have a simple statement with a group of words, and if one of the words appears it takes an action I specify such as do not proceed to add to DB etc Any help would be greatly appreciated as I am tired of keep writing the same scripts with different variables, i'd love to just grab all the variables from the form and perform the action ONCE on the incoming form data and then all the variables are affected instead of doing each one. Please save me from going nuts :-) Chris -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.1.375 / Virus Database: 268.2.1/278 - Release Date: 3/9/2006 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] PHPSession problem - help needed
Hi there everyone, I recently installed PHP 5 on my windows dev machine and it works great BUT I can't get sessions to work correctly and so my database logins won't work from my programming - which on a dev machine isn't good. Can anyone see something that is wrong in the sessions part of my PHP config file below? Any help would be greatly appreciated as it's stopping me fixing a members area bug I have in my database login script. Chris [Session] ; Handler used to store/retrieve data. session.save_handler = files ; Argument passed to save_handler. In the case of files, this is the path ; where data files are stored. Note: Windows users have to change this ; variable in order to use PHP's session functions. ; ; As of PHP 4.0.1, you can define the path as: ; ; session.save_path = N;/path ; ; where N is an integer. Instead of storing all the session files in ; /path, what this will do is use subdirectories N-levels deep, and ; store the session data in those directories. This is useful if you ; or your OS have problems with lots of files in one directory, and is ; a more efficient layout for servers that handle lots of sessions. ; ; NOTE 1: PHP will not create this directory structure automatically. ; You can use the script in the ext/session dir for that purpose. ; NOTE 2: See the section on garbage collection below if you choose to ; use subdirectories for session storage ; ; The file storage module creates files using mode 600 by default. ; You can change that by using ; ; session.save_path = N;MODE;/path ; ; where MODE is the octal representation of the mode. Note that this ; does not overwrite the process's umask. session.save_path = /tmp ; Whether to use cookies. session.use_cookies = 1 ; This option enables administrators to make their users invulnerable to ; attacks which involve passing session ids in URLs; defaults to 0. ; session.use_only_cookies = 1 ; Name of the session (used as cookie name). session.name = PHPSESSID ; Initialize session on request startup. session.auto_start = 0 ; Lifetime in seconds of cookie or, if 0, until browser is restarted. session.cookie_lifetime = 0 ; The path for which the cookie is valid. session.cookie_path = / ; The domain for which the cookie is valid. session.cookie_domain = localhost ; Handler used to serialize data. php is the standard serializer of PHP. session.serialize_handler = php ; Define the probability that the 'garbage collection' process is started ; on every session initialization. ; The probability is calculated by using gc_probability/gc_divisor, ; e.g. 1/100 means there is a 1% chance that the GC process starts ; on each request. session.gc_probability = 1 session.gc_divisor = 100 ; After this number of seconds, stored data will be seen as 'garbage' and ; cleaned up by the garbage collection process. session.gc_maxlifetime = 1440 ; NOTE: If you are using the subdirectory option for storing session files ; (see session.save_path above), then garbage collection does *not* ; happen automatically. You will need to do your own garbage ; collection through a shell script, cron entry, or some other method. ; For example, the following script would is the equivalent of ; setting session.gc_maxlifetime to 1440 (1440 seconds = 24 minutes): ; cd /path/to/sessions; find -cmin +24 | xargs rm ; PHP 4.2 and less have an undocumented feature/bug that allows you to ; to initialize a session variable in the global scope, albeit register_globals ; is disabled. PHP 4.3 and later will warn you, if this feature is used. ; You can disable the feature and the warning separately. At this time, ; the warning is only displayed, if bug_compat_42 is enabled. session.bug_compat_42 = 1 session.bug_compat_warn = 1 ; Check HTTP Referer to invalidate externally stored URLs containing ids. ; HTTP_REFERER has to contain this substring for the session to be ; considered as valid. session.referer_check = ; How many bytes to read from the file. session.entropy_length = 0 ; Specified here to create the session id. session.entropy_file = ;session.entropy_length = 16 ;session.entropy_file = /dev/urandom ; Set to {nocache,private,public,} to determine HTTP caching aspects ; or leave this empty to avoid sending anti-caching headers. session.cache_limiter = nocache ; Document expires after n minutes. session.cache_expire = 180 ; trans sid support is disabled by default. ; Use of trans sid may risk your users security. ; Use this option with caution. ; - User may send URL contains active session ID ; to other person via. email/irc/etc. ; - URL that contains active session ID may be stored ; in publically accessible computer. ; - User may access your site with the same session ID ; always using URL stored in browser's history or bookmarks. session.use_trans_sid = 0 ; Select a hash function ; 0: MD5 (128 bits) ; 1: SHA-1 (160 bits)
[PHP-DB] Help Needed with malfunctioning query
Hi there everyone, This line of code USED TO WORK but now it gives me a Coudln't Execute Query error: $query2 = SELECT word,def,photo MATCH(word,def) AGAINST ('$txtsearchword' IN BOOLEAN MODE) AS m FROM dictionary WHERE MATCH(word,def) AGAINST ('$txtsearchword' IN BOOLEAN MODE) LIMIT $offset, $item_perpage; I tried it with a basic $query2 = SELECT * FROM dictionary; to make sure it wasn't something else that was broke and this is the problem above, it used to work great and now it's on a live site after working great for 6 months and it suddenly doesn't work and I haven't touched anything !!! the server hasn't been updated so it's not that as it also does the same on my local dev machine here, the only thing that happened was my co-worker did a global find and replace with dreamweaver but that's all and I can't personally see anything wrong with the above though I could be looking too hard. Any help would REALLY be appreciated as this is on a very popular website and needs fixing ASAP so I don't lose my head !!! Chris
RE: [PHP-DB] Help Needed with malfunctioning query
Hi there, I'm using asd just to test the search, here's the output from the statement echoed to the screen: SELECT word,def,photo, if(locate('asd',word),1,2) as meFirst ,MATCH(word,def) AGAINST ('asd' IN BOOLEAN MODE) AS m FROM dictionary WHERE MATCH(word,def) AGAINST ('asd' IN BOOLEAN MODE) ORDER BY meFirst, word LIMIT 0, 25 Chris This line of code USED TO WORK but now it gives me a Coudln't Execute Query error: $query2 = SELECT word,def,photo MATCH(word,def) AGAINST ('$txtsearchword' IN BOOLEAN MODE) AS m FROM dictionary WHERE MATCH(word,def) AGAINST ('$txtsearchword' IN BOOLEAN MODE) LIMIT $offset, $item_perpage; What is the exact error phrase? Did you echo the $sql statement so you can see if the variables are correct? -- No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.1.375 / Virus Database: 268.1.0/269 - Release Date: 2/24/2006 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] FOUND THE PROBLEM WITH THE BAD CODE
Hi there everyone, thanks to everyone for the help with the bad MySQL query. it turns out there was some bad JAVASCRIPT at the top and the search itself was fine, I tested it on my dev machine and just realized I have an older version of MySQL on here than on the server and the server was FINE DOH so I took out the bad javascript and all is fine but now I have to upgrade my MySQL as didn't realize it was from 2002 !!! thanks again. Chris
[PHP-DB] Sessions help needed !!!
Hi there everyone, OK this script worked perfectly on my own apache webserver and I had to move it to the main live server, but for some reason it's not passing session values in the same way and i'm positive it's something damn obvious. On my server I can use: echo $credits_system; echo $credits_left; echo $foldername; To display the information to make sure it is being passed, but it returns blank on their server (Same versions of everything except I didn't install it so it may have something turned off in the config - which i don't have control over, sigh). The thing is, the last one - $foldername I MUST have access to as the database uses this as a reference for searches and without this working I can't pull the data I need ($foldername is an ID and also refers to physical folders/directories on the apache webserver for video files). Is there some obvious that I can check to see what's going on that I can't think about right now? Any help or pointers would be really appreciated. Chris
[PHP-DB] Found the sessions solution :-)
Hi Guys, Thanks for your prompt responses. I found if I put the below at the top of each page that needs to display the session data it works fine: foreach($_REQUEST as $key=$value) { $$key=$value; }; Chris
[PHP-DB] Strange rawlist behaviour
Hi there everyone, Can anyone see a problem with the below code? It scans an FTP directory and adds the LAST item in that directory to the database (Being the latest item added) - however, if the directory only has 1 file in it it WON'T add anything, the system returns that the directory is empty and it's very frustrating. chris $conn_id = ftp_connect($ftp_server2); $login_result = ftp_login($conn_id, $ftp_user_name2, $ftp_user_pass2); // check connection if ((!$conn_id) || (!$login_result)) { die(FTP connection has failed !); }; // Initiate passive mode if (ftp_pasv($conn_id, true)) { echo ; } else { echo Could not initiated passive modebrbr; } // try to change the directory to somedir if (ftp_chdir($conn_id, $newdir2)) { // echo Current directory is now: . ftp_pwd($conn_id) . \n; // get the file list for / $array = ftp_rawlist($conn_id, -t); $newdata = $contents[0]; for ( $i = 1; $i count($array); $i++ ) { $current = $array[$i]; $structure[$i]['name'] = substr($current, 55, strlen($current) - 0); $newdatab = $structure[$i][name]; }}; // close the connection ftp_close($conn_id); };
[PHP-DB] How can I solve this?
Hi everyone, I am using PHP_SELF in order to get the current path on a dynamically created webpage. This gives me the following: /my_website/index.php My problem is, ALL I NEED is the directory name - no / or no index.php, how can I strip these out to leave JUST the folder name the file is located in? I need this because the page is dynamically created, and it gets templated information from a database and needs to use the foldername as the identifier between the DB entry to use for grabbing the information and the pages inside the directory. Any help would be really appreciated and I'm certain it's something REALLY obvious. Chris
RE: [PHP-DB] How can I solve this?
Wonderful thank you, it displays a single / before the dir name but I can remove that without too much trouble :-) Thank you. Chris try $x =pathinfo($_SERVER['PHP_SELF']); echo $x['dirname']; =C= | | Cal Evans | http://blog.calevans.com | | Chris Payne wrote: Hi everyone, I am using PHP_SELF in order to get the current path on a dynamically created webpage. This gives me the following: /my_website/index.php My problem is, ALL I NEED is the directory name - no / or no index.php, how can I strip these out to leave JUST the folder name the file is located in? I need this because the page is dynamically created, and it gets templated information from a database and needs to use the foldername as the identifier between the DB entry to use for grabbing the information and the pages inside the directory. Any help would be really appreciated and I'm certain it's something REALLY obvious. Chris -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] http_referer question for DB access
Hi there everyone, I have a system which dynamically creates a template based website which can be turned on or off by a switch, to access it a user would do http://www.websitename/templatename and then it would produce a 404 (NOT look for a dir as this allows me to use a DB switch to enable the system). However, when they enter a similar URL as the above it DOES redirect using: ErrorDocument 404 /redirect.php BUT the PHP page it redirects to, which has the following code: ?php echo $_SERVER['HTTP_REFERER'] ? DOESN'T show the referrer page and I MUST have that in order to find what template they are aimining to look at. I can't query my MySQL DB without this information, am I doing something wrong? I did it once before about a year ago but no longer have the code and I SWEAR I did it this way. Any help would really be appreciated. Chris
[PHP-DB] Encrypting DB content
Hi there everyone, I am about to launch the website for my complex where the homeowners can login and check their billing status etc .. what is the best way, with PHP and MySQL, to store an ENCRYPTED password into the database so that if someone got into the DB they couldn't read the password but if they enter it into the form on the site it still works? I'm not sure on the best way to do this and any help would be really appreciated. Happy New Year everyone. Chris
[PHP-DB] Encrypting DB content THANK YOU and nlist help
Hi there, Thank you for your help I really appreciate it :-) I have one last question and you may (Or may not) be able to answer :-) Do you know how to sort the FTP nlist command? I have it listing the FTP directory once a video is uploaded and using nlist I can view the ENTIRE listing, but I just need to be able to grab the latest filename from the directory so that it can be added to a database. Any help on that would be fantastic, I've read the PHP manual which is how I managed to grab the entire directory listing on the server, but I just need the last modified date to display (The last file uploaded). Chris You can store an MD5, or SHA hash of the password, and then compare.. This is not an encrypted version of the password, rather a calculated hash of it. You can't (well, not without a bit of effort) decrypt this back into the password. The idea is when you store the password, you create the hash. Store the hash in the database. When the user logs in, take their password entry, generate a hash in the same way, and compare the two values. SHA2 is the most secure method to use of these two, I'd use that. The advantage is, the hash could be freely accessable to anyone, and it doesn't cause a security issue, where as all a hacker needs is the key to an encrypted database of passwords to reveal them all. That's the route I take anyhow.. This will likely start a huge conversation about how to secure your system up super tight, but remember the most secure server is one that isn't turned on. :) A realistic solution is somewhere in-between this and no security at all. -Micah On Friday 30 December 2005 8:15 pm, Chris Payne wrote: Hi there everyone, I am about to launch the website for my complex where the homeowners can login and check their billing status etc .. what is the best way, with PHP and MySQL, to store an ENCRYPTED password into the database so that if someone got into the DB they couldn't read the password but if they enter it into the form on the site it still works? I'm not sure on the best way to do this and any help would be really appreciated. Happy New Year everyone. Chris -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.1.371 / Virus Database: 267.14.9/216 - Release Date: 12/29/2005 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Quick question
Hi there everyone, How do I set the following items with ini_set()? I looked at the manual but when I try nothing happens: * file_uploads * upload_max_filesize * max_input_time * memory_limit * max_execution_time * post_max_size Basically I need to be able to upload 1gig files via FTP which is based on PHP, when the file uploads successfully it then adds the info to a mysql database so that the administration program can control the programs uploaded, but I can't upload any large files only small ones. Any help would REALLY be appreciated as this is quite urgent and I've searched the net for examples but couldn't find what I needed. Help me o-b-1, you're my only hope :-) Thanks everyone. Chris
[PHP-DB] One final question regarding FTP :-)
Hi there everyone, I found the PERFECT JAVA Applet for my PHP needs, it allows me to drag and drop and it uploads via FTP to the server very nicely with progress bar etc however, with this it doesn't send the file name to PHP which is what I urgently need. How can I list a directory and grab the latest file that has been added to it? I don't have to worry about multiple files being uploaded as once they upload THEN they are moved to their final resting place on the server :-) Basically I need to know with FTP how I can grab the filename of the most recent save file, then my boss will be happy as I'd have solved his problem on his pet project and I can breath again :-) Thank you all for your help throughout the past couple of years, you are all wonderful and I promise this is the last message unless it's directly DB related (It is technically as I have to add the filename to a DB, but it's not in the sense it should be and I'm sorry). Chris
[PHP-DB] Mailer issue with PHP and MySQL
Hi Guys, I'm using PHP with MySQL data to send a very important email to clients when they enter the recipients email address into the system. On the whole it works for ME, to either my yahoo email address or any of my own domains email addresses that I have, However, when my WIFE gets it it isn't HTML (Even though mine is) with outlook OR outlook express and my boss doesn't get it at ALL even at his yahoo address, so something is wrong with my script. Can anyone look at it please and let me know if anything is blazingly obvious that I've done wrong? As I said I can receive emails on any account I personally try, but my boss cannot and if it doesn't work for him it's basically not working in his eyes as it could be having the same issue with others. $MP = sendmail -t; $HT = htmlbody; $HT = /body/html; $fd = popen($MP,w); fputs($fd,MIME-Version: 1.0\r\n); fputs($fd,Content-type: text/html; charset=iso-8859-1\r\n); fputs($fd, To: $word\n); fputs($fd, From: $email\n); fputs($fd, Subject: $subject\n); fputs($fd, X-Mailer: PHP3\n); fputs($fd, From: $email\n); fputs($fd, Email: $email\n); fputs($fd, $messageheader); // actually this is the message itself pclose($fd); Any help would be REALLY appreciated. Chris
[PHP-DB] Drag and Drop with PHP and MySQL
HI there everyone, I have a file upload system where you select via requester the file to upload, it then uploads it with PHP and stores the info in a MySQL database. Is there an interface / programming method I can use which I can DRAG a file from the desktop into an area in a form just as if I had used a file requester to select a file? Learning a new programming technique is no problem as long as it can be used with PHP and MYSQL. Any helps / pointers would be REALLY welcome. Chris
[PHP-DB] Sending multiple items via a single form field
Hi there everyon, I have a set of form fields dynamically generated but each item must contain 2 pieces of data - the input from the field AND the id that the input represents from the DB. I had this info a while back but had a major HD crash and lost the info I had, how can I do this easily in PHP? Hopefully an easier to understand scenario: I have a form with - example - 5 items listed, each item from the DB and you select ONE item only out of the list, when you submit the form it sends the input from the field you select BUT I also need it to send an addition bit of info in the form of $id so that on the processing page, I can extract both the ID and the data entered from a single field. Obviously I can't use a hidden field for this so the data has to be tacked-on to the input field somehow? Any help would save my life :-) Chris
[PHP-DB] Escaping Characters help needed
Hi there everyone, Can any of you see why the below will not insert into my database? Hann Heritage Homes' Fall Circuit entry. Fabulous ranch floorplan w/walkout basement. Stunning great room w/FP, dramatic dining room, den, screened porch. Mullett kitchen with glazed birch cabinets and granite. Luxury master BR and bath. The finest materials and workmanship throughout. Interiors by Pine Tree Barn. Compare and you'll choose to build with Hann Heritage Homes! I'm using PHP with MySQL and I store the data in $marketremarks but when it gets to THIS FIELD with this particular data in it, it just won't insert. I use the below to escape the characters, but I'm missing something or doing something wrong? addslashes(trim($marketremarks)); Any help would REALLY be appreciated. Thanks everyone, Chris -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.344 / Virus Database: 267.11.2/105 - Release Date: 9/19/2005 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Brain not working, help needed :-)
Hi there everyone, I have the following code: while ($row = mysql_fetch_array($sql_result)) { $id = $row[id]; $video_link = $row[video_link]; $video_thumbnail = $row[video_thumbname]; $video_title = $row[video_title]; $video_description = $row[video_description]; }; Now I’ll be shifting through my MySQL array 6 items at a time, what I’d LIKE to be able to do is store each item in a number string on each pass. In other words, the first loop would see $id being called something like $id1, the second pass in the loop it would be $id2 and so on. I THOUGHT I could do this by putting a $count ++ in the loop and then doing something like $id$count or something like $id.$count but neither worked, this may sound odd but I REALLY need to be able to do this so how can I name a string that has to contain the data from a row successively higher on each loop so that it doesn’t overwrite the data on the previous loop? I have 6 items on the page so I can hardcode ?=$id1? for item 1 and ?=$id2? for item 2 etc …. But with the layout of the page being able to do it THIS way would be MUCH better than having to set the table itself up to handle it. Any help on this (Probably very easy) but annoying problem would be REALLY appreciated ;-) Chris -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.344 / Virus Database: 267.10.16/83 - Release Date: 8/26/2005
[PHP-DB] DB formatting question
Hi there everyone, I’m converting a video website from CGI to use Databases and they want me to keep their existing layout. However, I have a slight formatting problem. I’m using PHP with MySQL and what I have is this: Each page displays 6 videos, 2 are on the first row (Which has 3 columns with the 2nd one being a hardcoded flash video) so the first 2 videos go on the left and on the right, then below that is another row with 4 columns which have to display the other 4 videos. How can I format the table so that when the MySQL data is read in the loop, it displays the data like this? I can display it down the page no problem, but it needs to be 3 columns across on 1 row with the middle column not having any MySQL data and the 2nd row needs to have 4 videos, 1 in each of the 4 columns. Does that make sense? Chris -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.344 / Virus Database: 267.10.16/83 - Release Date: 8/26/2005
[PHP-DB] Case sensitive
Hi there everyone, I have a little problem, I have a search where people can search the address of a property BUT the search is case sensitive, I don’t WANT it to be. I’m using MySQL and PHP and I generally use something like WHERE address LIKE ‘%$stringinput%’ which works with the numbers ONLY, but when I add the address if I don’t put a capital infront of each part of the address it won’t show up. Any ideas how I can make it case INSENSITIVE? (Think that’s the correct phrase). Any help would really be appreciated. Thanks everyone Regards Chris Payne -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.344 / Virus Database: 267.10.15/80 - Release Date: 8/23/2005
[PHP-DB] File read question
Hi there everyone, I'm having to make an editor with PHP and MySQL for assigning column values that change (Long story), basically I can open the file and read it no problem, but how can I open a file and only display the first row of information with all columns? The column count changes every week which is what makes it more tricky for me. I use the fopen command to read the file and that's not an issue, I'm just not sure how to read the first row with all columns, any help would REALLY be appreciated. Regards Chris Payne
RE: [PHP-DB] File read question
Hi there, That actually looks like it might do it, thank you. I'm having a slow brain day today :0) Chris What's the file format, if things are delimited, just read the first line out from the file, after getting it with file() or something, and then use explode() to break it up into an array based on the delimeter. Then you can foreach through it. Assuming it's comma seperated, this would work I think: $file = file(filename.csv); $columns = explode(,, $file[0]); echo count($columns). total columns.br\n; foreach($columns as $column) { echo Column: $columnbr\n; } Is that what you mean? -Micah On Friday 22 July 2005 5:59 pm, Chris Payne wrote: Hi there everyone, I'm having to make an editor with PHP and MySQL for assigning column values that change (Long story), basically I can open the file and read it no problem, but how can I open a file and only display the first row of information with all columns? The column count changes every week which is what makes it more tricky for me. I use the fopen command to read the file and that's not an issue, I'm just not sure how to read the first row with all columns, any help would REALLY be appreciated. Regards Chris Payne -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Threading theory help needed
Hi there everyone, I've written a simple forum in PHP for my website (It's an artistic Jean-Michel Jarre website called Planet Oxygene where I experiment with all things tech) but I want to add threading to my messages but I'm not sure of the theory for such a thing. For example, I know I need ID, messageid, forumid and messagerootid (Just example names) but I'm not sure of the theory of how replies to replies etc ... would work in PHP with MySQL? I guess I'm just confused on the whole threading business and I'm just looking for some good explanation of how I can easily add threading to my messageboard (Assuming my messageboard is just an average system which adds the ID as an auto-numerator, the messageid and all subject etc ...). Any help would really be appreciated just on the basics of how threading works so I can work out the code. Thank you for your help on this, a very confusing subject for me :-) Chris
[PHP-DB] PHP/MySQL with Javascript
Hi there everyone, Just a quick question, I have a login system that stores whether you are logged in or not with a PHP Session. However, I need it so when people submit a form to add an item to their cart that Javascript can pickup the PHP Value of whether people are logged in or not. I don't really need code as I don't want to take anyones time up, but if someone could point me in the right direction of how I can use PHP Values in Javascript I would REALLY appreciate it. Chris
[PHP-DB] Page refresh question
Hi there everyone, I'm using PHP and MySQL in a shopping cart system but the client wants it so that when you add an item to the cart the page doesn't refresh and we all know with PHP the page MUST refresh in order to execute the MySQL query. Is it possible, maybe with javascript? That I can talk to MySQL without having to have the page itself refresh when they add the items to the cart? This is really a pain as the system was basically finished and now I'm told they don't want the page to refresh and they see other sites that don't refresh - sigh. If it can be done with Javascript, do you have a sample of how I can use PHP, Javascript and MySQL together to achieve this please? Any help would not only be appreciated, but would save my life. Thank you. Chris
[PHP-DB] Still having a form problem
Hi there everyone, I'm still having problems with my form PHP data, I lost email for a couple of days due to a server crash on my account so don't know if this was answered or not (Sorry). Basically, I have a form which populates 25 entries at a time from a MySQL DB with PHP, you can select the product you want to order by entering a value in the quantity box, if it was a single box it wouldn't be a problem, but it's an array. Now again, an array for the quantity is no problem at all, as I just use input name=quantity[] type=text class=style8 id=quantity[] value= size=5 HOWEVER, I also need to transfer the $id (Named $id_new) from the database in each quantity array at the same time so I can split each array into ID and QUANTITY, this way I know which ID has which quantity, but this is what has me stumped. I tried with a HIDDEN field but of course that won't work, as there's no way of aligning which ID goes with which quantity, so what I guess I need to know, is how to amend $id_new with the quantity[] array. Any help would be REALLY appreciated as this is really urgent. Chris
[PHP-DB] Form information
Hi there everyone, I'm pulling data from my MySQL DB with PHP 4.2, and I have a quantity box for multiple items, what I'm not sure of is this: Say there are 8 products and they choose 3 by entering a quantity into each box, I can display that no problem BUT how can I capture the ID of each product at the same time for each quantity? This is really an important thing for me to have to do, so I can associate each quantity with the product id. BTW, I use quantity[] as the name in the form, so it's an array, I just need to know how to add an extra item called productid to it so I can carry that info over too :-) Thank you for your help, it's driving me nuts. Chris
[PHP-DB] replace question
Hi there everyone, I'm pulling some sensitive data from a MySQL DB with PHP and the clients wants the first x amount of numbers displayed on the screen to be xx etc ... rather than the numbers, but wants the last 6 to be displayed, is there an easy way to do this? I understand this isn't technically a DB question as such, but if someone could point me in the right direction (IE: which function to read up on) I would really appreciate it. Chris
[PHP-DB] String manipulation
Hi there everyone, I'm working with a mysql Db where I have a single string that I have to split into 2 strings, the first character is the first name and I have that split off into it's own variable, but what I need to know is what's the best method to read the string again BUT ignore the first letter as that is already copied into $firstname? So basically I have $firstname defined from the one string, but I have to define $lastname from the SAME string value as the one I used for $firstname, BUT ignoring the first letter but I'm not sure what the best method is to achieve this? Any help would be very appreciated. Chris
[PHP-DB] URL question
Hi there everyone, My client needs to be able to have their url www.blahblah.com http://www.blahblah.com/ pickup the product number but I can't do it the way I'd want (which would be www.blahblah.com/?mls=examplenumber, instead they said it MUST be www.blahblah.com/examplenumber - how can I grab the number AFTER the .com in PHP so that I can process it with MySQL without it being assigned a variable name, just the number? Chris
[PHP-DB] Urgent DATA help needed
Hi there everyone, My client suddenly dropped on me that they need to be able to search by date, IE: the past 1 day, 3 days, 5 days or 7 days. In the DB, the date format is: 2001-07-05 (For example) but I have no clue how to count the days in between to know how many days I am counting. Say they have something at the end of feb and it runs into march, I have no clue how to work this out. Could anyone show me an example of how to do this? So to take 2001-07-05 and add 3 days to it? So if they choose 3 days, it would have to be CURRENT DATE + 2 I guess, that way you would see all dates from CURRENT DATE OR date = '2001-07-06' OR date = '2001-07-07'. Any help really would be appreciated. Chris
[PHP-DB] Date problem again ;-)
Hi there everyone, OK I'm using the following in my query to display entries in the LAST 3 days: DATE_SUB(CURDATE(),INTERVAL 3 DAY) = ListingDate But it doesn't seem to affect the results, the date format in my DB column (ListingDate - datatype is Date) is 2000-00-00 as in year, month and date - is THAT the problem? That it needs to be an actual timestamp? If that is the case I'm not sure how to approach this because the data MUST be in the above format as it comes from a central DB every night. All I need to do is display the current date plus also the previous x amount of days in between. I'm using PHP 4 with MySQL 4.0.22 (Not the latest MySQL I know, sigh). Chris
[PHP-DB] Timestamp question
Hi there everyone, I have to convert dates in the following format to a valid unix timestamp to be stored in a mysql DB, how should I write it for this format? 12/03/04 (Day,month,year) I'm not sure how to format it correctly. I've tried to following but I don't think it's right: list( $date, $time ) = split( , $listingdate); list( $month, $day, $year ) = split( /, $date ); list( $hour, $minute, $second ) = split( :, $time ); $newtimestamp = mktime( $hour, $minute, $second, $month, $day, $year ); Chris
[PHP-DB] Why isn't this working?
Hi everyone, Im trying to split a string by comma, but its not working, can you see any reason that the below doesnt work? $keywords = preg_split(',','$Agent_Rep'); Thanks Chris No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.300 / Virus Database: 266.5.0 - Release Date: 2/25/2005 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Table from an array?
Hi there everyone Is it possible to create a database table from the first line of a CSV file? What I mean is, how would you create the table columns based on the CSV files columns? This would really help me out, as some times the table column counts change on data I have to import, so it would be nice to have a flexible DB structure rather than a static one. Chris -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.300 / Virus Database: 265.8.4 - Release Date: 2/1/2005
[PHP-DB] Best way to remove slashes?
Hi there everyone, Whats the best way to remove slashes to stop the following from being output from a string: City = HYPERLINK file:///\\'Alliance\'Alliance\\\' Say the string is called $city, I tried the following: Stripslashes($city); but it didnt seem to work? Chris -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.300 / Virus Database: 265.8.4 - Release Date: 2/1/2005
RE: [PHP-DB] GROUP BY? Urgent help needed with selection list
Hi there, The problem is, the database is imported from a huge properties database and can only be imported in the format from the central database of estate agents, so I can't reformat it in the tables itself. Each table has the same fields, but one is for condo's, one is for residential etc . however, the client need to be able to do a search all tables query, and bring the results up as though you are only search 1 table. I've never searched multiple tables before without a relative ID, what I need is to search all of them as though it is just searching 1, so I don't think multiple queries would work, hence why I'm trying to do it all in a single query. Chris if you have kind of geo id number you could use that, failing to have that info, you could re-arrange the data to have Akron - Central, Akron - SE (so that all is in a standard format) Bastien From: Chris Payne [EMAIL PROTECTED] To: php-db@lists.php.net Subject: [PHP-DB] GROUP BY? Urgent help needed with selection list Date: Sun, 23 Jan 2005 00:46:18 -0500 Hi there everyone, Im using the following code to populate cities from a huge database: select name=fm_city[] id=fm_city[] multiple option value=0Show All/option ? $sqla = SELECT DISTINCT(Area) FROM MLS_Listings ORDER BY Area; $sql_resulta = mysql_query($sqla,$connection) or die(Couldn't execute query.); while ($row = mysql_fetch_array($sql_resulta)) { $Area = $row[Area]; ? option value=?=$Area? ?=$Area? /option ? }; ? /select This works great, no problems BUT the client now needs is so the cities are grouped, but its not so simple. For example, say you have Akron, Akron Central etc . They need them so that ALL Akrons appear together, the problem is, that also includes some which are SE Akron etc . So, of course that appears further down the list under S. How can I group this way? I am pretty lost on this. -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.300 / Virus Database: 265.7.2 - Release Date: 1/21/2005 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] What is wrong with this query?
Hi there everyone, Im trying to select data from 3 tables, Im using the following code: SELECT * FROM MLS, Cond, Comm ORDER BY Price DESC LIMIT 0, 50 But its not working, I thought this is how it worked but I guess Im wrong. Its just a basic query, but needs to pull all the info from all 3 tables in the same DB, what am I doing wrong? It works perfectly if I just use 1 table. Chris -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.300 / Virus Database: 265.7.2 - Release Date: 1/21/2005
RE: [PHP-DB] What is wrong with this query?
Hi there, Basically I just need to pull ALL the data from ALL the tables listed in the same query. It doesn't matter in what order the data is displayed and there is no relation between the tables. Chris What exactly are you trying to do? If you require data from each table and that data is linked somehow thur some common field (not required to be the same field across all three tables) you need to include that SELECT a.*, b.*,c.* FROM MLS a, Cond b, Comm c where [join crtieria] and [search crtieria] ORDER BY Price DESC LIMIT 0, 50 need more info about structure and goal bastien From: Chris Payne [EMAIL PROTECTED] To: php-db@lists.php.net Subject: [PHP-DB] What is wrong with this query? Date: Sat, 22 Jan 2005 23:44:29 -0500 Hi there everyone, Im trying to select data from 3 tables, Im using the following code: SELECT * FROM MLS, Cond, Comm ORDER BY Price DESC LIMIT 0, 50 But its not working, I thought this is how it worked but I guess Im wrong. Its just a basic query, but needs to pull all the info from all 3 tables in the same DB, what am I doing wrong? It works perfectly if I just use 1 table. Chris -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.300 / Virus Database: 265.7.2 - Release Date: 1/21/2005 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- No virus found in this incoming message. Checked by AVG Anti-Virus. Version: 7.0.300 / Virus Database: 265.7.2 - Release Date: 1/21/2005 -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.300 / Virus Database: 265.7.2 - Release Date: 1/21/2005 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] GROUP BY? Urgent help needed with selection list
Hi there everyone, Im using the following code to populate cities from a huge database: select name=fm_city[] id=fm_city[] multiple option value=0Show All/option ? $sqla = SELECT DISTINCT(Area) FROM MLS_Listings ORDER BY Area; $sql_resulta = mysql_query($sqla,$connection) or die(Couldn't execute query.); while ($row = mysql_fetch_array($sql_resulta)) { $Area = $row[Area]; ? option value=?=$Area? ?=$Area? /option ? }; ? /select This works great, no problems BUT the client now needs is so the cities are grouped, but its not so simple. For example, say you have Akron, Akron Central etc . They need them so that ALL Akrons appear together, the problem is, that also includes some which are SE Akron etc . So, of course that appears further down the list under S. How can I group this way? I am pretty lost on this. Any help would REALLY be appreciated. Chris -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.300 / Virus Database: 265.7.2 - Release Date: 1/21/2005
[PHP-DB] Security Question
Hi everyone, I have a security question, I want to see if I am right or wrong. I have programmed a system with PHP and MySQL, the main system resides on a secure server, but the client wants the login page on a NON-Secure server for marketing purposes. Am I the only one who thinks this is a major security concern? Chris -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.300 / Virus Database: 265.6.13 - Release Date: 1/16/2005
[PHP-DB] str_replace question
Sorry if this already went through, my SMTP server was having problems. Hi there everyone, Im having a weird problem and Im not sure why, if I try to replace WHERE AND with just WHERE it wont do it, but if I try to replace WHERE or AND by themselves it WILL do it, but I cannot replace BOTH of them from a single string, is something wrong below? $additionalsql = str_replace(WHERE AND, WHERE, $additionalsql); Basically Im trying to replace WHERE AND with just WHERE as Im building a very complex SQL query and its a difficult one, and I have a solution that works perfectly but I need this to work in order to do it. I would appreciate any help on this, as its very important. Chris -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.296 / Virus Database: 265.6.7 - Release Date: 12/30/2004
[PHP-DB] str_replace question
Hi there everyone, Im having a weird problem and Im not sure why, if I try to replace WHERE AND with just WHERE it wont do it, but if I try to replace WHERE or AND by themselves it WILL do it, but I cannot replace BOTH of them from a single string, is something wrong below? $additionalsql = str_replace(WHERE AND, WHERE, $additionalsql); Basically Im trying to replace WHERE AND with just WHERE as Im building a very complex SQL query and its a difficult one, and I have a solution that works perfectly but I need this to work in order to do it. I would appreciate any help on this, as its very important. Chris -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.296 / Virus Database: 265.6.7 - Release Date: 12/30/2004
[PHP-DB] Removing first word from a string?
Hi there everyone, I am building a dynamic MySQL query for a project I am working on, but there are instances where it products WHERE AND instead of WHERE city etc .. due to the nature of the system I am developing. My question is, how can I remove the FIRST AND from a string if it is present, but leave all other AND statements in the string? I would really appreciate any help on this. I can do a find and replace on a string no problem, but just want it to be removed IF it is the FIRST word in the string. Oh and Happy New Year everyone. Chris -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.296 / Virus Database: 265.6.7 - Release Date: 12/30/2004
RE: [PHP-DB] Looping within a string?
Hi there, Well basically I have a list of items and their prices etc . which have to be sent via email, so I need to store the data in a string. I THOUGHT I could execute the loop with all the elements (Such as table rows etc ...) inside a string, but I was wrong, so how can I store the data PLUS the table data into a string? It has to be an HTML email and I'm stumped. I can send an email no problem, but not with all the data, just the last row in the data. Chris On Friday 17 December 2004 10:33, Chris Payne wrote: Im having to send an email with looped results, but Im having problems. I can send an email no problem, and this code works OUTSIDE of the string, but not inside, can anyone see what is going wrong? Please explain what you are doing. A string is a string. Code doesn't execute inside a string. What else are you doing to the string? -- 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 -- /* Pardon this fortune. Database under reconstruction. */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.816 / Virus Database: 554 - Release Date: 12/14/2004 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.816 / Virus Database: 554 - Release Date: 12/14/2004 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] String question
Hi there everyone, I am having to read a string with text in, but the way the DB is written in the same string you have the price, for example CASARON 4G 50lb Sacks in Ton Lots $88.00 How can I strip out the 88.00 (Baring in mind it could be any number) into its own string? Thank you. Chris --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.816 / Virus Database: 554 - Release Date: 12/14/2004
[PHP-DB] Connecting to a remote server?
Hi there everyone, I have written a program in PHP with MySQL as the DB backend, It works great but I need to be able to connect to a remote MySQL DB server for an Updates system Ive written, how do I connect to a remote MySQL server with PHP? Ive only ever done it with localhost. Thanks Chris --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.802 / Virus Database: 545 - Release Date: 11/26/2004
[PHP-DB] Error Help
Hi there everyone, Thanks to everyone helping with connecting to a remote server, works wonderfully now :-) I do have a final question, had a look online but couldnt find what I needed. Its hard to explain why, but basically individuals have my program on their HD, the DB is on their HD etc . And it connects on startup to a remote server to check the latest version number so they can then download if a new one is available (Which I package using MS.nets installer system for distribution), Anyway, what I want to know is, how can I get a NICE error message IF they arent connected to the net when they launch the software on their machine? Currently I get a nasty message, but Id like to replace it with something like Please make sure you are connected to the Internet or something like that? I know the OR DIE command, but that doesnt work with connection failures. Thanks everyone. Chris --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.802 / Virus Database: 545 - Release Date: 11/26/2004
[PHP-DB] Numeric question
Hi there everyone, Just a quick question, Im having to calculate some values from an existing database, but on some of the results I get (For example) 0.5907 How can I limit the result to only 2 digits after the decimal point with PHP? Thanks Chris --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.797 / Virus Database: 541 - Release Date: 11/15/2004
[PHP-DB] PHP / Javascript question
Hi there everyone, I have a form with check boxes and with PHP I use the array feature for the form name. Now I need to check if the tickboxes are ticked and if not return an error, normally with javascript I would use: script language=JavaScript function validate_form ( ) { valid = true; if ( document.removeitems.del.value == ) { alert ( You cannot remove an item if it is not selected. ); valid = false; } return valid; } /script BUT because the tickboxes information is stored in a PHP Array called del[] I am having major problems getting it to work. Does anyone know how to determine with javascript if any boxes are ticked, when the name for the box is an Array such as del[] ??? Im grabbing the data from my MySQL DB without a hitch etc . And I know technically this is more MySQL / PHP list, but it is related and Ive looked online and cant seem to find anything, so thought Id try here as usually you are all very helpful. Thank you Chris --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.795 / Virus Database: 539 - Release Date: 11/12/2004
[PHP-DB] session_destroy();
Hi there everyone, I need to destroy a session in the browser so when they log out it clears all the session data from the browser, I have tried: session_destroy(); But it doesnt seem to do it as the browser keeps the same PHPSessionID. What is the best way to destroy a session and generate a new sessionid without having to close the browser and go back again? Chris --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.791 / Virus Database: 535 - Release Date: 11/8/2004
[PHP-DB] How to get unique entries?
Hi there everyone, Im listing entries by date in a dropdown box, but on some days there are 7-8+ dates the same, but I just need it to display each date ONCE in the dropdown, but for the life of me I cant remember the command to use to do this, can anyone please remind me? I know it was dead simple, but cant remember the command. Thank you. Chris --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.788 / Virus Database: 533 - Release Date: 11/1/2004
[PHP-DB] Finding the highest number in a column?
Hi there everyone, I am working with a very complex system where not all numbers are assigned 1, 2, 3 etc so there could be a row with the number 1 and then the next row could be 40 and so on Is there a way with PHP and MySQL to find out what the highest number is in a particular column easily when the numbers are auto-incremented so arent necessarily one after the other? I would really appreciate any help on this as its really bugging me. Chris --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.783 / Virus Database: 529 - Release Date: 10/25/2004
[PHP-DB] I can't seem to get Max() to work
Hi there everyone, I cant seem to get the below to work with PHP and MySQL: $sql = SELECT MAX(FoodItemNumber) FROM menuitemsubs; What am I doing wrong? I need the highest number from the column FoodItemNumber, but it doesnt return anything unless I change the MAX() to a * and I dont want that I need it to be the MAX() number as it isnt an auto-increment field. Chris --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.783 / Virus Database: 529 - Release Date: 10/25/2004
[PHP-DB] Lotus Notes DB to MySQL?
Hi there everyone, I have a client who uses Lotus Notes for her database, now she wants it converted to MySQL, is that possible? What format is notes DB in? Basically I will write a new front-end and back-end for her so she doesn't need notes anymore (Nasty, nasty software) but I need to import her old data first. Chris
[PHP-DB] Updating a table when using LEFT JOIN
Hi there everyone, I am using the following to grab the data I need from several tables: $sql = SELECT * FROM vendorprices LEFT JOIN fooditems on (vendorprices.FoodItemNumber = fooditems.FoodItemID) WHERE vendorprices.VendorNumber='$VendorID' ORDER BY vendorprices.VendorItemNumber; This works great, very fast etc .. the problem is, I then need to give the option for them to edit the items - again, not a problem in populating the form - until I have to then use the UPDATE function, how can I update each item in separate tables when I use the above join to grab the info in the first place? I've never had to write to 2 tables at once where data is relative like this, infact it was my first time of using JOINS at all to even display the data. I'm using PHP with MySQL. Thank you. Chris
[PHP-DB] PHP Array to Javascript?
Hi there everyone, I set an array using the following in PHP: $ringb[$i]=$complex_area; $i++; It cycles through my DB and stores the info, my question is, how can I convert it to a value that can be read in Javascript? I'm stumped. Chris
[PHP-DB] MySQL to EXCEL?
Hi there everyone, I'm having a dilemma (Now that I have power back after the hurricane hit us directly in Orlando). Anyway, I need to export a database table to Excel, I can do it as a .txt file without a problem, but I can't seem to get it to put each column into a separate cell when I try to export as an .xls form, I think I have this line formed incorrectly for an XLS file, can anyone see if I need to use any special characters rather than a comma? fwrite($filesession,$id,$new,$recno,$category,$product,$description,$unit,$ certificate,$instock,$orderpt,$ordernow,$vendor,$unitcost,$unitsell\015\012 ); Thank you. Chris
RE: [PHP-DB] MAIL() help needed :-(
Hi there, Thanks for the help, I've sorted it out now - stupid me :-) You know what it's like sometimes, you work that hard on different things that something which should be really simple just goes over your head - well, it does mine anyway :-) Very much appreciated. Chris Hey Chris, Probably a good idea would be to read the email RFC. I'd say that you're trying to send a Multi-part MIME email, but not formatting it correctly. You even forget to include your 'simple' (plain text) message in the email body. SO if you were formatting it correctly, and your friend is only viewing plain text, you won't see anything. Here's the basic structure of a Multi-part MIME email: begin quote From: Persons Name [EMAIL PROTECTED] MIME-Version: 1.0 Content-type: multipart/alternative; boundary=mime_seperator X-Mailer: PHP/5.0.0 This is a multi-part message in MIME format. --mime_seperator Content-type: text/plain;charset=us-ascii Content-Transfer-Encoding: 7bit This is the plain text part of the email. --mime_seperator Content-type: text/html;charset=us-ascii Content-Transfer-Encoding: 7bit HTML HEADTITLEEmail Title/TITLE/HEAD BODY HTML Email in here /BODY /HTML --mime_seperator- end quote A few notes for you: 1. This is a multi-part message in MIME format. begins the email body. (ie it's not a header) 2. Most of the headers need \r\n as a newline. \n won't do. (Checkout the code below to see where to use \r\n and where to use \n) 3. You need a mime seperator to begin each section of the email. it should be preceded by -- each time. You should end the email with the mime seperator preceeded with -- AND suffixed with -. You can use pretty much anything for the seperator. There may be a restriction on which characters you can use. 4. This does not cover attachments. If you want to send attachments in the email, you need to do some further research. Official EMail RFCs: http://www.ietf.org/rfc/rfc2822.txt http://www.ietf.org/rfc/rfc1341.txt Here's a great tutorial at PHP Builder: http://www.phpbuilder.com/columns/kartic2807.php3 Here's how I do the above email: ? $myname=My Name; $my_email=[EMAIL PROTECTED]; $username=Person's Name; $user_email=[EMAIL PROTECTED]; $stamp=time(); $subject=General Subject; $content_boundary=MYDOMAIN_$stamp; $extra_headers=From: $myname $my_email \r\nMIME-Version: 1.0\r\nContent-type: multipart/alternative; boundary=\$content_boundary\\r\nX-Mailer: PHP/.phpversion(); $start_html=Content-type: text/html;\tcharset=\us-ascii\\nContent-Transfer-Encoding: 7bit\n\n; $start_text=Content-type: text/plain;\tcharset=\us-ascii\\nContent-Transfer-Encoding: 7bit\n\n; $message=This is a multi-part message in MIME format.\r\n\r\n; $message.=--.$content_boundary.\r\n.$start_text; $message.=Plain text email.\r\nA new line\r\n\r\nTwo new lines follwed by some more text. $message.=--.$content_boundary.\r\n.$start_html; $message.=!DOCTYPE HTML PUBLIC \-//W3C//DTD HTML 4.01 Transitional//EN\\r\nHTML\r\nHEADTITLE/TITLE\r\n/HEAD\r\nBODY\ r\n; $message.=Message body in here; $message.=\r\n/BODY\r\n/HTML; $message.=--.$content_boundary.-\r\n; mail($username..$user_email., $subject, $message, $extra_headers); ? Hope this helps. Collin -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] MAIL() help needed :-(
Hi there everyone, I'm having a major problem. I'm trying to send a message FROM Windows XP Pro, now this is where it get weird - in some mail packages it WORKS, and in some it doesn't. Basically it's an HTML email which is sent when a form is completed, the results are stored in a DB and then sent on in an HTML Email Format. In My outlook 2003, it works, in my friends outlook 2003 which I setup for him exactly the same way mine is - the email is blank, it is the same in his outlook express. My question is, can anyone see anything that I am doing wrong for this to happen? Maybe my headers are wrong? Any help would be really appreciated as this is really getting to me. This is my first time trying with this method, I usually use a different method as I use Linux, but the method I use didn't want to work without sendmail. Thank you everyone $to_name = 'To Name; $to_email = '[EMAIL PROTECTED]'; $from_name = 'From Name'; $from_email = '[EMAIL PROTECTED]'; $subject = 'Information Request'; $body_simple = 'Simple content for non-MiME-compliant clients'; $body_plain = 'This message requires a HTML Capable Client - Such as Outlook or Outlook Express'; $body_html = $messagebody; $headers = From: \.$from_name.\ .$from_email.\r\n; $headers .= to: \.$to_name.\ .$to_email.\r\n; $headers .= Return-Path: .$from_email.\r\n; $headers .= MIME-Version: 1.0\r\n; $headers .= Content-Type: text/html; charset=ISO-8859-1\r\n; $headers .= Content-Transfer-Encoding: 8bit\r\n\r\n; $headers .= $body_html.\r\n; mail($to_email, $subject, '', $headers); - Regards Chris
[PHP-DB] Urgent JOIN help needed
Hi there everyone, I'm new to JOINS and have followed some info in the MySQL manual but I'm at a loss, using the code I'll paste below, I get each result 4 times and I am confused as to why? Basically I'm trying to display ALL fields from the vendorprices table, and grab just the Description column from the fooditems table, the factor which joins them both is the string $VendorID which in the vendorprices table is VendorNumber and in the fooditems table is CategoryNumber. $sql = SELECT * FROM vendorprices LEFT JOIN fooditems on (vendorprices.VendorNumber = fooditems.CategoryNumber AND fooditems.CategoryNumber = '$VendorID') WHERE vendorprices.VendorNumber='$VendorID' AND fooditems.CategoryNumber='$VendorID'; Can anyone see where I'm going wrong? This is driving me nuts and I need to figure it out urgently. Thank you for your help. Regards Chris
[PHP-DB] JOIN question
Hi there everyone, I'm transferring a client's product from a Visual Basic .NET ACCESS 2000 application to run on a custom install of Apache/MySQL/PHP which I created (With a custom installer which sets everything up for them). My question though, is on looking through their ACCESS database, there seem to be table joins - or at least that's what I understand they would be under MySQL 4. How can I read information from 3 tables at the same time? I am a little confused, I gather you use JOIN but I'm not sure how it works, could someone please show me an easy to follow example? Thanks, I really appreciate it. Oh and so far, on the pages that I haven't had to use JOINS, I can honestly say that MySQL is FAR faster than ACCESS from what I'm seeing in my development here. Chris
[PHP-DB] Column help needed (Table)
Hi there everyone, I need my MySQL query to be displayed in a table, which is no problem, but I only want 2 results per row to be displayed - so if I had 10 returned results from my Database, it would display 2 per column on 5 rows. How can I do this dynamically? Any help would be really appreciated. Thanks Chris
[PHP-DB] MySQL variable question
Hi there everyone, I'm using MySQL 4's built-in Boolean handling abilities with PHP 4 which works wonderfully, but I need to change: ft_min_word_len to be 3 characters instead of 4 for fulltext indexing, how can I change this as words such as cat etc ... are not showing up in my PHP search engine and I need them to. I know I have to edit ft_min_word_len to show 3 instead of 4, but what file do I edit? (Sorry to sound dumb but I haven't reconfigured MySQL before). Thanks everyone. Chris
[PHP-DB] SELECT problem between MySQL 3.23 and MySQL 4
Hi there everyone, I'm using Booleans in my searches (New to it) but it works perfectly on my local 3.23 version of MySQL, but on the main server which uses version 4 of MySQL I get an error so there's an error in my Syntax. Here's what I currently use: SELECT id, def, word, 0.2*( LENGTH(word) - LENGTH(REPLACE(LOWER(word),LOWER('as'),''))) /LENGTH('as') + 0.2*( LENGTH(def) - LENGTH(REPLACE(LOWER(def),LOWER('as'),''))) /LENGTH('as') as relevance FROM joyzine.dictionary WHERE ( word LIKE '%as%' OR def LIKE '%as%' ) HAVING relevance0 ORDER BY relevance DESC And here's the error I receive on the remote MySQL 4 server: Warning: Bad arguments to implode() in /var/www/html/www.planetoxygene.com/htdocs/funcs_mysql_boolean.php on line 45 You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near ') - LENGTH(REPLACE(LOWER(),LOWER('as'),''))) /LENGTH('as' Can anyone see what is wrong which is stopping it being compatible with MySQL 4? Any help would really be appreciated, as this system is very important. Best Wishes Chris
[PHP-DB] Load Data infile help needed
Hi there everyone, I'm having a problem loading in a text file, each column is enclosed with a and separated by a , but when I try the below, it loads in the data BUT it puts a to the left of each character. Any help would be really appreciated. Thank you Chris mysql_query(LOAD DATA INFILE 'c:/apache/htdocs/example/20040624.txt' INTO TABLE import FIELDS TERMINATED BY '\\\' ESCAPED BY '\\,' LINES TERMINATED BY '\\r\\n');
[PHP-DB] PHP with Javascript tutorials?
Hi there everyone, I've been looking on Google for PHP Javascript tutorials but I can't find any. I'm new to Javascript but can use PHP for what I need. I was hoping someone would know of a tutorial that would show how to use PHP to get 2-3 datasets which javascript can then use in forms. For example, say I have 3 pulldown boxes, one would have countries - such as UK, USA etc .. If you selected the UK it would bring up countries in the UK, and if you select a country the third pulldown would show the cities in that country (This is just an example to hopefully explain what I need) but I don't want the page to refresh everytime I select an option which it does if you just use PHP. Any help would be EXTREMELY greatly received :-) Regards Chris
[PHP-DB] Date help needed
Hi there everyone, I have a problem, I currently have some code which populates a dropdown box - this code gives me every day for the next x amount of days (EG: a years worth of days), however what I really need to be able to do, is to find a way to display this data in the dropdown box but ONLY show 3 days a week, IE: Mondays, Fridays and Sundays, so it would show the dates for each Monday, Friday and Sunday for X amount of days (IE: 365 days in the dropdown). Does anyone have any idea how to do this? I would really appreciate any help, I'd send my sample code only I'm not at my home/work computer ATM. Chris
RE: [PHP-DB] Date help needed
Hi there, Just got back and tried it and it works perfectly, thank you so much for your help, you've got me out of a bind here ;-) Chris You could loop through the weeks and put those 3 specifically in: $days = array(); for($i = 0; $i 365; $i +=7) { $days[] = strtotime('next Monday', strtotime('+ '.$i.' days')); $days[] = strtotime('next Friday', strtotime('+ '.$i.' days')); $days[] = strtotime('next Sunday', strtotime('+ '.$i.' days')); } sort($days); foreach($days as $day) { echo date('Y-m-d', $day).'br/'; } (This is not tested, but it *should* work,) On Thu, 24 Jun 2004 17:07:12 -0400, Chris Payne [EMAIL PROTECTED] wrote: Hi there everyone, I have a problem, I currently have some code which populates a dropdown box - this code gives me every day for the next x amount of days (EG: a years worth of days), however what I really need to be able to do, is to find a way to display this data in the dropdown box but ONLY show 3 days a week, IE: Mondays, Fridays and Sundays, so it would show the dates for each Monday, Friday and Sunday for X amount of days (IE: 365 days in the dropdown). Does anyone have any idea how to do this? I would really appreciate any help, I'd send my sample code only I'm not at my home/work computer ATM. Chris !DSPAM:40db40cb34094233914063! -- paperCrane --Justin Patrin-- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Date help needed
Hi there, A drop down with 365 days !?!? Isn't that a little big? Actually it's Fridays, Sundays and Tuesdays for 2 years (365 was an example) it's for an Admin for a client, and he asked that it be in a dropdown box and he's the boss, so he gets what he wants :-) One thing he wanted which I didn't know how to do (Javascript I guess which I don't know much about) was to preload a database of email address, and as he started to type an email address it would do a sort of auto-complete, but have no clue how to go about that so just told him not viable ATM. Chris -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] URL Problem
Hi there everyone, I have a problem. Basically this is what I need to do: Request behind the scenes (PHP) an ASP Url on a different website with the value pid=1 (Where 1 is an identifying number). Then I need PHP to listen to the response from that request as ASP will then return a value which PHP has to pickup, and I have ZERO idea how to do this :-( I tried something which I though, but that gets the webpage and NOT the url that it passes back with its values. Any help would be greatly appreciated. So basically I need to request an URL from within PHP, PHP listens to and gets the reply URL that is sent back to it with the new value (Which is determined by the pid= value). Thank you everyone. Chris --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.662 / Virus Database: 425 - Release Date: 4/20/2004
RE: [PHP-DB] URL Problem
Hi there, Thanks for the below, but I'll try to explain it a bit better. I don't have access to the ASP server, it's a general server setup for companies, to query their server you must use the ?pid=uniquecompanynumber as it tracks your IP to make sure the correct server is connecting. Anyway, what I need is to be able to query this server and get the url response ONLY, in other words, when it sends a response back I need to pick up what their URL and any additional values IN their url are, and not the body of the page itself. Does that make more sense? I didn't get much sleep last night so hard to express what I mean. Chris Anyway first you have to translate your problem to us. In plain english. But I have spare time, so.. here is the solution for your problem, as I understood it. from php ?php $f = file(http://myserver.com/index.asp?pid=;); print_r($f); ? In ASP you take the pid do what you want to it and then % Response.Write( myResult ) % The myResult is what the php will be printing and the value you can use. Use only one Response.Write in entire .asp --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.662 / Virus Database: 425 - Release Date: 4/20/2004 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] PHP Standalone?
Hi there everyone, I need to produce a system which uses databases but NOT on a webserver, I heard something about a PHP distro that is being developed which acts like an executable, does anyone know anything of this? Any help would really be appreciated :-) Chris Payne -- [EMAIL PROTECTED] [EMAIL PROTECTED]
RE: [PHP-DB] PHP Standalone? (fwd)
Hi there, Unfortunately I don't know much Perl at all ATM, and I've suddenly has this job arise that needs me use an ACCESS Database (Yuck) but in a windows-style interface and NOT web, so I have been looking hard to try to find information on whether I can create an interface for 2000/XP that can control and receive results from PHP. If you have any tips I would be really appreciative :-) I just download PHP-GTK. Chris Payne -- [EMAIL PROTECTED] [EMAIL PROTECTED] -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Thursday, February 05, 2004 7:30 PM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] PHP Standalone? (fwd) while php can be set up to do what you're after, i think that perl would be a better choice. while i use both php and perl, i think that perl is a much stronger general scripting language. if you need [web]server parsed pages, then php has an advantage (unless you want to use mod_perl), but in a standalone environment i think that perl will serve you better. -- Forwarded Message -- Date: Thursday, February 05, 2004 04:19:56 PM -0800 From: Frank M. Kromann [EMAIL PROTECTED] To: Chris Payne [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: Re: [PHP-DB] PHP Standalone? http://gtk.php.net - Frank Hi there everyone, I need to produce a system which uses databases but NOT on a webserver, I heard something about a PHP distro that is being developed which acts like an executable, does anyone know anything of this? Any help would really be appreciated :-) Chris Payne -- [EMAIL PROTECTED] [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- End Forwarded Message -- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Functions
Hi there everyone, I need to write a function (New to them but starting to get the hang of it) that will take the field from a form and then do operations on it (To remove bad characters, any entered mysql commands etc ) now that's not a problem, what I want to do though is write a generic function that will handle ALL the fields in any form. For example, if I have 3 input boxes, name, address, email - I would like the function to recieve the data from each form string and do the operation and then send the info back keeping the same name and value that it arrived in. I'm finding it hard to explain, but basically if a field is called email and it's value is [EMAIL PROTECTED] then the function needs to be able to automatically pickup that the incoming name is email and it's value it [EMAIL PROTECTED] then process it and output it again, and i'm confused how to do it. I can do it if I specify the name of the form item coming in and going out, but since I want to make it generic I don't want a zillion different possible form names in the function :-) Any help (If you can understand my rambling :-) would be greatly appreciated. Regards Chris
[PHP-DB] PHP with Sendmail
HI there everyone, Is it possible to use PHP to check an email on the same server? I have a system setup for my newsletters which I want to expand, and basically when mails bounce back to a certain email address on the server as failed it would then read the email and remove the address from the MySQL database, is this possible? Any help would be really appreciated, as right now I have to collect all the failed emails from the server, then go through them one at a time and remove them, not very effecient :-( BTW the server is Redhat. Chris
[PHP-DB] retrieving email address from array
Hi there everyone, I'm connecting to my mailserver and getting my messagebody, however what I need to do it take everything away but leave the email address that is in the array for processing. How can I take out JUST the email address from the Array? I really need to do this urgently as I need to get this mail system working with the DB by the weekend, almost there but this bit has stumped me. Thanks everyone, and Happy New Year. Chris
[PHP-DB] PHP Error or installation problem?
Hi there everyone, I just upgraded my Linux installation of MySQL from 3.23 to 4.0 (Well, the latest production build). In Webmin everything is fine, I can login etc . BUT with PHP 4, the version I used for 3.23 with no modifications (Which may be the problem?) I am having problems connecting tot he server, and with PHPMyADMIN I get the following error: cannot load MySQL extension HELP I am so confused and I need my DB up as soon as possible :-( Chris
[PHP-DB] Reading emails with PHP
Hi there everyone, A quick question, is it possible to read a failed mail email and pick out the failed email address? I have around 900 failed emails (Don't ask, long story) from a client and what I want to do is just put the emails in a folder and cycle through the folder and pickout the email addresses. Cycling through a folder isn't difficult, neither is removing an email from the DB in a loop, but how can I - if it's possible - open an email and find the failed line and grab the failed email address from that? Any help, tips would be REALLY appreciated as I REALLY don't want to spend a few days doing it manually. Oh and Merry Christmas / Happy Holidays. Chris
[PHP-DB] Splitting a string by a ,
Hi there everyone, I'm trying to split a string into an Array by a , but I kepe getting errors. Looking at the PHP manual, I thought it would be this way: $keywords = preg_split(,, $email); But it keeps saying that the , isn't an ending delimiter? Any help would be appreciated, i'm trying to split email addresses from an input box seperated by a , Thanks for any help. Chris
[PHP-DB] Great PHP Book i've come across
Hey there everyone, Just found a great PHP/MySQL/Apache book, it's not as comprehensive as some books, but the topics it covers it covers VERY well, and i'm learning alot from it. It's called: Sams: Teach Yourself PHP, MySQL and Apache in 24 hours and it's by SAMS PUBLISHING. While it's not the most comprensive book out there, for people wanting a refresher course who are just getting into working with PHP, this is excellent. I'm currently learning about functions from it and it is outstanding, very easy to understand (Which is good because i'm not the sharpest knife in the draw :-) Just thought i'd mention this, as it's helping me i'm sure it would help others too, and this is what this group is for, helping everyone out :-) Oh and no I DON'T work for them LOL, just found it useful. Chris
[PHP-DB] Function Problem
Hi there everyone, This code works fine until I put it into my function, then it still works BUT however many lines are in the file are multiplied. For example, if I have 3 lines with the following: [EMAIL PROTECTED], myname [EMAIL PROTECTED], yourname [EMAIL PROTECTED], ourname In THEORY this should just print the above, HOWEVER, when it's being called as a function it's giving me the following: [EMAIL PROTECTED], myname [EMAIL PROTECTED], myname [EMAIL PROTECTED], myname [EMAIL PROTECTED], yourname [EMAIL PROTECTED], yourname [EMAIL PROTECTED], yourname [EMAIL PROTECTED], ourname [EMAIL PROTECTED], ourname [EMAIL PROTECTED], ourname When it is inserted into the DB. It might be something obvious, but here's the code below to see if there's anything obvious i'm doing wrong. Oh and i've checked and $userfile AND $delim are being picked up ok. function db_importcsv($userfile,$delim) { if ($userfile == ){ $failed = 'yes'; } else { $date = date('d m Y'); $row = 1; $handle = fopen ($userfile,r); while ($data = fgetcsv ($handle, 5024, ,)) { $num = count ($data); $row++; mysql_query (INSERT INTO emaillist (EMail,name,date) VALUES ('$data[0]','$data[1]','$date') ); }; fclose ($handle); $failed = no; }; return $failed; }; Any help would be really appreciated, as i'm new to functions but enjoying it :-) Chris
[PHP-DB] a LITTLE bug with my CSV importer :-)
Hi there everyone, OK So I kind of have my CSV utility working nicely, except for one thing - if I import the file with PHPMyADMIN it imports over 1000 rows (Which is correct) but with the below code on the same file, it's only importing 92 rows, can anyone see anything obvious that's wrong? I think it could be the MySQL query, as I have a count statement which counts the number of rows in the loop and it counts correctly and if I print the data on the screen it prints the data correctly, just when it writes to the DB argghhh i'm going nuts, i've been trying hard to figure it out without hasstling the group (Sorry). $d = |; // fields delimiter $fp = fopen ($userfile, r); while ($data = fgetcsv ($fp, 1, $d)) { $num = count ($data); $row++; $count ++; mysql_query (INSERT INTO import (id,BranchReference,address1,Location,Location2,Postcode,Price,Offers,Bedrooms,Receptrooms,period,Proptype,spare1,Propstatus,ShortDescription,LoDesc,PictureRef1,Bullets,Field1,Field2,Field3,Field4,Field5,Field6,Sale) VALUES ('$data[0]','$data[1]','$data[2]','$data[3]','$data[4]','$data[5]','$data[6]','$data[7]','$data[8]','$data[9]','$date[10]','$data[11]','$data[12]','$data[13]','$data[14]','$data[15]','$data[16]','$data[17]','$data[18]','$data[19]','$data[20]','$data[21]','$data[22]','$data[23]','$data[24]') ); }; echo $count; fclose ($fp); Thanks for any help Regards Chris
Re: [PHP-DB] a LITTLE bug with my CSV importer :-)
Hey there Roger, I just put that in (Will keep it in anyway) but I get the same problem. Could it be there's some kind of illegal char in one of the array fields? If so, how can I do checking and fix bad characters when going through the array? I know if I remove the LoDesc fields (Which is $data[15]; if I remember correctly) it imports over 880 fields, but when that's in it only imports 92 - but I have no idea how to correct bad characters they may have put in the file (I have no control over the characters they use - sigh). I really appreciate your help on this. Regards Chris may want to try this also (instead of stating a size)... filesize($filename) This: while ($data = fgetcsv ($fp, 1, $d)) {Would be this: while ($data = fgetcsv ($fp, filesize($userfile), $d)) { Let me know... Roger Chris Payne wrote: Hi there everyone, OK So I kind of have my CSV utility working nicely, except for one thing - if I import the file with PHPMyADMIN it imports over 1000 rows (Which is correct) but with the below code on the same file, it's only importing 92 rows, can anyone see anything obvious that's wrong? I think it could be the MySQL query, as I have a count statement which counts the number of rows in the loop and it counts correctly and if I print the data on the screen it prints the data correctly, just when it writes to the DB argghhh i'm going nuts, i've been trying hard to figure it out without hasstling the group (Sorry). $d = |; // fields delimiter $fp = fopen ($userfile, r); while ($data = fgetcsv ($fp, 1, $d)) { $num = count ($data); $row++; $count ++; mysql_query (INSERT INTO import (id,BranchReference,address1,Location,Location2,Postcode,Price,Offers,Bedrooms,Receptrooms,period,Proptype,spare1,Propstatus,ShortDescription,LoDesc,PictureRef1,Bullets,Field1,Field2,Field3,Field4,Field5,Field6,Sale) VALUES ('$data[0]','$data[1]','$data[2]','$data[3]','$data[4]','$data[5]','$data[6]','$data[7]','$data[8]','$data[9]','$date[10]','$data[11]','$data[12]','$data[13]','$data[14]','$data[15]','$data[16]','$data[17]','$data[18]','$data[19]','$data[20]','$data[21]','$data[22]','$data[23]','$data[24]') ); }; echo $count; fclose ($fp); Thanks for any help Regards Chris -- ...and I say unto you, the Geek shall inherit the earth.
[PHP-DB] Fixed CSV import problem
Hi there everyone, Just a note to say i've fixed the CSV import problem, I had to excape the ' character that was in the array and now it imports all 1081 rows properly. Now I can relax and pass out LOL :-) Thanks for all the help, very appreciated. Chris
[PHP-DB] Empty Table command?
Hi there everyone, Just a quick question which I can't for the life of me find the answer for on MySQL's website (Probably as i'm looking for the wrong term?) I want to know how to empty a table, is there an empty command or should I just tell it to delete everything? Chris
Re: [PHP-DB] Splitting a CSV file
Hey there, I just want to thank everyone for their time and help, you've all been so valuable and solved my problems :-) I needed the hidden max_file_size bit in the form. But i'm also going to look at all your other suggestions you've all made, as what you say makes perfect sense from a coding point of view :-) Again thank you everyone, I don't know what i'd do without you all. Regards Chris - Crazy, but slightly less so than this morning :-) You may have hit the browser time-out limit, which you can not control (at least for IE; don't know about others). To prevent this, arrange for the script send regularly some invisible content to the browser (eg send a HTML comment line every 100 lines of your CSV file) HTH Ignatius _ - Original Message - From: Chris Payne [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, November 25, 2003 18:54 Subject: Re: [PHP-DB] Splitting a CSV file Hi there, I did a test on my local machine, set the upload limit for PHP to 50Megs for forms (WAAA more than I need, but then atleast I know that isn't the problem). Then, I select the file through my web form, put in the delimiter which works great on small files. Then, I try the larger file - exactly the same format (As I just cut a portion of the file and pasted into another file about with just about 50 entries to test which worked) and then click send, but when I try to echo the result to debug, the array is totally empty, and even tells me it is empty, but only when the file is above a certain size (Not worked out what size that is yet though). The file itself is around 5.4 megs, and I know it's not a server timeout issue as i've increased everything I could find in my local Apache config, from a timeout of 300 to 3000 (Again, just to eliminate all possible courses that I can think of). The only thing I can think of is that there is some illegal char somewhere in the file, but I have no idea what that could be. I'm using the straight line up as the delimiter to avoid any , issues etc . as I know that | isn't used in the file at all. It's just getting to me, there has to be a reason why :-( I'm using the following code (Minus the bit that enters the DB into the database, as that works fine with small files so would with large too): if ($option == importcsv) { if ($userfile == ){ $failed = 'yes'; } else { $row = 1; $handle = fopen ($userfile,r); while ($data = fgetcsv ($handle, 10, |)) { $num = count ($data); $row++; echo $data[0];; }; fclose ($handle); }}; Chris I've never seen where the file size causes a problem that wasn't one of the file size settings either in the upload form or php.ini. I'd focus on figuring out why it's failing on the large files before trying to split it. No errors at all? Just a blank screen? Are you uploading the file through a browser? Ryan -Original Message- From: Matt Babineau [mailto:[EMAIL PROTECTED] Sent: Monday, November 24, 2003 2:37 PM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] Splitting a CSV file Chris, If you are on a Redhat machine, you could try running a CLI command on this. Try looking up the 'split' command, it may solve your problem if you combine it with some PHP. -Matt On Mon, 2003-11-24 at 19:14, Chris Payne wrote: Hi there everyone, I'm writing an automation system to automatically insert data into a mysql database from a CSV file, and it works great - until I try to insert a large file, then it just doesn't do anything. I've set my PHP filesize to 10 Megs so that's not the issue, and a server timeout isn't the issue either. So, is that a way that I can split a CSV file into 2 files if it's larger than a certain size so that I can still use the automation I am working on? Actually, I won't see the files as it's for a company who just wants to be able to select their CSV file (No matter what size) and it will insert it automatically, and as I said it does work on small files but not large :-( Any help would really be appreciated. Chris -- 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 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] LIKE % command
Hi there everyone, I'm doing a search in my DB using LIKE '%$word%' which works great, but it's not case sensitive, so if I search for bike it WON'T find BIKE, i'm using PHP and MySQL. Probably something very obvious LOL it's just a basic select using LIKE. Chris
[PHP-DB] Splitting a CSV file
Hi there everyone, I'm writing an automation system to automatically insert data into a mysql database from a CSV file, and it works great - until I try to insert a large file, then it just doesn't do anything. I've set my PHP filesize to 10 Megs so that's not the issue, and a server timeout isn't the issue either. So, is that a way that I can split a CSV file into 2 files if it's larger than a certain size so that I can still use the automation I am working on? Actually, I won't see the files as it's for a company who just wants to be able to select their CSV file (No matter what size) and it will insert it automatically, and as I said it does work on small files but not large :-( Any help would really be appreciated. Chris
Re: [PHP-DB] CSV Import Question
Hi there, Yes, in the form itself there is an input field where you specify the character for import, as default it is set to , but you can change it to any. Chris On Tuesday 18 November 2003 13:07, Chris Payne wrote: any ideas? Here's the code: $row = 1; $handle = fopen ($userfile,r); while ($data = fgetcsv ($handle, 250, $delim)) { $num = count ($data); $row++; for ($c=0; $c $num; $c++) { mysql_query (INSERT INTO emaillist (EMail,name) VALUES ('$data[$c]','$data[$c]') When I import, it puts all data in the EMail field, even the name field. What exactly do you mean by puts all data in the EMail field? Does print_r($data) look OK? And you do realise that in your SQL statement you're inserting the same value for both EMail and name? What's $delim? Sorry, delim is from the form you use to select the CSV file, as you can select the char as the seperator (I have set the default to a COMMA though). By that you do mean: $delim = ','; and not $delim = COMMA; ? -- 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 -- /* Pilfering Treasury property is paticularly dangerous: big thieves are ruthless in punishing little thieves. -- Diogenes */ -- 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] CSV Import Question
Hi there, Oh I know the , (Or $Delim) isn't the problem, I think your previous email may be the answer so i'll take a good look at that once i've eaten and if it works you're the best (Heck even if it doesn't you're all the best on this list ;-) Chris Try it with just , instead of $delim. If it works, then you know that is your problem. Chris Payne [EMAIL PROTECTED] wrote: Hi there, Yes, in the form itself there is an input field where you specify the character for import, as default it is set to , but you can change it to any. Chris On Tuesday 18 November 2003 13:07, Chris Payne wrote: any ideas? Here's the code: $row = 1; $handle = fopen ($userfile,r); while ($data = fgetcsv ($handle, 250, $delim)) { $num = count ($data); $row++; for ($c=0; $c $num; $c++) { mysql_query (INSERT INTO emaillist (EMail,name) VALUES ('$data[$c]','$data[$c]') When I import, it puts all data in the EMail field, even the name field. What exactly do you mean by puts all data in the EMail field? Does print_r($data) look OK? And you do realise that in your SQL statement you're inserting the same value for both EMail and name? What's $delim? Sorry, delim is from the form you use to select the CSV file, as you can select the char as the seperator (I have set the default to a COMMA though). By that you do mean: $delim = ','; and not $delim = COMMA; ? -- 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 -- /* Pilfering Treasury property is paticularly dangerous: big thieves are ruthless in punishing little thieves. -- Diogenes */ -- 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 -- Do you Yahoo!? Protect your identity with Yahoo! Mail AddressGuard
[PHP-DB] Thank you Karen
Hi there Karen, Thank you you are a star, just tried your idea for the CSV import (With getting rid of the loop etc ) and it works perfectly, you've made an old man very happy LOL :-) Chris
[PHP-DB] CSV Import Question
Hi there everyone, I have a 2 Column CSV file, and i'm trying to import it into the DB via a form, I have it importing fine with the first field (Called EMail) but I cannot get it to import the second column correctly (Called name). I know it's going to be something so obvious i'll pass out, but does anyone have any ideas? Here's the code: $row = 1; $handle = fopen ($userfile,r); while ($data = fgetcsv ($handle, 250, $delim)) { $num = count ($data); $row++; for ($c=0; $c $num; $c++) { mysql_query (INSERT INTO emaillist (EMail,name) VALUES ('$data[$c]','$data[$c]') When I import, it puts all data in the EMail field, even the name field. Any help would be appreciated beyond belief as this is annoying the crapola out of me :-) Chris