Jump to content

benphp

Members
  • Posts

    336
  • Joined

  • Last visited

Everything posted by benphp

  1. It's opening the HTML in a Word document. I'm guessing it must be a CSS solution.
  2. I'm generating a Microsoft Word doc with header("Content-type: application/vnd.ms-word"); header("Content-Disposition: attachment;Filename=myPrintInLandscape.doc"); but it opens in portrait orientation. Does anyone know of a way to force it into landscape?
  3. Oracle. According to http://php.net/manual/en/function.oci-parse.php, I could instead just set $stmt = null; but I still don't know why I'm getting that error.
  4. Howdy. Can someone tell me - does the oci_free_statement error out when there are no records? Otherwise, can you tell me why I'd get the "oci_free_statement(): 3 is not a valid" error with this? $connSelect = oci_connect($usr, $pwd, $db); $sqlSelect = "SELECT a.myfield FROM mytable "; $stmt=oci_parse($connSelect,$sqlSelect); oci_execute($stmt, OCI_DEFAULT); while (($row = oci_fetch_array($stmt, OCI_BOTH))) { $myfield = $row[0]; } $sqlSelect = null; $row = null; oci_free_statement($stmt); oci_close($connSelect); There are no errors in the SQL, and there are zero records returned. Can't I still free the statement if there are no records? or do I need to add an if statement to free it only when records > 0?
  5. I've been using a program that uses MS SQL Server for a back end. The interface is bad, so I wrote some PHP forms to hit the database directly, and now I don't use the program at all - just the database. At what point can I stop paying for the program? If I discontinue using the program, then can I still use the database? If not, then how do I get my data out without using their schema? If I can't use their schema, how different would a new database need to be for it to not be a reverse engineered schema? For example, there's an Employee table that has LastName FirstName Address, etc. How different can that be - or should it be?
  6. No - the only way I can kill it is to delete all cookies.
  7. I set a cookie on page1.php: setcookie("wusername",$_REQUEST['wusername']); I have another page logout.php for logging out that kills the cookie and sends me to the login page. if (isset($_REQUEST['btnLogOut'])) { setcookie ("wusername", "", time() - 3600); header("Location: login.php"); } However, when I go to the login page, login.php, I have this: if (isset($_COOKIE['wusername'])) { $wusername = "Logged in as: " . $_COOKIE['wusername']; } Which does indeed retain my cookie and prints it. Why is my cookie not dying?
  8. Even if you prepare a statement, you still have to fix your apostrophes in the preparation. The delineation issue is more of a PHP puzzle than a db one.
  9. Nice. I'm not using PDO -just spent the day converting to sqlsrv that has the ability to prepare an array using execute. I'll look into that. Thanks!
  10. I think I may have done it. I'm used to massaging strings to input into mysql, so I was probably overdoing it. When updating the DB, I first run the string through fnTick: function fnTick($string) { $string = str_replace("'", "''", $string); return $string; } This takes care of the single quotes (or apostrophes) for my SQL statement. The db removes the second single quote for me - thanks, db. UPDATE mytable SET desc = 'My test string here is "tester" test "quote" test''s', name = 'This is "test''s" ''test'' working "tester" test "quote" test''s Here''s another line "quote" ' WHERE ID = 737 Note that the values for the db fields are delineated by single quotes (desc='string in here'), so I only need to double up single quotes ' ', so actual double quotes, or quotation marks, are passed through without a problem - I don't need to worry about them going INTO the db, but I do need to fix them coming OUT of it. I first tried doubling up both single and double quotes as suggested, but mssql retains double double quotes ("") - it only filters out double single quotes (''). Once it's in the db with the correct double and single quotes, I have to be careful when pulling it out and displaying it in HTML. So, when I read from the db, I run all user strings through htmlspecialchars: function fnUnTick($string) { $string = htmlspecialchars($string, ENT_QUOTES, 'UTF-8'); return $string; } Sure would be easier if all dbs had some other way to delineate their SQL - something like <mssql>select from...</mssql>
  11. I'm using double apostrophes for apostrophes, but double quotes are still a problem with PHP/MS SQL. Is there any way to get actual double quotes in the db and not faking it with two single quotes? "This" not ''This''
  12. How do I display the actual errors in IIS 7.5? If I miss a semicolon, I get: "HTTP Error 500.0 - Internal Server Error" absolutely useless. In prior versions, I could see the line and get to the PHP error. How do I display PHP errors? I've added: set_ini('display_errors', '1'); but it doesn't help.
  13. But when I input exactly 98.8, it displays 98.8 in SQL Server Management Studio, but when I use PHP, it returns 98.800003. Why is it one value in one place and something else in another? It's not my database, or I'd change it.
  14. MS SQL Server - data type "real" I add a value of 95.4, and that's what displays in the SQL table, but when I fetch the value via PHP, I get 98.400002. Other values: 98.2 = 98.199997 98.3 = 98.300003 98.4 = 98.400002 98.5 = 98.5 98.6 = 98.599998 98.7 = 98.699997 98.8 = 98.800003 98.9 = 98.900002 WTF? I can use round to fix it, but would rather fix the problem than the symptom. Help? Thanks!
  15. NOTE: It only worked for me when I applied it to the entire web site (Default Web Site) level. It didn't work by adding Handler Mappings at the folder level. And make sure that your subdirectories are set to inherit from the Parent. In Handler Mappings, you'd need to click "Revert to Parent" if you have custom mappings.
  16. Make sure FastCgiModule is installed. You should have configured that during PHP install. If not, there are a lot of how-tos out there for that. [*]In IIS Manager [*]Navigate to the folder you want to add the rule to. [*]In the IIS section, double click Handler Mappings. [*]In Actions, click Add Module Mapping... [*]Request Path: *.htm [*]Module: FastCgiModule [*]Use quotes for the Executable: "C:\Program Files (x86)\PHP\php-cgi.exe" [*]Name: PhpInHtml Success! BTW, I removed the MIME type. All you need to do is the above.
  17. I tried changing the MIME type of .HTM to: Extension: .htm MIME-Type: application/x-httpd-php But the htm pages still don't recognize the PHP in the .htm files. I changed the .html MIME too, but still no go. Is there something in PHP.INI I need to switch on?
  18. After several hours of pulling hair out with PHP v5.3.8, I gave up and installed v5.2.17, which works with sqlsrv_connect. Version 5.3.8 always compiled "--without-mssql" and I couldn't get it to do otherwise. Here's my install notes for installing on Windows, IIS: Don't install v5.3.x. Use v5.2.17 instead. The latest PHP does not support the orginal php sql driver (php_mssql.dll) they have updated ones you need to find like: 'php_sqlsrv_52_ts_vc6.dll' which is what you have to load as an extension. Install v5.2.17 Install web server IIS FastCGI Download Microsoft Drivers for PHP for SQL Server (SQLSRV20.EXE) from Microsoft http://www.microsoft.com/download/en/details.aspx?id=20098 Install SQLSRV20.EXE - install to your extensions directory ..\php\ext\ - It just copies DLLs there. For version 5.2.17 on Windows running IIS7, it will use non-threaded 5.2 version Compiler v6 files: php_pdo_sqlsrv_52_nts_vc6.dll php_sqlsrv_52_nts_vc6.dll --- Go into IIS7 Manager and click PHP Manager. Enable the extensions: php_pdo_sqlsrv_52_nts_vc6.dll php_sqlsrv_52_nts_vc6.dll This adds extensions to the ini: [php_PDO_SQLSRV_52_NTS_VC6] extension=php_pdo_sqlsrv_52_nts_vc6.dll [php_SQLSRV_52_NTS_VC6] extension=php_sqlsrv_52_nts_vc6.dll Note – different versions of the DLL for 5.2. Connection test: <?php print "Connecting...<br /><br />"; $serverName = "MYSERVERNAMEHERE"; $uid = "my_username_here"; $pwd = "my_secret_password"; $dbname = "MyDatabaseName"; $connectionInfo = array( "Database"=>"$dbName", "UID"=>"$uid", "PWD"=>"$pwd"); $conn = sqlsrv_connect( $serverName, $connectionInfo); if($conn) { echo "Connection established.\n"; } else { echo "Connection could not be established.\n"; die( print_r( sqlsrv_errors(), true)); } sqlsrv_close( $conn); ?>
  19. I may have fixed the connection - I think my DBA wasn't giving me the right instance name. But now I get: Connection string is not valid using the connection string above. :-\
  20. strToLower? $str1 = strtolower($str1); $str2 = strtolower($str2); if ($str1 == $str2) { print "we're the same"; }
  21. I've been working on this for 8 hours and still cannot get sqlsrv_connect to work. Thank you, Microsoft. My connection strings work for Access DBs and MySQL - but I can't get this to work. For servername, I've tried: $serverName = "MYSERVER"; $serverName = "(MYSERVER\MYINSTANCE)"; $serverName = "'MYSERVER\MYINSTANCE'"; $serverName = "(MYSERVER)"; Setup: PHP Compiler = MSVC9 (Visual C++ 2008) C:\Program Files (x86)\PHP\v5.3\php.ini extension_dir C:\Program Files (x86)\PHP\v5.3\ext\ php_sqlsrv_53_nts_vc9.dll in the extension library. And I'm getting an error from sqlsrv_errors, so it looks like the DLL is working. Pulling my hair out here. Any ideas? $serverName = "MYSERVER\MYINSTANCE"; $connectionInfo = array("UID" => $uid, "PWD" => $pwd, "Database"=>"$dbname"); $conn = sqlsrv_connect( $serverName, $connectionInfo); if($conn) { echo "Connection established.\n"; } else { echo "Connection could not be established.\n"; die( print_r( sqlsrv_errors(), true)); } sqlsrv_close( $conn); Connection could not be established. Array ( [0] => Array ( [0] => 08001 => 08001 [1] => 53 => 53 [2] => Named Pipes Provider: Could not open a connection to SQL Server [53]. => [sql Server Native Client 10.0]Named Pipes Provider: Could not open a connection to SQL Server [53]. ) [1] => Array ( [0] => HYT00 => HYT00 [1] => 0 => 0 [2] => [sql Server Native Client 10.0]Login timeout expired => [sql Server Native Client 10.0]Login timeout expired ) [2] => Array ( [0] => 08001 => 08001 [1] => 53 => 53 [2] => [sql Server Native Client 10.0]A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online. => [sql Server Native Client 10.0]A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online. ) )
  22. I have a grid, where there is a single checkbox will indicate a yes/no value: Field1 | Field 2 x | x | x etc. And I'm using an array for each field on each row: <input type=\"checkbox\" name=\"Field1[]\" value=\"$Field1\" /> <input type=\"checkbox\" name=\"Field2[]\" value=\"$Field2\" /> The problem: When I cycle through the array, it only contains values for checked boxes - and doesn't contain a value for unchecked boxes. So if my table has 20 rows and 5 are checked, I only get an array with 5 elements. A table with 20 rows, 5 checked: foreach ($_POST['Field1'] as $f1) { print "F = $f1 <br />"; } Results: F = 1 F = 1 F = 1 F = 1 F = 1 I would expect to get "F= " for the unchecked boxes. It seems like I'm missing something simple. All help is appreciated! B
  23. I'm trying to make a left-side navigation iFrame work like a regular frame. If you click on a link in the iFrame, it should target the parent page, reloading it - but I don't want it to reload the iFrame. However, since the iFrame is in the parent page, it is always reloaded. Is there any way around this?
  24. I've been pulling my hair out with this one. I have a page with an iframe with an anchor. Main frame - myTasksIframe.php <iframe src="myTasksIframe.php?PID=1234&testPID=5678#iframeAnchor=$iframeAnchor"> When I click on a link in the iframe: Iframe = myTasksIframe.php <a href="myTask.php?testPID=$testPID&iframeAnchor\" target=\"_parent\">Go to place in iframe</a> it will refresh the main page, and skip down to the anchor in the iframe. Trouble is that the page focus goes to the iframe, and the page is shifted down and I can't figure out how to make the anchor happen while setting the main page to NOT focus on the iframe and shift the page down. I've tried many versions of window.scrollTo(0,0); parent.window.scrollTo(0,0); opener.window.scrollTo(0,0); opener.scrollTo(0,0); parent.window.location = "#" and so on. I can't get any of it to work. Please HELP!
  25. It seems to work though. How would you use IS NULL? I tried a few different ways but got nothin
×
×
  • 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.