Jump to content

QuePID

Members
  • Posts

    19
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

QuePID's Achievements

Member

Member (2/5)

0

Reputation

  1. This is very helpful as I desire to produce code which works equally well across platforms.
  2. Switching to / instead of \ as directory separators worked like a charm. Thanks guys!
  3. What you suggested worked except for this line (#14): $speciesname='C:\herbariumdb.eku.edu\images\'.$family.'\'.$genus.'\'.$species; which gives error: PHP Parse error: syntax error, unexpected T_STRING in C:\herbariumdb.eku.edu\qpadmin\foldercreationtest.php on line 14
  4. Here is the code: <?php //Define variables for a test drive of folder detection/creation. $family="Family"; $genus="Genus"; $species="Species"; //Create variable to hold family name along with path and make the folder should it not exist. $familyname="C:\herbariumdb.eku.edu\images\$family"; if(!is_dir($familyname)) mkdir ('$familyname',777); echo "$familyname<br>"; //Create variable to hold genus name along with path and make the folder should it not exist. $genusname='C:\herbariumdb.eku.edu\images\$family\$genus'; if(!is_dir($genusname)) mkdir ("$genusname",777); echo "$genusname<br>"; //Create variable to hold genus name along with path and make the folder should it not exist. $speciesname='C:\herbariumdb.eku.edu\images\$family\$genus\$species'; if(!is_dir($species)) mkdir ("$species",777); echo "$speciesname<br>"; ?> Here is the output: C:\herbariumdb.eku.edu\images$family C:\herbariumdb.eku.edu\images\$family\$genus C:\herbariumdb.eku.edu\images\$family\$genus\$species The $vars should be their values not their names, but something is askew.
  5. Hi, I am wanting to check to see if a folder exists, if not create it. PHP on a windows machine so I would like to know how to handle the folder separators. I am wanting to use a path which includes the drive letter, such as... $foldername ="C:\folder1\images\$checkfolder" I was thinking about using something like this: if(!is_dir($foldername)) mkdir ("$foldername",777); What would be the best way of tackling this using windows paths?
  6. It's not working for some reason here is the code: if ($date=NULL) $date="0000-00-00"; if ($col_datet=NULL) $col_datet="0000-00-00"; Here is the error given: Incorrect date value: '' for column 'Col_Datet' at row 1 What I am doing is retrieving a record from a mysql database in which the date and col_datet columns contain either a date or NULL. When I go to update the query with either of those two fields in which they contain a null the update query fails. So what I am wanting to do with PHP is to use a default date of 0000-00-00 instead of a NULL for the update query.
  7. How can I check a variable to see if it is NULL and if so set to 0000-00-00? I've tried: if ($var IS NULL) THEN $var='0000-00-00'; to no avail.
  8. I've tried it with a single SET and still gives the same error.
  9. Hi, I am building an update query which will update a record in a table, but I am getting an error which doesn't make sense to me. Here is my code: $query = "UPDATE iknew SET ID='$id', SET Herbarium='$herbarium', SET Taxon='$taxon', SET Bar_Code='$bar_code', SET GUID='$guid', SET Private='$private', SET Image='$image', SET Kingdom='$kingdom', SET Genus='$genus', SET Species='$species', SET Variety_Name='$variety_name', SET Taxon_Author='$taxon_author', SET Accession='$accession', SET State='$state', SET County='$county', SET Habitat='$habitat', SET Locality='$locality', SET Latitude='$latitude', SET Longitude='$longitude', SET Quadrangle='$quadrangle', SET Collector='$collector', SET Collection_Number='$collection_number', SET Country='$country', SET Family='$family', SET Annotation='$annotation', SET Col_Date='$col_date', SET Comments='$comments', SET Natural_Area='$natural_area', SET Col_datet='$col_datet', SET Symbol='$symbol' WHERE ID='$id' LIMIT 1"; Here is a sample update query: UPDATE iknew SET ID='62547', SET Herbarium='EKY', SET Taxon='Salix exigua Nutt.', SET Bar_Code='3288', SET GUID='', SET Private='1', SET Image='', SET Kingdom='Plantae', SET Genus='Salix', SET Species='exigua', SET Variety_Name='', SET Taxon_Author='Nutt.', SET Accession='EKY3288', SET State='Kentucky', SET County='Madison', SET Habitat='stream bank', SET Locality='Hagan Mill Road at bridge over Silver Creek.', SET Latitude=' 0', SET Longitude=' 0', SET Quadrangle='', SET Collector='John Hornback', SET Collection_Number='38', SET Country='USA', SET Family='Salicaceae', SET Annotation='', SET Col_Date='1976-04-18', SET Comments='RRP', SET Natural_Area='', SET Col_datet='', SET Symbol='SAEX' WHERE ID='62547' LIMIT 1 And here is the error given: 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 'SET Herbarium='EKY', SET Taxon='Salix exigua Nutt.', SET Bar_Code='3288', SET' at line 3 Any help would be quite appreciated.
  10. Worked like a charm, and was quite fast. How would I do similar for a count of all records within the table?
  11. When I echo the results of your query string I get "Resource id #6", and when I use mysql_num_rows($results) I get a value of 1 which isn't correct (should be 224). What is the type of data returned in the results of the query?
  12. Hi, I have a database with roughly 73k rows (records). I am using a query string such as: SELECT DISTINCT Column FROM databasename I am then using mysql_num_rows($results) to count the number of distinct rows. This method works, but it is slow. Is there a faster way of doing this perhaps internal to the mysql without having to send the entire results to the PHP when I only need a count?
  13. I used phpmyadmin version 3.3.3 to back up MySQL table data and would love to know how to restore the data to mysql via PHP (not phpmyadmin). Also how can one produce phpmyadmin compatible .sql dumps of a tables data? I know easy ways of doing this via the mysql command console, but want to be able to handle this via php.
  14. I have a large table with roughly thousands of duplicates in a field which should have been unique. I need a way of creating a new table with all the duplicate records for later sorting. I have a duplicate-free copy of the old table saved as a new table. I have tried CREATE TABLE iknew1 as SELECT iknew.*, COUNT(*) FROM iknew GROUP BY Accession HAVING COUNT(*) > 1 But this only copies one of the duplicated records not both, and I will need both records for comparison and to aid determining if the dupes are from data entry.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.