Jump to content

proximabih

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Everything posted by proximabih

  1. Hi2all I created some PHP file which I will use through crone job to import data from csv to MySQL table automatic. But..it does not work and I dont know what is problem with. Email message says All imports FAILS? WHY? THank you all Code is: <?php define('DB_SERVER', 'localhost'); define('DB_USER', 'database-username'); define('DB_PASSWORD', 'password'); define('DB_NAME', 'database-name'); @$conn = mysql_connect (DB_SERVER, DB_USER, DB_PASSWORD); mysql_select_db (DB_NAME,$conn); if(!$conn){ die( "No connection."); } # assign the tables that you want to import to to the table array $table = array( 'table1', 'table2', 'table3', 'table4', 'table5', ); # if the first row of your csv file contains column headings: # $columnheadings=1 # if the first row does not contain column headings and should be imported: # $columnheadings=0 $columnheadings = 0; # contains the email address you want the results sent to $emailaddress = "[email protected]"; # contains the subject you want the message to have $subject = "Enter Subject Here"; # contains the email address that will show in the from line $emailfrom = "[email protected]"; # you should not have to edit anything below this line # perform the required operations for every table listed in the table array foreach ($table as $tablename) { # empty the table of its current records $deleterecords = "TRUNCATE TABLE `$tablename`"; mysql_query($deleterecords); # intialize your counters for successful and failed record imports $pass = 0; $fail = 0; # the csv file needs to be the same name as the table, # comma seperated with the columns in the same order as the table, # and in the same dir as this script $filecontents = file ("$tablename.csv"); # .csv is added to the table name to get the name of the csv file # every record in the csv file will be inserted into the table unless an error occurs with that record for($i=$columnheadings; $i<sizeof($filecontents); $i++) { $insertrecord = "Insert Into `$tablename` Values ($filecontents[$i])"; mysql_query($insertrecord); if(mysql_error()) { $fail += 1; # increments if there was an error importing the record } else { $pass += 1; # increments if the record was successfully imported } } # adds a line to the email message we will send stating how many records were imported # and how many records failed for each table $message .= "Table $tablename: Success=$pass Failure=$fail \n"; } # set to the date and time the script was run $runtime = (date("d M Y H:i")); # add the run time to the body of the email message $message .= "\nTime of the message: $runtime (server time zone)\n\n"; # Send the email message mail($emailaddress, $subject, $message, "From: '$emailfrom'"); ?>
  2. More explanation: We have another pge-a php file /contact form/. How to insert into body of php form link from the bottom of previous page?
  3. Hi2all! I have one question: A have this page: http://proximabih.com/elitesecurity/test_mapa.html Its on my native lang, but what is important that at the bottom of page is generated google maps static image of dynamic map. Now - how to send, or how to integrate this image to php $body of ph contact form. My idea is to have two pages-first is above link, another is php contact form, so if we have php contact form, on first page maby i need to create SUBMIT button which will by code automaticly put url with poicture in contact form body. I really don have any idea, any help is very appriciate )
×
×
  • 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.