php,file,file-upload,phpmailerRelated issues-Collection of common programming errors


  • shin
    php
    I have the following array structure in MySQL. There could be no items or many items; the example shows only three.Array ([0] => Array([id] => 1…[start_time] => 09:00:00[finish_time] => 10:20:00…)[1] => Array([id] => 2…[start_time] => 13:00:00[finish_time] => 14:20:00…)[2] => Array([id] => 23…[start_time] => 18:05:00[finish_time] => 19:35:00…)etc etc)I want to add the time difference between start_time and finish_time and find out the total time wi

  • themerlinproject
    php
    Looping through a dynamically-named array and comparing results to the previous positions results.if($s>1 && $s<=10){if( ${“strat{$s}”}[total] > ${“strat{$s-1}”}[total] )$sl_best = $sl_mult; //if this one did better than the previous one, then grab the value} And I’m getting error messages related the the ${“strat{$s-1}”}[total], specifically the {$s-1} portion. Here is the error message:Parse error: syntax error, unexpected ‘-‘, expecting ‘}’ …Any thoughts on how to check the

  • moogeek
    php oop class object
    How can I dynamically pass “items” to class function? For example here it is a piece of some class and its function where I declare an element of object (items) as $b://……….public function __add2SomeObj($b) { $namespc = $this -> __someObj(); // __someObj() returns object$namespc -> cats = $b;} //……………….Can I pass any other name instead cats dynamically so it won’t be declared as a string? i.e. something like://……….public function __add2SomeObj($a,$b) { $namespc

  • Brad
    php ubuntu apache2
    I have a VM with ubuntu 12.04 and running apache2 as a web server. I’ve installed PHP 5.3.10 and every time I run a php application, my php.ini throws this error: PHP: syntax error, unexpected BOOL_FALSE in /etc/php5/cli/php.ini on line 1020I’d expect that something wasn’t commented out correctly in the php.ini but when I look at it, I can’t see what’s wrong: 1007 [Pcre] 1008 ;PCRE library backtracking limit. 1009 ; http://php.net/pcre.backtrack-limit 1010 ;pcre.backtrack_limit=100000 1011 10

  • js111
    php wordpress
    I’m working with a WordPress theme (genesis framework) and i need to input a php snippet into the post meta function (right after post_edit). I cannot seem to get this to work without throwing an error. This is the function I need to work with:add_filter( ‘genesis_post_info’, ‘sp_post_info_filter’ ); function sp_post_info_filter($post_info) {$post_info = ‘[post_date] by [post_author_posts_link] [post_comments] [post_edit]’;return $post_info; }And this is the PHP snippet I need to use<?php ech

  • Julibear Police
    php
    I have this code below for updating a line on a text file.$filename = “flat-file-data.txt”; // File which holds all data $rowToUpdate = 1; // This is line need to be updated $newString = “This text is updated\n”; // This is what you want to replace it with$arrFp = file( $filename ); // Open the data file as an array // Replace the current element in array which needs to be updated with new string $arrFp[$rowToUpdate-1] = $newString; $numLines = count( $arrFp ); // Count the elements in the arra

  • Shawn31313
    php json object
    This question already has an answer here:PHP dynamic name for object property2 answersI basically know how to add a new key value pair to JSON through PHP like:$json->newObject = “value”;What I can’t however figure out is how to give the key of the pair, a random ID.I’ve tried something like:$id = rand(99, 9999); $json[“newObject” . $id] = “value”;With an error of: Fatal error: Cannot use object of type stdClass as array in /home/methodjs/public_html/projects/chat/send.php on line 8And:$id =

  • Duncan
    php arrays pdo
    Using the guidelines suggested by netnuts for the use of Data Objects for Database access, specifically in relation to unnamed placeholders# the data we want to insert $data = array(‘Cathy’, ‘9 Dark and Twisty Road’, ‘Cardiff’); $STH = $DBH->(“INSERT INTO folks (name, addr, city) values (?, ?, ?); $STH->execute($data);unfortunately seems to produce a parse error for the code# the data we want to insert $data = array($first_name, $second_name, $email_from, $telephone, $dateofbirth, $address

  • daNullSet
    php
    Look at the code below<?php //The array is storing a blog entry in it $entry = array (‘title’ => ‘sample title’,’date’ => ‘August 9, 2011′,’author’ => ‘daNullSet’,’body’ => ‘I shall become a web developer IA’,); echo “The title of the blog is “.$entry[‘title’].”<br />”; ?>The code above executes quite well, but it returns the following parse error when I enclose $entry[‘title’] in double quotes while concatenating with other strings in echo statement.Parse error: syntax e

  • Francisco Presencia
    php class variables assign
    How can I assign multiple variables at once in PHP? This is basically what I’m trying to achieve but it throws a parsing error on private $from = private $to saying syntax error, unexpected ‘private’:<?php namespace Library;class Localize{// Default data for both fields. Localization must be specified.private $from = private $to = array(‘language’ => ‘en’, // Language: English’country’ => ‘usa’, // Country: USA’currency’ => ‘dollar’, // Currency: dollar $’units’ => ‘is’

  • Adam Liss
    c file line
    I’m trying to read a file one line at a time, print out that line, then analyze each character to determine what to do with it (all the analyzing takes place in the driver, mark it as an error if the character is anything except a letter or number)My current input file is:Hello$ is asdSo this is what I am doing to read one line at a time:char GetSourceChar() {char line[MAXLINE];if (changeLine == 1) {if (fgets(line, sizeof line, file) != NULL) {char str1[10];sprintf(str1,”%d”, row); // convert in

  • Jonathan Leffler
    c file pointers struct
    I would like to store a struct in a file. I used this code:#include <stdio.h> #include <stdlib.h>typedef struct {int a;short b;char *ch; } wrFile;main() {FILE* fd=fopen(“Result.txt”,”w+”);wrFile wf={12451,14,”result”};fwrite(&wf,sizeof(wrFile),1,fd);fclose(fd); }the resul that I obtained in Result.txt is:£0^@^@^N^@^@^@^Z^G@^@^@^@^@^@The question is why?

  • Diego Favero
    php file exec ls
    I Just wanna to list all files and subdirectories and store this list in file … in MS-DOS, Linux and MAC OS, the command line — .ls( or .dir) >> files.txt — would give me what I want … But, how to make a php script run it ? if I use (on php)exec (‘ls >> files.txt’); I will get a error like this: Warning: Unexpected character in input: ” (ASCII=28) state=0 in /Applications/XAMPP/xamppfiles/htdocs/DjUtilities/makeLabels.php on line 29…please, any idea ???The use of this will be to set la

  • Templar
    php string file operators
    Let’s say I have file foo.txt in which I have one digit which is 0. Then I read that file and 0 is stored into array. I want to increment number by 1 so I just use shorthand operator ++ but it doesn’t work however += does.$poo = file(“foo.txt”); $poo[0]++; echo $poo; // gives me 0 $poo[0] += 1; echo $poo; // gives me 1I know that when I read file value of poo[0] is string with space “0 ” but why it doesn’t work with ++?

  • Eitan T
    file for-loop batch-file copy
    Looking for a batch file that would copy a file into multiple folders (within the same directory that the batch file was placed), but not their subfolders.For example: I need K:\NewCustomers\NewPartNumber.Bat to go into K:\NewCustomers\Customer Name\ but not any subfolder of \Customer Name\, there being 200-300 “Customer Name” folders.I was using:for /R “K:\NewCustomers\” %%a in (.) do copy “K:\NewCustomers\NewPartNumber.bat” “%%a”But this is recursive, and now that there are folders inside of t

  • Abs
    php windows file
    I open a Microsoft Access file normally and I can see its locked by Micorsoft Office. I then attempt to check if its writeable with PHP:echo ‘|–> ‘.is_writeable(‘C:\wamp\www\Database1.accdb’);But it returns a 1. Surley, it should return a 0 when open?Just to test, I then attempt to write to it:$fh = fopen(‘C:\wamp\www\Database1.accdb’, ‘w+’);fwrite($fh, ‘hello’);It lets me do so! Is there anyway I can make sure if a file is not open by another program?

  • Bill the Lizard
    file interprocess
    I was recently downvoted (which only bugged me a little 🙂 ) for an answer I gave to this question. The person offered no explanation for the down vote which started me thinking: “Why would you avoid producing intermediate files?” Especially in a language like Python where File IO is laughably easy.There seemed to be consensus that it was a bad idea, but I know for a fact that intermediate files are used regularly in practice. I worked for a very well respected research firm (let’s just say S

  • Jhon Woodwrick
    php file directory
    what im trying to do here, get the current file and then upload it,find the extension of the file and rename it! and echo the result!! but it seems wrong, and i dnt know which part!! :(($fieldname = $_REQUEST[‘fieldname’];$uploaddir = ‘uploads/’;$uploadfile = $uploaddir . basename($_FILES[$fieldname][‘name’]);if (move_uploaded_file($_FILES[$fieldname][‘tmp_name’], $uploadfile)) {//find the extension$extension= pathinfo($uploadfile);//rename the filerename ($uploadfile, “newfile.”.$extenion[‘exte

  • TIMEX
    python linux file unix
    import time import traceback import sys import tools from BeautifulSoup import BeautifulSoupf = open(“randomwords.txt”,”w”) while 1:try:page = tools.download(“http://wordnik.com/random”)soup = BeautifulSoup(page)si = soup.find(“h1”)w = si.stringprint wf.write(w)f.write(“\n”)time.sleep(3)except:traceback.print_exc()continuef.close()It prints just fine. It just won’t write to the file. It’s 0 bytes.

  • Tim
    c# file
    I try to write a console app C# to move my etxt files to another folder. The functions just copies certain .txt files from folder A to folder AAstring source = “C:\\A\\ResultClassA.txt”; File.Move(Source, “C:\\AA”);But its always giving this error message:Access to the path is denied.Troubleshooting tips: Make sure you have sufficient privileges to access this resource. If you are attempting to access a file, make sure it is not ReadOnly. Get general help for this exception.Do i really need to

  • Unit 342
    php file-upload
    I have a PHP app that requires semi-frequent code updates. What I do now is that I bring down the app for maintenance whenever I have to upload new scripts, effectively turning the app off for all users except myself.If I don’t do this I always see a lot of “unexpected $end” error messages in the logs, as PHP tries to interpret half-uploaded scripts. Which I of course want to avoid.My question is: Is there a safe way of doing this without bringing the app down for maintenance? In an environment

  • Saeid Ghaferi
    php jquery-ui file-upload blueimp
    I’ve set up the jQuery File Upload – blueimp on my local server and everything works great! I uploaded the script onto my server and when I upload images I recieve this error SyntaxError: Unexpected token <my files are uploaded, both the originals and the thumbnails, but for some reason it wont show the files that are uploaded. Please help Thank you

  • Igoru
    ajax ruby-on-rails-3 file-upload
    I’m using qqfileupload (http://valums.com/ajax-upload/) to create a single drag & drop image upload interface. The request is being sent to rails, and my rails console is returning!! Unexpected error while processing request: invalid %-encoding (????JFIFdd??Ducky??Adobed)which I assume is rails attempting to read the file.I set my controller to outputreturn render :text => paramsthinking that I could look at what the server was recieving, but I only get the Unexpected error again, which to m

  • Jason
    c# csv file-upload .net-4.0 webclient
    I am attempting to upload a csv file but I can’t seem to get it to work programatically. If I use Postman in Chrome to send the file it works and here is what it sends (Fiddler output):——WebKitFormBoundary2YsMyLR3QAPruTy4 Content-Disposition: form-data; name=”Content-Type”; filename=”613022.csv” Content-Type: application/vnd.ms-excel// File Content here——WebKitFormBoundary2YsMyLR3QAPruTy4–However, using this code:WebClient wc = new WebClient();wc.Credentials = new NetworkCredential(use

  • Aditya Mohan
    php mysql database file-upload
    i am trying to insert data in a ‘songs’ column of a table with name same as the current session variable username. but it is giving following errorParse error: syntax error, unexpected ‘”‘, expecting T_STRING or T_VARIABLE or T_NUM_STRINGmysql_query(“INSERT INTO “.$_SESSION[‘username’].”(‘songs’) VALUES(\”$_FILES[“file”][“name”]\”)”);

  • ???n B?rtiL
    android file file-upload cordova file-transfer
    I am using phonegap to upload file to a server. I am making android app which takes picture and send to server. I am getting error “Response Parse error syntax error, unexpected T_STRING in this line” I am also pasting the code this is my phonegap code.navigator.camera.getPicture( cameraSuccess, cameraError, {quality : 75,destinationType : Camera.DestinationType.FILE_URI,sourceType : Camera.PictureSourceType.PHOTOLIBRARY,mediaType: navigator.camera.MediaType.ALLMEDIA,allowEdit : true,targetWid

  • Pravin
    objective-c file-upload asp.net-web-api
    I have following ASP.net WebAPI code which handles file uploads. Works great using a simple HTML file upload form.public Task<IEnumerable<string>> UploadFile() {if (Request.Content.IsMimeMultipartContent()){string fullPath = HttpContext.Current.Server.MapPath(“~/uploads”);MultipartFormDataStreamProvider streamProvider = new MultipartFormDataStreamProvider(fullPath);var task = Request.Content.ReadAsMultipartAsync(streamProvider).ContinueWith(t =>{if (t.IsFaulted || t.IsCanceled

  • abatishchev
    c# wcf file-upload exception-handling
    My server config file:<?xml version=”1.0″ encoding=”UTF-8″?> <configuration><system.webServer><security><requestFiltering><requestLimits maxAllowedContentLength=”500000000″></requestLimits></requestFiltering></security></system.webServer><system.serviceModel><bindings><basicHttpBinding><binding name=”HttpEndpointBinding” receiveTimeout=”00:10:30″ maxBufferPoolSize=”2147483647″ maxReceivedMessageSize=”2147483647″ max

  • jpo
    asp.net file-upload web-config app-config endpoint
    There are a number of post already out there but I cannot get this to work. The posts suggest to define the tags endpoints and binding both client side and server side. All I have is the applications web.config file. How do I make the distinction between client side and server side. In my web.config, i defined a services tag, but it seems as if it is not used as the face binding configurations defined in there is never called out when debugging. My web.config looks like this:<?xml version=”1.

  • Loki
    php jquery file-upload
    I want use prduct but when upload image i see error SyntaxError: JSON.parse: unexpected non-whitespace character after JSON datascript directory: Folder2 directory Jquery-file-upload: function/blueimp-jQuery-File-Upload/ in main.js i edit rows$(‘#fileupload’).fileupload({ // Uncomment the following to send cross-domain cookies: //xhrFields: {withCredentials: true}, url: ‘server/php/’ });on$(‘#fileupload’).fileupload({ // Uncomment the following to send cross-domain cookies: //xhrFields: {withCre

  • Katie
    forms phpmailer comments
    I have a site that is hosted on inmotion hosting and requires a phpMailer in order to send an email form (such as a contact form) from a site. I’ve put the necessary files and code on the contact page, but I am getting a parse error once I hit submit. Here’s the error message:Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or ‘}’ in /home/username/public_html/phpmailer/class.phpmailer.php on line 53Line 53 according to DreamWeaver is public $Prio

  • Darsshan Nair
    php html html-email phpmailer swiftmailer
    $transport = Swift_SmtpTransport::newInstance(‘smtp.gmail.com’, 465, “ssl”)->setUsername(‘username’)->setPassword(‘password’);$username = $_SESSION[‘username’]; $from = $_POST[‘from’];$to = $_POST[‘to’];$subject = $_POST[‘subject’];$body = $_POST[‘message’];$message = Swift_Message::newInstance($subject)->setFrom(array($from => $username)) ->setTo(array($to)) ->setBody($body);$mailer = Swift_Mailer::newInstance($transport); $result = $mailer->send($message);Error on Webpag

  • Jason George
    php try-catch phpmailer
    I have a mailer script that is looping, processing outgoing emails from my server. Occasionally it hangs up with the following error.PHP Fatal error: Uncaught exception ‘phpmailerException’ with message ‘SMTP Error: Data not accepted.’This causes my script to die before the reminder of the messages can complete.Here is the code that kicks off the email.$message = new \PHPMailer(true); $message -> IsSMTP(); try {$message -> SMTPAuth = true;$message -> Host = Config::HOST;$message -> Port = Conf

  • matino
    php email phpmailer
    I’m trying to create a contact form using phpMailer and I get in firebug this: NetworkError: 500 Internal Server Error – path/process.php uncaught exception: [object Object]each time I’m trying to run the code below. Please note that the error is not shown anymore if I remove $mail->AddAddress line, that’s why I suspect this line to be the cause. Instead a new error is displayed: You must provide at least one recipient email address when I remove it.<?php $name = $_POST[‘firstName’]; $ema

  • Charles
    php phpmailer
    I am getting the error Fatal error: Uncaught exception ‘phpmailerException’ with message ‘Invalid address: ‘ etc. etc. etc. and it is a real eye sore on the page.So I want to capture the error or suppress it or something – and then have it be returned to the form so the user can be told there is an error and to re-input their email address. All this will be neat and tidy and not the mess of an error it is now.Does anyone know how to do this?Thanks

  • Alfabravo
    php phpmailer
    Im new to classes and im trying to create a static email class that uses the phpmailer class.What I’d like to do is something like…Email::send(‘from’, ‘to’, ‘subject’, ‘html message’); // worksbut if i want to add an attachment…Email::send(‘from’, ‘to’, ‘subject’, ‘html message’)->attach(‘file/blah.txt’);This throws a fatal error: Call to undefined method PHPMailer::attach(), I understand why, I just don’t know how to go about it making the Email class do the above code, if it’s even poss

  • Jonah Katz
    php phpmailer email-attachments
    Ive been working on create a file upload form using PHPmailer to send as attachments. Ive finally got it to send the email, but its not sending the attachment. Here’s my HTML form:<input type=”file” class=”fileupload” name=”images[]” size=”80″ />And here’s my php processor code:<?php require(“css/class.phpmailer.php”); //Variables Declaration $name = “the Submitter”; $email_subject = “Images Attachment”; $Email_msg =”A visitor submitted the following :\n”; $Email_to = “[email protected]

  • hooligan
    php phpmailer
    I’ve just updated a contact form to use PHPMailer to stop emails being marked as junk, with no luck. It’s a fairly straight forward setup I’m using but its still going into peoples junk mail.Here is my script, I was wondering if anyone could tell what was wrong?include_once(‘../inc/phpmailer/class.phpmailer.php’);$mail = new PHPMailer();$name = $_POST[‘name’]; $email = $_POST[’email’]; $body = “Name: “.$name.”\r\n”; $body .= “Email: “.$email.”\r\n”; $body .= “Message: “.$_POST[‘message’];$mail-&

  • Jonah Katz
    php file file-upload phpmailer
    I have an HTML / javascript form written with a loop to upload an unlimited amount of files with names=”file1″,”file2″,etc. (i++)So now i have a PHP form to process it (get all files, save to temporary folder “uploads”, and email as attachments using phpmailer). <?php require(“class.phpmailer.php”); //Variables Declaration $name = “the Submitter”; $email_subject = “Images Attachment”; $Email_msg =”A visitor submitted the following :\n”; $Email_to = “[email protected]”; // the one that recieves

  • Gatura
    php phpmailer
    am getting these errors while running php mailer. What could be the problemMAMP/htdocs/practice/email/email.php on line 2 [06-Jun-2011 09:53:40] PHP Notice: Undefined variable: from in /Applications/MAMP/htdocs/practice/phpmailer/phpmailer.inc.php on line 259 [06-Jun-2011 09:53:40] PHP Notice: Undefined variable: Encoding in /Applications/MAMP/htdocs/practice/phpmailer/phpmailer.inc.php on line 271 [06-Jun-2011 09:53:40] PHP Fatal error: Cannot access empty property in /Applications/MAMP/

Web site is in building