Search Results

Search found 616 results on 25 pages for 'fopen'.

Page 4/25 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Facebook app getting "Warning: fopen......." - Please help!

    - by Poni
    Hello! I'm trying to establish a Facebook application. I'm getting the following PHP notice randomly: Warning: fopen(http://api.facebook.com/restserver.php? … &v=1.0) [function.fopen]: failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request in D:\projects........\facebookapi_php5_restlib.php on line 3391 As said, it happens randomly. My app configuration: IFrame Page host configuration: Windows Vista, Apache 2.2.11, PHP 5.1 No support for cURL is possible at the moment. My aim: Get the user's first name & pic_square along with two other preferences. If these two preferences are not set then I'll set them, after doing some internal job. I understand that the REST API is old. Which interface should I use then? Saw FQL, which seem to be fine, but I see no corresponding getUserPreference/setUserPreference interface. Where is it? How do I combine it with the "first name & pic_square" info that I need in one query? How do I read the results of multi-query query? Also, if I understand correctly, the FQL is also executed with the fopen() function, and as we see here it might fail. That means something went wrong, and then I want to handle it. Any suggestions how to do so efficiently? Less important than the above question though. Thank you all.

    Read the article

  • Problem with filefield module after migrating drupal site to a new server: cant upload files

    - by oalo
    We have a content type with two imagefield / filefield fields, and after migrating our site to a new server, we have the following problem: When we submit a new item for this content type, with two images for those fields, drupal gives us the following error and does not upload the images: warning: fopen(sites/default/files/.htaccess) [function.fopen]: failed to open stream: Permission denied in /websites/sitename/data/sites/all/modules/filefield/field_file.inc on line 349. warning: fopen(sites/default/files/.htaccess) [function.fopen]: failed to open stream: Permission denied in /websites/sitename/data/sites/all/modules/filefield/field_file.inc on line 349. An image thumbnail was not able to be created. warning: fopen(sites/default/files/.htaccess) [function.fopen]: failed to open stream: Permission denied in /websites/sitename/data/sites/all/modules/filefield/field_file.inc on line 349. warning: fopen(sites/default/files/.htaccess) [function.fopen]: failed to open stream: Permission denied in /websites/sitename/data/sites/all/modules/filefield/field_file.inc on line 349. An image thumbnail was not able to be created. I understand this is a permissions error, but it is not clear to me where do I have to change permissions. Line 349 of file.inc has the following code: if (($fp = fopen("$directory/.htaccess", 'w')) && fputs($fp, $htaccess_lines)) { fclose($fp); chmod($directory .'/.htaccess', 0664); } else { $repl = array('%directory' = $directory, '!htaccess' = nl2br(check_plain($htaccess_lines))); form_set_error($form_item, t("Security warning: Couldn't write .htaccess file. Please create a .htaccess file in your %directory directory which contains the following lines:!htaccess", $repl));

    Read the article

  • Why does C's "fopen" take a "const char *" as its second argument?

    - by Chris Cooper
    It has always struck me as strange that the C function "fopen" takes a "const char *" as the second argument. I would think it would be easier to both read your code and implement the library's code if there were bit masks defined in stdio.h, like "IO_READ" and such, so you could do things like: FILE* myFile = fopen("file.txt", IO_READ & IO_WRITE); Is there a programmatic reason for the way it actually is, or is it just historic? (i.e. "That's just the way it is.")

    Read the article

  • PHP fopen fails - does not have permission to open file in write mode.

    - by George
    Hello. I have an Apache 2.17 server running on a Fedora 13. I want to be able to create a file in a directory. I cannot do that. Whenever I try to open a file with php for writing fopen(,'w'), it tells me that I don't have permission to do that. So i checked the httpd.conf file in /etc/httpd/conf/. It says user apache, group apache. So I changed ownership (chown -R apache:apache .*) of my whole /www directory to apache:apache. I also run chmod -R 777 * Apart from knowing how terribly dangerous this is, it actually still gives me the same error, even though I even allow public write!

    Read the article

  • best practice on precedence of variable declaration and error handling in C

    - by guest
    is there an advantage in one of the following two approaches over the other? here it is first tested, whether fopen succeeds at all and then all the variable declarations take place, to ensure they are not carried out, since they mustn't have had to void func(void) { FILE *fd; if ((fd = fopen("blafoo", "+r")) == NULL ) { fprintf(stderr, "fopen() failed\n"); exit(EXIT_FAILURE); } int a, b, c; float d, e, f; /* variable declarations */ /* remaining code */ } this is just the opposite. all variable declarations take place, even if fopen fails void func(void) { FILE *fd; int a, b, c; float d, e, f; /* variable declarations */ if ((fd = fopen("blafoo", "+r")) == NULL ) { fprintf(stderr, "fopen() failed\n"); exit(EXIT_FAILURE); } /* remaining code */ } does the second approach produce any additional cost, when fopen fails? would love to hear your thoughts!

    Read the article

  • PHP , What is the difference between fopen r+ and r ! does it matter if i used r+ when not intending

    - by Naughty.Coder
    when I use fopen function , why don't I use r+ always , even when I'm not going to write any thing ... is there a reason for separating writing/reading process from only reading .. like , the file is locked for reading when I use r+ , because i might write new data into it or something ... another question : in php manual a+ : Open for reading and writing; place the file pointer at the end of the file. If the file does not exist, attempt to create it. What is supposed to be read if you are at the end of the file ..(pointer at the end) !!? where to learn more about the filesystem thing .... it's confusing

    Read the article

  • error LNK2019 for ZLib sample compare.

    - by Nano HE
    Hello. I created win32 console application in vs2010 (without select the option of precompiled header). And I inserted the code below. but *.obj link failed. Could you provide me more information about the error. I searched MSDN, but still can't understand it. #include <stdio.h> #include "zlib.h" // Demonstration of zlib utility functions unsigned long file_size(char *filename) { FILE *pFile = fopen(filename, "rb"); fseek (pFile, 0, SEEK_END); unsigned long size = ftell(pFile); fclose (pFile); return size; } int decompress_one_file(char *infilename, char *outfilename) { gzFile infile = gzopen(infilename, "rb"); FILE *outfile = fopen(outfilename, "wb"); if (!infile || !outfile) return -1; char buffer[128]; int num_read = 0; while ((num_read = gzread(infile, buffer, sizeof(buffer))) > 0) { fwrite(buffer, 1, num_read, outfile); } gzclose(infile); fclose(outfile); } int compress_one_file(char *infilename, char *outfilename) { FILE *infile = fopen(infilename, "rb"); gzFile outfile = gzopen(outfilename, "wb"); if (!infile || !outfile) return -1; char inbuffer[128]; int num_read = 0; unsigned long total_read = 0, total_wrote = 0; while ((num_read = fread(inbuffer, 1, sizeof(inbuffer), infile)) > 0) { total_read += num_read; gzwrite(outfile, inbuffer, num_read); } fclose(infile); gzclose(outfile); printf("Read %ld bytes, Wrote %ld bytes, Compression factor %4.2f%%\n", total_read, file_size(outfilename), (1.0-file_size(outfilename)*1.0/total_read)*100.0); } int main(int argc, char **argv) { compress_one_file(argv[1],argv[2]); decompress_one_file(argv[2],argv[3]);} Output: 1>------ Build started: Project: zlibApp, Configuration: Debug Win32 ------ 1> zlibApp.cpp 1>d:\learning\cpp\cppvs2010\zlibapp\zlibapp\zlibapp.cpp(15): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. 1> c:\program files\microsoft visual studio 10.0\vc\include\stdio.h(234) : see declaration of 'fopen' 1>d:\learning\cpp\cppvs2010\zlibapp\zlibapp\zlibapp.cpp(25): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. 1> c:\program files\microsoft visual studio 10.0\vc\include\stdio.h(234) : see declaration of 'fopen' 1>d:\learning\cpp\cppvs2010\zlibapp\zlibapp\zlibapp.cpp(40): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. 1> c:\program files\microsoft visual studio 10.0\vc\include\stdio.h(234) : see declaration of 'fopen' 1>d:\learning\cpp\cppvs2010\zlibapp\zlibapp\zlibapp.cpp(36): warning C4715: 'decompress_one_file' : not all control paths return a value 1>d:\learning\cpp\cppvs2010\zlibapp\zlibapp\zlibapp.cpp(57): warning C4715: 'compress_one_file' : not all control paths return a value 1>zlibApp.obj : error LNK2019: unresolved external symbol _gzclose referenced in function "int __cdecl decompress_one_file(char *,char *)" (?decompress_one_file@@YAHPAD0@Z) 1>zlibApp.obj : error LNK2019: unresolved external symbol _gzread referenced in function "int __cdecl decompress_one_file(char *,char *)" (?decompress_one_file@@YAHPAD0@Z) 1>zlibApp.obj : error LNK2019: unresolved external symbol _gzopen referenced in function "int __cdecl decompress_one_file(char *,char *)" (?decompress_one_file@@YAHPAD0@Z) 1>zlibApp.obj : error LNK2019: unresolved external symbol _gzwrite referenced in function "int __cdecl compress_one_file(char *,char *)" (?compress_one_file@@YAHPAD0@Z) 1>D:\learning\cpp\cppVS2010\zlibApp\Debug\zlibApp.exe : fatal error LNK1120: 4 unresolved externals ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

    Read the article

  • error LNK2019 for ZLib sample code compiling.

    - by Nano HE
    Hello. I created win32 console application in vs2010 (without select the option of precompiled header). And I inserted the code below. but *.obj link failed. Could you provide me more information about the error. I searched MSDN, but still can't understand it. #include <stdio.h> #include "zlib.h" // Demonstration of zlib utility functions unsigned long file_size(char *filename) { FILE *pFile = fopen(filename, "rb"); fseek (pFile, 0, SEEK_END); unsigned long size = ftell(pFile); fclose (pFile); return size; } int decompress_one_file(char *infilename, char *outfilename) { gzFile infile = gzopen(infilename, "rb"); FILE *outfile = fopen(outfilename, "wb"); if (!infile || !outfile) return -1; char buffer[128]; int num_read = 0; while ((num_read = gzread(infile, buffer, sizeof(buffer))) > 0) { fwrite(buffer, 1, num_read, outfile); } gzclose(infile); fclose(outfile); } int compress_one_file(char *infilename, char *outfilename) { FILE *infile = fopen(infilename, "rb"); gzFile outfile = gzopen(outfilename, "wb"); if (!infile || !outfile) return -1; char inbuffer[128]; int num_read = 0; unsigned long total_read = 0, total_wrote = 0; while ((num_read = fread(inbuffer, 1, sizeof(inbuffer), infile)) > 0) { total_read += num_read; gzwrite(outfile, inbuffer, num_read); } fclose(infile); gzclose(outfile); printf("Read %ld bytes, Wrote %ld bytes, Compression factor %4.2f%%\n", total_read, file_size(outfilename), (1.0-file_size(outfilename)*1.0/total_read)*100.0); } int main(int argc, char **argv) { compress_one_file(argv[1],argv[2]); decompress_one_file(argv[2],argv[3]);} Output: 1>------ Build started: Project: zlibApp, Configuration: Debug Win32 ------ 1> zlibApp.cpp 1>d:\learning\cpp\cppvs2010\zlibapp\zlibapp\zlibapp.cpp(15): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. 1> c:\program files\microsoft visual studio 10.0\vc\include\stdio.h(234) : see declaration of 'fopen' 1>d:\learning\cpp\cppvs2010\zlibapp\zlibapp\zlibapp.cpp(25): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. 1> c:\program files\microsoft visual studio 10.0\vc\include\stdio.h(234) : see declaration of 'fopen' 1>d:\learning\cpp\cppvs2010\zlibapp\zlibapp\zlibapp.cpp(40): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. 1> c:\program files\microsoft visual studio 10.0\vc\include\stdio.h(234) : see declaration of 'fopen' 1>d:\learning\cpp\cppvs2010\zlibapp\zlibapp\zlibapp.cpp(36): warning C4715: 'decompress_one_file' : not all control paths return a value 1>d:\learning\cpp\cppvs2010\zlibapp\zlibapp\zlibapp.cpp(57): warning C4715: 'compress_one_file' : not all control paths return a value 1>zlibApp.obj : error LNK2019: unresolved external symbol _gzclose referenced in function "int __cdecl decompress_one_file(char *,char *)" (?decompress_one_file@@YAHPAD0@Z) 1>zlibApp.obj : error LNK2019: unresolved external symbol _gzread referenced in function "int __cdecl decompress_one_file(char *,char *)" (?decompress_one_file@@YAHPAD0@Z) 1>zlibApp.obj : error LNK2019: unresolved external symbol _gzopen referenced in function "int __cdecl decompress_one_file(char *,char *)" (?decompress_one_file@@YAHPAD0@Z) 1>zlibApp.obj : error LNK2019: unresolved external symbol _gzwrite referenced in function "int __cdecl compress_one_file(char *,char *)" (?compress_one_file@@YAHPAD0@Z) 1>D:\learning\cpp\cppVS2010\zlibApp\Debug\zlibApp.exe : fatal error LNK1120: 4 unresolved externals ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

    Read the article

  • implementation of text editor in shell programming

    - by Arka Ghosh
    i have made a text editor in C. when i am changing the extension of that file from .c to .sh and compiling the file in the terminal,some error is shown,like for the global variables an external error is shown,and for the functions i have declared errors are shown there also.please help me to solve this. I am sending my code.. include include include int i,j,ec,fg,ec2; char fn[20],e,c,d; FILE *fp1,*fp2,fp; void Create(); void Append(); void Delete(); void Display(); int main() { do { printf("\n\t\t** TEXT EDITOR *"); printf("\n\n\tMENU:\n\t..\n "); printf("\n\t1.CREATE\n\t2.DISPLAY\n\t3.APPEND\n\t4.DELETE\n\t5.EXIT\n"); printf("\n\tEnter your choice: "); scanf("%d",&ec); switch(ec) { case 1: Create(); break; case 2: Display(); break; case 3: Append(); break; case 4: Delete(); break; case 5: exit(1); } }while(1); } void Create() { fp1=fopen("temp.txt","w"); printf("\n\tEnter the text and press '.' to save\n\n\t"); while(1) { c=getchar(); fputc(c,fp1); if(c == '.') { fclose(fp1); printf("\n\tEnter then new filename: "); scanf("%s",fn); fp1=fopen("temp.txt","r"); fp2=fopen(fn,"w"); while(!feof(fp1)) { c=getc(fp1); putc(c,fp2); } fclose(fp2); break; }} } void Display() { printf("\n\tEnter the file name: "); scanf("%s",fn); fp1=fopen(fn,"r"); if(fp1==NULL) { printf("\n\tFile not found!"); goto end1; } while(!feof(fp1)) { c=getc(fp1); printf("%c",c); } end1: fclose(fp1); printf("\n\n\tPress any key to continue.."); } void Delete() { printf("\n\tEnter the file name: "); scanf("%s",fn); fp1=fopen(fn,"r"); if(fp1==NULL) { printf("\n\tFile not found!"); goto end2; } fclose(fp1); if(remove(fn)==0) { printf("\n\n\tFile has been deleted successfully!"); goto end2; } else printf("\n\tError!\n"); end2: printf("\n\n\tPress any key to continue.."); getchar(); } void Append() { printf("\n\tEnter the file name: "); scanf("%s",fn); fp1=fopen(fn,"r"); if(fp1==NULL) { printf("\n\tFile not found!"); goto end3; } while(!feof(fp1)) { c=getc(fp1); printf("%c",c); } fclose(fp1); printf("\n\tType the text and press 'Ctrl+s' to append.\n"); fp1=fopen(fn,"a"); while(1) { c=getchar(); if(c==19) goto end3; if(c==13) { d='\n'; fputc(d,fp1); } else { fputc(c,fp1); } } end3: fclose(fp1); }

    Read the article

  • Time complexity of a sorting algorithm

    - by Passonate Learner
    The two programs below get n integers from file and calculates the sum of ath to bth integers q(number of question) times. I think the upper program has worse time complexity than the lower, but I'm having problems calculating the time complexity of these two algorithms. [input sample] 5 3 5 4 3 2 1 2 3 3 4 2 4 [output sample] 7 5 9 Program 1: #include <stdio.h> FILE *in=fopen("input.txt","r"); FILE *out=fopen("output.txt","w"); int n,q,a,b,sum; int data[1000]; int main() int i,j; fscanf(in,"%d%d",&n,&q); for(i=1;i<=n;i++) fscanf(in,"%d",&data[i]); for i=0;i<q;i++) { fscanf(in,"%d%d",&a,&b); sum=0; for(j=a;j<=b;j++) sum+=data[j]; fprintf(out,"%d\n",sum); } return 0; } Program 2: #include <stdio.h> FILE *in=fopen("input.txt","r"); FILE *out=fopen("output.txt","w"); int n,q,a,b; int data[1000]; int sum[1000]; int main() { int i,j; fscanf(in,"%d%d",&n,&q); for(i=1;i<=n;i++) fscanf(in,"%d",&data[i]); for(i=1;i<=n;i++) sum[i]=sum[i-1]+data[i]; for(i=0;i<q;i++) { fscanf(in,"%d%d",&a,&b); fprintf(out,"%d\n",sum[b]-sum[a-1]); } return 0; } The programs below gets n integers from 1 to m and sorts them. Again, I cannot calculate the time complexity. [input sample] 5 5 2 1 3 4 5 [output sample] 1 2 3 4 5 Program: #include <stdio.h> FILE *in=fopen("input.txt","r") FILE *out=fopen("output.txt","w") int n,m; int data[1000]; int count[1000]; int main() { int i,j; fscanf(in,"%d%d",&n,&m); for(i=0;i<n;i++) { fscanf(in,"%d",&data[i]); count[data[i]]++ } for(i=1;i<=m;i++) { for(j=0;j<count[i];j++) fprintf(out,"%d ",i); } return 0; } It's ironic(or not) that I cannot calculate the time complexity of my own algorithms, but I have passions to learn, so please programming gurus, help me!

    Read the article

  • stdio's remove() not always deleting on time.

    - by Kyte
    For a particular piece of homework, I'm implementing a basic data storage system using sequential files under standard C, which cannot load more than 1 record at a time. So, the basic part is creating a new file where the results of whatever we do with the original records are stored. The previous file's renamed, and a new one under the working name is created. The code's compiled with MinGW 5.1.6 on Windows 7. Problem is, this particular version of the code (I've got nearly-identical versions of this floating around my functions) doesn't always remove the old file, so the rename fails and hence the stored data gets wiped by the fopen(). FILE *archivo, *antiguo; remove("IndiceNecesidades.old"); // This randomly fails to work in time. rename("IndiceNecesidades.dat", "IndiceNecesidades.old"); // So rename() fails. antiguo = fopen("IndiceNecesidades.old", "rb"); // But apparently it still gets deleted, since this turns out null (and I never find the .old in my working folder after the program's done). archivo = fopen("IndiceNecesidades.dat", "wb"); // And here the data gets wiped. Basically, anytime the .old previously exists, there's a chance it's not removed in time for the rename() to take effect successfully. No possible name conflicts both internally and externally. The weird thing's that it's only with this particular file. Identical snippets except with the name changed to Necesidades.dat (which happen in 3 different functions) work perfectly fine. // I'm yet to see this snippet fail. FILE *antiguo, *archivo; remove("Necesidades.old"); rename("Necesidades.dat", "Necesidades.old"); antiguo = fopen("Necesidades.old", "rb"); archivo = fopen("Necesidades.dat", "wb"); Any ideas on why would this happen, and/or how can I ensure the remove() command has taken effect by the time rename() is executed? (I thought of just using a while loop to force call remove() again so long as fopen() returns a non-null pointer, but that sounds like begging for a crash due to overflowing the OS with delete requests or something.)

    Read the article

  • How to solve this simple PHP forloop issue?

    - by Londonbroil Wellington
    Here is the content of my flat file database: Jacob | Little | 22 | Male | Web Developer * Adam | Johnson | 45 | Male | President * Here is my php code: <?php $fopen = fopen('db.txt', 'r'); if (!$fopen) { echo 'File not found'; } $fread = fread($fopen, filesize('db.txt')); $records = explode('|', $fread); ?> <table border="1" width="100%"> <tr> <thead> <th>First Name</th> <th>Last Name</th> <th>Age</th> <th>Sex</th> <th>Occupation</th> </thead> </tr> <?php $rows = explode('*', $fread); for($i = 0; $i < count($rows) - 1; $i++) { echo '<tr>'; echo '<td>'.$records[0].'</td>'; echo '<td>'.$records[1].'</td>'; echo '<td>'.$records[2].'</td>'; echo '<td>'.$records[3].'</td>'; echo '<td>'.$records[4].'</td>'; echo '</tr>'; } fclose($fopen); ?> </table> Problem is I am getting the output of the first record repeated twice instead of 2 records one for Jacob and one for Adam. How to fix this?

    Read the article

  • Opening a file in Mac OS X

    - by Pooya
    I am trying to open a text file with C++ in Mac OS X but I always get a Bus error. I do not care where to put the file. I just need to read it. Am I writing its address wrong? or that Bus Error has another reason? FILE *dic; dic = fopen("DICT","rb"); dic = fopen("./DICT","rb"); dic = fopen("~/DICT","rb"); dic = fopen("~//DICT","rb");

    Read the article

  • Errors checking and opening a URL using PHP

    - by Jean
    Hello Here is one script with out any errors $url="http://yahoo.com"; $file1 = fopen($url, "r"); $content = file_get_contents($url); $t_beg = explode('<title>',$content); $t_end = explode('</title>',$t_beg[1]); echo $t_end[0]; And here is the same script using a look to check multiple urls and getting errors for ($j=1;$j<=$i;$j++) { if ($x[$j]!=''){ $t_u = "http:".$x[$j]; $file2 = fopen($t_u, "r"); $content2 = file_get_contents($t_u); $t_beg = explode('<title>',$content); $t_end = explode('</title>',$t_beg[1]); echo $t_end[0]; } } The error is Warning: fopen() [function.fopen]: php_network_getaddresses: getaddrinfo failed: No such host is known. in g:/ What exactly is wrong here?

    Read the article

  • opening and viewing a file in php

    - by Christian Burgos
    how do i open/view for editing an uploaded file in php? i have tried this but it doesn't open the file. $my_file = 'file.txt'; $handle = fopen($my_file, 'r'); $data = fread($handle,filesize($my_file)); i've also tried this but it wont work. $my_file = 'file.txt'; $handle = fopen($my_file, 'w') or die('Cannot open file: '.$my_file); $data = 'This is the data'; fwrite($handle, $data); what i have in mind is like when you want to view an uploaded resume,documents or any other ms office files like .docx,.xls,.pptx and be able to edit them, save and close the said file. edit: latest tried code... <?php // Connects to your Database include "configdb.php"; //Retrieves data from MySQL $data = mysql_query("SELECT * FROM employees") or die(mysql_error()); //Puts it into an array while($info = mysql_fetch_array( $data )) { //Outputs the image and other data //Echo "<img src=localhost/uploadfile/images".$info['photo'] ."> <br>"; Echo "<b>Name:</b> ".$info['name'] . "<br> "; Echo "<b>Email:</b> ".$info['email'] . " <br>"; Echo "<b>Phone:</b> ".$info['phone'] . " <hr>"; //$file=fopen("uploadfile/images/".$info['photo'],"r+"); $file=fopen("Applications/XAMPP/xamppfiles/htdocs/uploadfile/images/file.odt","r") or exit("unable to open file");; } ?> i am getting the error: Warning: fopen(Applications/XAMPP/xamppfiles/htdocs/uploadfile/images/file.odt): failed to open stream: No such file or directory in /Applications/XAMPP/xamppfiles/htdocs/uploadfile/view.php on line 17 unable to open file the file is in that folder, i don't know it wont find it.

    Read the article

  • advanced Visual Studio kung-fu test -- Calling functions from the Immediate Window during debugging

    - by kizzx2
    I see some related questions have been asked, but they're either too advanced for me to grasp or lacking a step-by-step guide from start to finish (most of them end up being insider talk of their own experiment results). OK here it is, given this simple program: #include <stdio.h> #include <string.h> int main() { FILE * f; char buffer[100]; memset(buffer, 0, 100); fun(); f = fopen("main.cpp", "r"); fread(buffer, 1, 99, f); printf(buffer); fclose(f); return 0; } What it does is basically print itself (assume file name is main.cpp). Question How can I have it print another file, say foobar.txt without modifying the source code? It has something to do with running it through VS's, stepping through the functions and hijacking the FILE pointer right before fread() is called. No need to worry about leaking resources by calling fclose(). I tried the simple f = fopen("foobar.txt", "r") which gave CXX0017: Error: symbol "fopen" not found Any ideas? Edit I found out the solution accidentally on Debugging Mozilla on Windows FAQ. The correct command to put into the Immediate Window is f = {,,MSVCR100D}fopen("foo.txt", "r") However, it doesn't really answer this question: I still don't understand what is going on here. How to systematically find out the {,,MSVCR100D} part for any given method? I know the MSVCR version changes from system to system. How can I find that out? Could anyone explain the curly brace syntax, especially, what are those two commas doing there? Are there more hidden gems using this syntax?

    Read the article

  • Using a php://memory wrapper causes errors...

    - by HorusKol
    I'm trying to extend the PHP mailer class from Worx by adding a method which allows me to add attachments using string data rather than path to the file. I came up with something like this: public function addAttachmentString($string, $name='', $encoding = 'base64', $type = 'application/octet-stream') { $path = 'php://memory/' . md5(microtime()); $file = fopen($path, 'w'); fwrite($file, $string); fclose($file); $this->AddAttachment($path, $name, $encoding, $type); } However, all I get is a PHP warning: PHP Warning: fopen() [<a href='function.fopen'>function.fopen</a>]: Invalid php:// URL specified There aren't any decent examples with the original documentation, but I've found a couple around the internet (including one here on SO), and my usage appears correct according to them. Has anyone had any success with using this? My alternative is to create a temporary file and clean up - but that will mean having to write to disc, and this function will be used as part of a large batch process and I want to avoid slow disc operations (old server) where possible. This is only a short file but has different information for each person the script emails.

    Read the article

  • how to fix my error saying expected expression before 'else'

    - by user292489
    this program intended to read a .txt, a set of numbers, file and wwrite to another two .txt files called even amd odd as follows: #include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) { int i=0,even,odd; int number[i]; // check to make sure that all the file names are entered if (argc != 3) { printf("Usage: executable in_file output_file\n"); exit(0); } FILE *dog = fopen(argv[1], "r"); FILE *feven= fopen(argv[2], "w"); FILE *fodd= fopen (argv[3], "w"); // check whether the file has been opened successfully if (dog == NULL) { printf("File %s cannot open!\n", argv[1]); exit(0); } //odd = fopen(argv[2], "w"); { if (i%2!=1) i++;} fprintf(feven, "%d", even); fscanf(dog, "%d", &number[i]); else { i%2==1; i++;} fprintf(fodd, "%d", odd); fscanf(dog, "%d", &number[i]); fclose(feven); fclose(fodd);

    Read the article

  • Permission denied install Joomla CiviCRM

    - by Tim
    Dear All, I am trying to install CiviCRM on a Joomla 1.5.17 web server running Ubuntu 9.10. Uploading the package to the tmp directory in /var/www/[site name]/tmp and installing creates this error: Warning: fopen(/var/www/trbcp/administrator/components/com_civicrm/civicrm/templates/CRM/common/civicrm.settings.php.tpl) [function.fopen]: failed to open stream: Permission denied in /var/www/trbcp/libraries/joomla/filesystem/file.php on line 240 Warning: fopen(/var/www/trbcp/administrator/components/com_civicrm/civicrm/templates/CRM/common/civicrm.settings.php.tpl) [function.fopen]: failed to open stream: Permission denied in /var/www/trbcp/libraries/joomla/filesystem/file.php on line 240 Warning: include_once(/var/www/trbcp/administrator/components/com_civicrm/civicrm.settings.php) [function.include-once]: failed to open stream: Permission denied in /var/www/trbcp/administrator/components/com_civicrm/configure.php on line 115 Warning: include_once() [function.include]: Failed opening '/var/www/trbcp/administrator/components/com_civicrm/civicrm.settings.php' for inclusion (include_path='.') in /var/www/trbcp/administrator/components/com_civicrm/configure.php on line 115 Warning: require_once(DB.php) [function.require-once]: failed to open stream: No such file or directory in /var/www/trbcp/administrator/components/com_civicrm/configure.php on line 140 Fatal error: require_once() [function.require]: Failed opening required 'DB.php' (include_path='.') in /var/www/trbcp/administrator/components/com_civicrm/configure.php on line 140 Initially I got a permissions denied error and thought that Joomla did not have permissions to all its directories but looking at Help-System information all the necessary directories are writable. I then decided to chmod 777 all the directories and try again but it still fails. Looking at the directories afterwards it seems that the new directories being created are not being created 777. By changing them I can get at least one step further before the error appears again. My question is does anyone know how to get round this? I am thinking that the new directories being created will require sudo privileges to have mv and create actions carried out, hence the permission denied errors. Can this be configured in Joomla? Or is there a way to specify that new directories created in /var/www/[site name] take 777 by default? any help greatly appreciated! EDIT: P.S. if anyone could give me a clue as to how the insert code feature works as well that would be great! Might make this post a bit more readable! EDIT2: Well I have had a bash at changing the permissions and ownership. sudo chown -R www-data:www-data /var/www/trbcp I then tried changing the whole /var directory (insecure I know but this is a test and dev server for me to find my feet on) to 777 and still getting permission errors. It seems to be error opening stream? Not a php guy so not sure what that is but could it be that permissions to run php script need to change? any thoughts greatly appreciated.

    Read the article

  • Chrome Equivalent of %s address bar trick in Firefox

    - by notbrain
    I was curious if there was an equivalent technique in Chrome to do address bar param string replacement like you can do in Firefox. If you create a bookmark and put a %s in the bookmark URL/address part, and set a keyword for the bookmark, you can do things like URL: http://php.net/%s Keyword: php Type in browser: php fopen End up at: http://php.net/fopen Is this making its way into Chrome or is there a way to do it?

    Read the article

  • Chrome Equivalent of %s address bar trick in Firefox

    - by notbrain
    I was curious if there was an equivalent technique in Chrome to do address bar param string replacement like you can do in Firefox. If you create a bookmark and put a %s in the bookmark URL/address part, and set a keyword for the bookmark, you can do things like URL: http://php.net/%s Keyword: php Type in browser: php fopen End up at: http://php.net/fopen Is this making its way into Chrome or is there a way to do it?

    Read the article

  • How to use C to write to flash drive bootsector despite error 'Failed to open file to write.:Permiss

    - by updateraj
    My goal is to manipulate the boot-sector in my flashdrive (volume E:) I am using XP. I am able to read the boot-sector FILE *fp_read = fopen("\\\\.\\E:", "rb"); /* Able to proceed to read boot sector */ however i am not able to open the file to write using fopen in 'wb' mode. FILE *fp_read = fopen("\\\\.\\E:", "wb"); /* Unable to proceed due to Failed to open file to write.:Permission Denied */ The flash-drive is not in use at the moment of execution. Hex-editors are able to manipulated boot sector etc, i believe it possible to do so in c. Any suggestion or insight to overcome the access problem so as to be able to write?

    Read the article

  • How to Get a Webpage's contents without CURL ?

    - by Arsheep
    I need to get webpage's content ,I cant use Curl as it is not enabled.I tried the below code But it is not working. $opts = array( 'http'=>array( 'method'=>"GET", 'header'=>"Accept-language: en\r\n" . "Cookie: foo=bar\r\n" ) ); $context = stream_context_create($opts); $fp = fopen($_GET['url'], 'r', false, $context); if($fp) fpassthru($fp); fclose($fp); exit; The code produce an error Warning: fopen(http://www.google.com/search?&q=site:www.myspace.com+-intitle:MySpaceTV+%22Todd Terje%22) [function.fopen]: failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >