Jump to content

eelmitchell

Members
  • Posts

    17
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

eelmitchell's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I use Windows Explorer to view C:\Inetpub\wwwroot. Under the Security tab, I see a list of user names like Administrators, CREATOR OWNER, DELL340 Admins, Authors, Browsers, Edward, Everyone, SYSTEM, Users, VS Developers, but no IUSR_xxxx. So I go to Computer Management and select Users. Under this I find IUSR_DEL340 for Internet Guest Account which seems hopeful. Back to wwwroot Properties, I add IUSR_DELL340 and on "Check Names" this is changed into DELL340\IUSR_DELL340. I allow Read&Execute, List, Read, Write permissions. Back to my original problem, and it's gone away. Thanks for the feedback. Problem solved. I really appreciate the advice.
  2. I moved the files to my Unix web server and there was no problem with the upload. I could touch a file in the root directory. Seems to be something special about IIS on my Windows machine.
  3. I am trying to upload a file and move_uploaded_file() was failing. It didn't seem to be able to write the file into the web root or a subfolder. My .html form to browse for the file is as follows: <html> <body> <form action="testupload.php" method="post" enctype="multipart/form-data" > <input type="hidden" name="MAX_FILE_SIZE" value="1000000" /> <label for="userfile">Upload File:</label> <input type="file" name="userfile" id="userfile" /> <input type="submit" value="Send File" /> </form> </body> </html> In my receiving file (testupload.php) I tried various combinations of forward slashes, back slashes and even $_SERVER['DOCUMENT_ROOT']. My test file to handle the file move from the temp file is as follows (the $newFile override was just to see if I could write anywhere): <html> <body> <h1>Uploading file...</h1> <?php if($_FILES['userfile']['type'] != 'text/plain') { echo("Problem: File is not plain text"); exit; } if(is_uploaded_file($_FILES['userfile']['tmp_name'])) { // move the file to a subdirectory of this script $newFile = $_SERVER['DOCUMENT_ROOT']."/uploads/foo.txt"; $newFile = 'foo.txt'; echo("newFile: $newFile<br />"); echo("Type: ".$_FILES['userfile']['type']."<br />"); echo("File: ".$_FILES['userfile']['tmp_name']."<br />"); echo("Error: ".$_FILES['userfile']['error']."<br />"); echo("DocRoot: ".$_SERVER['DOCUMENT_ROOT']."<br />"); $tmp_name = $_FILES['userfile']['tmp_name']; echo("tmp_name: ".$_FILES['userfile']['tmp_name']."<br />"); if(!move_uploaded_file($_FILES['userfile']['tmp_name'], $newFile)) { echo("Problem: Could not move file to $newFile<br />"); echo("Error Code: ".$_FILES['userfile']['error']."<br />"); exit; } } ?> </body> </html> The output when I ran this was the following: newFile: foo.txt Type: text/plain File: C:\WINDOWS\Temp\phpC96.tmp Error: 0 DocRoot: c:\inetpub\wwwroot tmp_name: C:\WINDOWS\Temp\phpC96.tmp Warning: move_uploaded_file(foo.txt) [function.move-uploaded-file]: failed to open stream: Permission denied in C:\Inetpub\wwwroot\testupload.php on line 27 Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\WINDOWS\Temp\phpC96.tmp' to 'foo.txt' in C:\Inetpub\wwwroot\testupload.php on line 27 Problem: Could not move file to foo.txt Error Code: 0 Since it seemed that the problem could be a permission problem, I made sure that I can write on the C:\Inetpub\wwwroot\ by changing the permission for my account to "all" and testing this by doing "touch" from a DOS window. Then I added the "touch" to the .php code and found from the .php program I can't create the same file. I added the following: // try and create a file in the root directory if(!touch($newFile)) { echo("Can't touch $newFile file"); exit; } if(!unlink($newFile)) { echo("Can't unlink $newFile file"); exit; } This produced the following: newFile: foo.txt Warning: touch() [function.touch]: Unable to create file foo.txt because Permission denied in C:\Inetpub\wwwroot\testupload.php on line 13 Can't touch foo.txt file So my question is, what user permissions am I running under when the testupload.php program runs? What should I do in order to create the new file from the upload to the website?
  4. When a topic has run it's course, is there a button to add the [solved] tag to the header. I presume I could edit the header myself but I worried about breaking the thread if the header was changed.
  5. I see now that msqli is a big class. When I tried to put together a simple test, there was a warning message: Call-time pass by reference has been deprecated. This is PHP 5.3. I got rid of the message by removing the mysqli_close, assuming that connection will be closed for me automatically.
  6. I have a function that does a SELECT statement but when it returns and I attempt to close the db resource I get the following message: Warning: mysqli_close() [function.mysqli-close]: Couldn't fetch mysqli in /homepages/13/d280102247/htdocs/GiftShop/salesform.php on line 45. I open the connection with mysqli_connect(...) The connect function assigns a value to $dbc. $dbc = mysqli_connect($server, $user, $password) or die('Error connecting to MySQL server.'); and then does a query to use my database. After that I invoke the function: // if the form asked to list the contents if(isset($_POST['list']) && ($_POST['list'] == 'List')) { ListSales(&$dbc); mysqli_close($dbc); Inside the function is a "SELECT * FROM sales" executed via an mysqli_query() statement. I tried passing the database resource variable $dbc by value and as above which I assume is by reference. Both syntax methods produce the same error message. The line 45 is the _close(...) statement. I don't know what the phrase "Couldn't fetch mysqli in ..." means in the error message. If I place the mysqli_close($dbc) within the function then I get no error message. I can only assume that the $dbc variable is carrying more info about the database than is visible to me and that any changes don't get transmitted outside the ListSales(...) function which would be reasonable if the $dbc were passed by value. Is there something I can do to stop the error message occurring?
  7. I think I fixed the problem. I moved libmysql.dll to C:\WINDOWS then the key thing appeared to be that I restarted IIS. The magic that was going on wasn't apparent but I thought I'd make an experiment. Move the libmysql.dll back to C:\PHP5 and the mysqli_connect(...) function is still found. A "which" in a command window confirms that libmysql.dll is back in C:\PHP5. Now I restart IIS. After the restart, mysql_connect(...) can't be found. So I move libmsql.dll back to C:\WINDOWS, restart IIS and my script works again. I can only assume that IIS reads php.ini when it's restarted and if libmysql.dll is not in the WINDOWS folder, doesn't look any further for it when the extension=libmysql.dll line is processed. When the restart is over, the actual load of the libmysql.dll must come from the PATH environment. I'm not happy with IIS.
  8. Thanks for correcting me. $_SERVER['PHP_SELF'] turns into the correct file name for the page (action="/salesform/test.php">). I also realised I shouldn't be getting the default value for the input text field from $_POST. If I initialise $quantity to an empty string then the value is correct the first time in the form and will be overridden when the form returns with some data. As a newcomer to PHP, I appreciate the help. How do I put [sOLVED] on the Subject? I read somewhere there was a button or do I just edit the subject line itself?
  9. I'm trying to get a form page to call back on itself by action=$SERVER['PHP_SELF"] but I don't believe the _SESSION variable is defined. My test code page is: <html> <body> <h1>Test</h1> <?php if($_POST) { echo("Return after form data entry<br />"); $quantity = $_POST['quantity']; } else { echo("First time page opened.<br />"); ?> <form method="post" action="<?php echo($_SESSION['PHP_SELF'])?>"> Quantity:<input type="text" size="10" name="quantity" value="<?php echo($_POST["quantity"])?>" /> <input type="submit" name="Submit" value="Submit" /> </form> <?php } ?> </body></html> and the output is: <html> <body> <h1>Test</h1> First time page opened.<br /> <form method="post" action="<br /> <b>Notice</b>: Undefined variable: _SESSION in <b>C:\Inetpub\wwwroot\SalesForm\test.php</b> on line <b>11</b><br /> "> Quantity:<input type="text" size="10" name="quantity" value="<br /> <b>Notice</b>: Undefined index: quantity in <b>C:\Inetpub\wwwroot\SalesForm\test.php</b> on line <b>13</b><br /> " /> <input type="submit" name="Submit" value="Submit" /> </form> </body></html> The first time I would expect $_POST to be undefined and sure enough if($_POST) ... is false so we get to the <form ...> tag. But the $_SESSION is unknown so the "action" field is filled with an error message and won't return to the page. It should be http://localhost/salesform/test.php. In addition the $_POST['quantity'] gives a message as an "Undefined index". I know it's undefined but I would expect an empty string. The second time through the value will be known and that makes the data sticky. How can I get the page URL so the action can return and how can I produce the empty string for filling the form values the first time through? Environment: Windows XP Pro SP3 PHP 5.1 from binaries to C:\PHP5 php.ini is php.ini-recommended except for mysql changes.
  10. Another piece of info. I changed the display_errors in the php.ini file to "On", restarted IIS and now I get an error message: <html> <body> <h3>Hello World</h3> <br />Test4: E_ALL=6143<br /> <b>Fatal error</b>: Call to undefined function mysql_connect() in <b>C:\Inetpub\wwwroot\SalesForm\test.php</b> on line <b>7</b><br /> At least I'm seeing something.
  11. It seems I don't really know where the error message (if any) goes. I tried the: echo '<br />Test3: E_ALL='.E_ALL; if (!$dbc = mysql_connect('127.0.0.1', "Edward")) { die("Could not connect: ".mysql_error()); } but I don't see any more text in the html output file. I changed an "echo" so that I could tell that the page really was being re-executed, not being regenerated from a cache. If I set the "display_errors" to on, I don't understand where they will go. It looks like I use use "Off", "stderr", "On" or "stdout". Surely the line above in the test.php file for "error_reporting(E_ALL)" will turn the display_errror flag on. When I look in the php.ini file, "error_reporting" is set to E_ALL so I shouldn't have to call the error_reporting(E_ALL) function. In the php.ini-dist file, E_ALL is modified by ~E_NOTICE but the display_errors is set to "on". I'm using the php.ini-recommended. Is there a function that I can call from the test.php file to change the "display_errors" flag? Still doesn't tell me where any errors will go. Is the html code generated equivalent to "stdout"?
  12. Sorry. That was dumb not to get the function correct. I would have expected a message however! When I change to the correct function (and take out an "echo"): <html> <body> <h3>Hello World</h3> <?php error_reporting(E_ALL); echo '<br />E_ALL='.E_ALL; $dbc = mysql_connect('127.0.0.1', "Edward"); echo("<br />Continue after connect"); ?> </body> </html> I get the html code: <html> <body> <h3>Hello World</h3> <br />E_ALL=6143 At least I can confirm that the E_ALL is seen and has a value. But no error messages.
  13. I added error_reporting(...) line to the test.php script so that it looks like: <html> <body> <h3>Hello World</h3> <?php error_reporting(E_ALL); echo '<br />Post_max_size = ' . ini_get('post_max_size'); $dbc = msql_connect('127.0.0.1', "Edward"); echo("<br />Continue after connect"); ?> </body> </html> When I run this I just see the first "echo" - no errors reported. It dies inside the msql_continue(...). Is this where I put the error_reporting(E_ALL) line?
  14. When I invoke "phpinfo();" the "Loaded Configuration File" is listed as "(none)" and the Configuration File (php.ini) Path is "C:\WINDOWS". There is only one php.ini file in the system and that's in C:\PHP5. So I moved the php.ini file from C:\PHP5 to C:\WINDOWS and ran the phpinfo(); again. The loaded config file was still listed as (none). Next I had a thought that "restart the server" meant restart IIS so I did this. Now phpinfo(); lists the config file path as C:\WINDOWS and the loaded config file as C:\WINDOWS\php.ini. But running my test.php file doesn't work and in fact I've lost the error message that I was getting before. The produced html code is: <html> <body> <h3>Hello World</h3> <br />display_errors = <br />register_globals = <br />post_max_size = 8M<br />mysql.default_user = so nothing has happened (no error message) once php started into: $dbc = msql_connect('127.0.0.1', "Edward"); To test that this is real, I moved php.ini back to the C:\PHP5 folder and restarted IIS. The phpinfo() now lists the config file as "(none)". But running my test.php file gives me the error message I had seen previously at the end: ... Fatal error: Call to undefined function msql_connect() in C:\Inetpub\wwwroot\SalesForm\test.php on line 9 So when it doesn't read php.ini I get a message, when it does read the php.ini it must go into mysql_connect(...) and never return! I'm using IIS since I've used it before with Visual Studio and a C# app together with MS SQLServer. My preference is to stay with IIS so that I wouldn't have to install any extra things on my machine.
  15. This topic seemed to have been put to bed three years ago but I can't get past msql_connect(). My system Description: XP Professional, SP3 Firefox 3.0.7 (Same result with IE6.0) IIS 5.1 php 5.2.9-Win32.zip into C:\PHP5. MySQL mysql-essential-5.1.32-win32.msi I can run php and msql separately with no problem but can't connect them. I wrote a test file to try and exercise mysql (test.php) as follows: <html> <body> <h3>Hello World</h3> <?php echo '<br />display_errors = ' . ini_get('display_errors'); echo '<br />register_globals = ' . ini_get('register_globals'); echo '<br />post_max_size = ' . ini_get('post_max_size'); echo '<br />mysql.default_user = '. ini_get('mysql.default_user'); $dbc = msql_connect('127.0.0.1', "Edward"); echo("Foo after connect"); ?> </body> </html> I put the echo() functions in there to show that php was really working. Output when run in Firefox browser (http://localhost/SalesForm/test.php): Hello World display_errors = 1 register_globals = 0 post_max_size = 8M mysql.default_user = Fatal error: Call to undefined function msql_connect() in C:\Inetpub\wwwroot\SalesForm\test.php on line 9 I had only changed the php.ini file from php.ini-recommended for the extension_dir and allowed the extension=php_mysql.dll and then copied it to C:\WINDOWS. I used WinDiff to check the php.ini differences from php.ini-recommended as follows: extension=php_mysql.dll ; Directory in which the loadable extensions (modules) reside. extension_dir = "C:\PHP5\ext" ; **You CAN safely turn this off for IIS, in fact, you MUST.** cgi.force_redirect = 0 The following show where the various files are coming from: C:\>which php.ini C:\WINDOWS\php.ini C:\>which mysql C:\Program Files\mysql\MySQL Server 5.1\bin\mysql.exe C:\>which php C:\PHP5\php.exe C:\>which libmysql.dll C:\PHP5\libmysql.dll One thing I don't understand in the usual instructions for making changes to php.ini is that I have to do a "restart server." I've rebooted many times! I thought php started up every time the .php file was scanned. php was installed by copying binaries from php-5.2.9-Win32.zip into C:\PHP5. I can start it from the command line and I've attached the output from "php -i" as a text file. I can start msql from the command line C:\>mysql -u Edward Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 22 Server version: 5.1.32-community MySQL Community Server (GPL) Type 'help;' or '\h' for help. Type '\c' to clear the buffer. ... Can somebody recommend anything I can do to fix the problem? [attachment deleted by admin]
×
×
  • 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.