PHP - Amending To A File On A Windows Machine With Xampp
I am working on a task where the user of the webpage can amend to a text file, but when I try it on Windows, I get messages such as
Warning: fopen(C: mpp\htdocs cm\denman2.txt) [function.fopen]: failed to open stream: Invalid argument in C:\xampp\htdocs\amendfile.php on line 8 Warning: fputs() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\amendfile.php on line 10 Warning: fclose() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\amendfile.php on line 11 And nothing is appended. I don't know what the problem is, considering the only aspect I really changed was the file path since I was using Ubuntu to try to accomplish this. Here is the coding of my Amend File Script: Code: [Select] <html> <head><title>Amend File</title></head> <?php if($_POST['append'] !=null) { $filename="C:\xampp\htdocs\rcm\denman2.txt"; $file=fopen($filename, "a"); $msg="Updated Information: " .$_POST['append']. "<br>"; fputs ($file, $msg); fclose($file); } ?> <body> <h1>Do you want to append to a document?</h1> Enter Updated Information: <form action="amendfile.php" method="post"> <input type="text" size="40" name="append"><br><br> <input type="submit" value="Add name to report"> </form> <form action="viewfile.php" method="post"> <input type="submit" value="View Web Blog"> </form> <a href="viewfile.php">View Web Blog</a></body></html> Any help is appreciated! Similar Tutorialshelo dear linux experts my girlfriend runs a windows 8.0 she claims that sometimes the wlan access gets lost. Despite the fact that the notebook (lenovo g 780) just is very close to the wlan router. question: how to make sure that windows 8 does not corrupt wlan access? Hi,
I am a newbie at php and I recently tried making a small php configuration that runs on the localhost. execution.php <?php echo "first script has been executed"; exec('execution2.php'); ?> execution2.php <?php echo "Second script has been executed"; ?> The script is designed to call another php file whereas on the web page I would expect seeing, "first script has been executed" and "Second script has been executed". I am honestly not sure how the execution method is supposed to work however I am not planning on using "include" or "require" since they do not meet my criteria for another project. I am using xampp localhost server on a windows 10 computer. I tried entering "localhost:8080/dir/execution.php" however it did not work.
Any help would be appreciated, thanks! This topic has been moved to Other Web Server Software. http://www.phpfreaks.com/forums/index.php?topic=347581.0 I have a PHP web system that store in a windows server. In the system, there is a function for user to upload files to another server (Shared server in Unix). When i try to upload a file, it gives warning: Warning: move_uploaded_file(\\unixserver/sharedfolder/upload/test.txt) [function.move-uploaded-file]: failed to open stream: Permission denied in C:\wamp\www\upload\index.php on line 40 For your information, my username has been assigned in xxx's group that has access to read and write on that folder. Besides, i'm able to open,create and delete files on that folder's server manually (samba). The safe mode setting is off. Does anybody has any idea why this thing happen? Hi everyone, I'm trying to get the name of the machine in use. If I use this feature locally, it works.
function visitor_machine_name(){
return $machine_name;
But as soon as I try it on an online server I get the DNS name back, like this:
What can I do? Does any one know where I can find a PHP slots machine script? I am trying to make a gumball machine on my site which gives you a gumball every time you click the button. This is the code I am using to generate a gumball: Code: [Select] <?php $balltype = rand(1,50); if ($balltype = 1) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30978','1','1')"); $gummy = "You won a <b>Blue Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_blue.gif" width="80" height="80" border="0">'; } elseif ($balltype = 2) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30978','1','1')"); $gummy = "You won a <b>Blue Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_blue.gif" width="80" height="80" border="0">'; } elseif ($balltype = 3) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30978','1','1')"); $gummy = "You won a <b>Blue Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_blue.gif" width="80" height="80" border="0">'; } elseif ($balltype = 4) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30978','1','1')"); $gummy = "You won a <b>Blue Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_blue.gif" width="80" height="80" border="0">'; } elseif ($balltype = 5) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30983','1','1')"); $gummy = "You won a <b>Green Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_green.gif" width="80" height="80" border="0">'; } elseif ($balltype = 6) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30983','1','1')"); $gummy = "You won a <b>Green Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_green.gif" width="80" height="80" border="0">'; } elseif ($balltype = 7) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30983','1','1')"); $gummy = "You won a <b>Green Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_green.gif" width="80" height="80" border="0">'; } elseif ($balltype = 8) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30983','1','1')"); $gummy = "You won a <b>Green Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_green.gif" width="80" height="80" border="0">'; } elseif ($balltype = 9) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30985','1','1')"); $gummy = "You won an <b>Orange Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_orange.gif" width="80" height="80" border="0">'; } elseif ($balltype = 10) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30985','1','1')"); $gummy = "You won an <b>Orange Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_orange.gif" width="80" height="80" border="0">'; } elseif ($balltype = 11) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30985','1','1')"); $gummy = "You won an <b>Orange Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_orange.gif" width="80" height="80" border="0">'; } elseif ($balltype = 12) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30985','1','1')"); $gummy = "You won an <b>Orange Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_orange.gif" width="80" height="80" border="0">'; } elseif ($balltype = 13) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30986','1','1')"); $gummy = "You won a <b>Purple Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_purple.gif" width="80" height="80" border="0">'; } elseif ($balltype = 14) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30986','1','1')"); $gummy = "You won a <b>Purple Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_purple.gif" width="80" height="80" border="0">'; } elseif ($balltype = 15) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30986','1','1')"); $gummy = "You won a <b>Purple Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_purple.gif" width="80" height="80" border="0">'; } elseif ($balltype = 16) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30986','1','1')"); $gummy = "You won a <b>Purple Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_purple.gif" width="80" height="80" border="0">'; } elseif ($balltype = 17) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30990','1','1')"); $gummy = "You won a <b>Yellow Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_yellow.gif" width="80" height="80" border="0">'; } elseif ($balltype = 18) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30990','1','1')"); $gummy = "You won a <b>Yellow Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_yellow.gif" width="80" height="80" border="0">'; } elseif ($balltype = 19) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30990','1','1')"); $gummy = "You won a <b>Yellow Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_yellow.gif" width="80" height="80" border="0">'; } elseif ($balltype = 20) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30990','1','1')"); $gummy = "You won a <b>Yellow Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_yellow.gif" width="80" height="80" border="0">'; } elseif ($balltype = 21) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30981','1','1')"); $gummy = "You won a <b>Cola Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_cola.gif" width="80" height="80" border="0">'; } elseif ($balltype = 22) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30981','1','1')"); $gummy = "You won a <b>Cola Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_cola.gif" width="80" height="80" border="0">'; } elseif ($balltype = 23) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30981','1','1')"); $gummy = "You won a <b>Cola Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_cola.gif" width="80" height="80" border="0">'; } elseif ($balltype = 24) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30979','1','1')"); $gummy = "You won a <b>Chocolate Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_bronze.gif" width="80" height="80" border="0">'; } elseif ($balltype = 25) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30979','1','1')"); $gummy = "You won a <b>Chocolate Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_bronze.gif" width="80" height="80" border="0">'; } elseif ($balltype = 26) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30979','1','1')"); $gummy = "You won a <b>Chocolate Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_bronze.gif" width="80" height="80" border="0">'; } elseif ($balltype = 27) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30984','1','1')"); $gummy = "You won an <b>Ice Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_ice.gif" width="80" height="80" border="0">'; } elseif ($balltype = 28) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30984','1','1')"); $gummy = "You won an <b>Ice Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_ice.gif" width="80" height="80" border="0">'; } elseif ($balltype = 29) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30984','1','1')"); $gummy = "You won an <b>Ice Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_ice.gif" width="80" height="80" border="0">'; } elseif ($balltype = 30) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30987','1','1')"); $gummy = "You won a <b>Rock Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_rock.gif" width="80" height="80" border="0">'; } elseif ($balltype = 31) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30987','1','1')"); $gummy = "You won a <b>Rock Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_rock.gif" width="80" height="80" border="0">'; } elseif ($balltype = 32) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30987','1','1')"); $gummy = "You won a <b>Rock Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_rock.gif" width="80" height="80" border="0">'; } elseif ($balltype = 33) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30988','1','1')"); $gummy = "You won a <b>Strawberry Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_strawberry.gif" width="80" height="80" border="0">'; } elseif ($balltype = 34) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30988','1','1')"); $gummy = "You won a <b>Strawberry Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_strawberry.gif" width="80" height="80" border="0">'; } elseif ($balltype = 35) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30988','1','1')"); $gummy = "You won a <b>Strawberry Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_strawberry.gif" width="80" height="80" border="0">'; } elseif ($balltype = 36) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30980','1','1')"); $gummy = "You won a <b>Dark Chocolate Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_chocolate2.gif" width="80" height="80" border="0">'; } elseif ($balltype = 37) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30980','1','1')"); $gummy = "You won a <b>Dark Chocolate Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_chocolate2.gif" width="80" height="80" border="0">'; } elseif ($balltype = 38) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30977','1','1')"); $gummy = "You won a <b>Black Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_black.gif" width="80" height="80" border="0">'; } elseif ($balltype = 39) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30977','1','1')"); $gummy = "You won a <b>Black Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_black.gif" width="80" height="80" border="0">'; } elseif ($balltype = 40) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30982','1','1')"); $gummy = "You won a <b>Digital Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_digital.gif" width="80" height="80" border="0">'; } elseif ($balltype = 41) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30982','1','1')"); $gummy = "You won a <b>Digital Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_digital.gif" width="80" height="80" border="0">'; } elseif ($balltype = 42) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30989','1','1')"); $gummy = "You won a <b>Silver Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_silver.gif" width="80" height="80" border="0">'; } elseif ($balltype = 43) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30991','1','1')"); $gummy = "You won a <b>Burnt Gumball</b>. Ur... Well done..."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gumball_burnt.gif" width="80" height="80" border="0">'; } elseif ($balltype = 44) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30991','1','1')"); $gummy = "You won a <b>Burnt Gumball</b>. Ur... Well done..."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gumball_burnt.gif" width="80" height="80" border="0">'; } elseif ($balltype = 45) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30991','1','1')"); $gummy = "You won a <b>Burnt Gumball</b>. Ur... Well done..."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gumball_burnt.gif" width="80" height="80" border="0">'; } elseif ($balltype = 46) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30991','1','1')"); $gummy = "You won a <b>Burnt Gumball</b>. Ur... Well done..."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gumball_burnt.gif" width="80" height="80" border="0">'; } elseif ($balltype = 47) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30991','1','1')"); $gummy = "You won a <b>Burnt Gumball</b>. Ur... Well done..."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gumball_burnt.gif" width="80" height="80" border="0">'; } elseif ($balltype = 48) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30991','1','1')"); $gummy = "You won a <b>Burnt Gumball</b>. Ur... Well done..."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gumball_burnt.gif" width="80" height="80" border="0">'; } elseif ($balltype = 49) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30991','1','1')"); $gummy = "You won a <b>Burnt Gumball</b>. Ur... Well done..."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gumball_burnt.gif" width="80" height="80" border="0">'; } elseif ($balltype = 50) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30991','1','1')"); $gummy = "You won a <b>Burnt Gumball</b>. Ur... Well done..."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gumball_burnt.gif" width="80" height="80" border="0">'; } else { $gummy = "Nooooooooo!!!!! The gumball machine is broken!!! It still took your money though..."; } ?> Every time I try it, it gives me a burnt gumball EDIT: All that CODE hurts.... use some CODE formatting for godsakes. Could Someone Help Me Make A Gumball Machine My Site Is Toxicpets.co.cc And the page is gumballs.php but i need it to give gumballs Is there a way to get my visitors PC or Device Name? I am not looking for server name or ip. I need to get my current visitors computer name. Example: MAIN, HOME, OFFICE, TOM32154}}{|\] like when first naming a PC with a new windows install. hello and good day dear php-freaks which is the passwd for the mysql db run opensuse - therein i have installed a myql serfver and an apache now i want to port over a cms-system from a server to the localhost. question: the passwd of the configuriatin of the cms has got the following db connecgtion host : localhost db-name db-passwd question: does the db passwd need to match the passwd of the local mysql server!? is this true love to hear from you hello dear php-experts i run opensuse 13-2 and i am very very happy the time does not get displayed correct. it falls back to UTC all day. What can i do. i have had look at the documents here https://en.opensuse....uring_the_clock https://tr.opensuse....T_Date_and_Time how to set up correct to the local time - note i live in GERMANY near francfurt In php.ini on my local development server, error_reporting is set to Quote error_reporting = E_ALL | E_STRICT And I get no errors. However, on the remote web server I found a bunch of warnings in the error log. I fixed most of them, but this error/warning should have popped up on my development console: Quote [02-Dec-2011 17:47:22] PHP Warning: array_keys() [<a href='function.array-keys'>function.array-keys</a>]: The first argument should be an array in /home/bpslk/public_html/cart-checkout.php on line 177 [02-Dec-2011 17:47:22] PHP Warning: Invalid argument supplied for foreach() in /home/bpslk/public_html/cart-checkout.php on line 177 I can fix the code to eliminate the warning, no prob. But why am I NOT seeing this error on my development machine? --Thanks --HarryG Hello, I am wondering if there is any way with PHP to get a list of the processes running on the client that hits the PHP server script. If that is not possible, is there a way I have have my PHP script do an 'exec' call on something that will do it? Thanks Mike Is it possible to read from a file that is located on the user's local machine and not on the server? I have a CSV file that is about 70MB that I have to parse through and insert the data into a database. I have no problem doing this if I hard code the path to the file. Is there a way to get the path of the file that the user wants to be parsed into the database? I don't think uploading the file would be a good idea because, like I said, it is 70MB and is nearly 2 million lines. Simply parsing the file takes long enough without throwing in upload time.. can abybody tell where to write php code & sql statements in Xampp I am new to php and starting to write my first programs. I have a laptop (my local pc) and I am wondering if there is some kind of php-interpreter available so I can test them out on my local machine without having to upload them to my website? Is there anyway I can avoid having to install a web-sever on my machine? Is there an all-in-one php interpreter? (someone suggested something called Xampp, - is this the best?) thanks,, Hello, I need help with php, I don't understand what that could be , otherwise I run the page via a wampserver, I would be grateful for any kind of help. Hi, i had today problem with my script. Everything worked well on my localhost(xampp server) and when i uploaded on dedi machine functions with MySQL database stoped working. Problem was with mysql_real_escape_string and i forgot that i must first open connection and then mysql_real_escape_string... But strange thing is that on xampp server i dont need to open connection for mysql_real_escape_string, and everything worked well... is there any solutio to php scripts on xampp worke same as php script on linux apache server? This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=348673.0 |