PHP - Php On New Server No Longer Connects (mssql)
We're moving to a new web server and we recently migrated to a new MS SQL server, as well. All PHP functions on the old web server were switched to point to the new SQL server and all was well.
But..... Now I''m trying to move my PHP functions to the new web server and it won't connect to the database. PHP works fine because I can echo "Testing" or whatever. I've downloaded the SQL Server PHP drivers from Microsoft, changed the connection string from MSSQL to SQLSRV, updated the PHP.ini file, and taken several other steps. It still can't see the database. Ideas? Oh, yeah. And both the new web server and MS SQL server are Server 2008 R2. Similar TutorialsI apologize if this isn't the exact right location for this question, but it's the best place I could find. I work for a small business and the server hosting our website recently disabled FormMail. We no longer have a webdesigner per se and I've been the one taking care of the website. Unfortunately the few programming classes I've taken have mostly left me by now and I'm banging my head against the wall trying to find a way to get back our multiple feedback forms. I'm sure the best thing would be to hire someone, but business hasn't been great and the boss is counting on me, so I'm hoping someone here may have some suggestions. I've been corresponding with our server trying to get some suggestions on what to do and this is the best they've been able to tell me; "The reason being that Shared Servers must have the ability for php/cgi to send mail disabled as a protection against darkmailer, so any form or scripts that would send mail must be able to authenticate itself to the server as a valid user." "If you can find a method to send the mail without php/cgi, or one that does go through the steps to authenticate as a valid user (specifically, as you), then we can probably get you all set up." "The only option at this point would be to correct your script to authenticate as a valid email user." "...you would need to change your scripts to login with a mail user to authenticate and send mail." Now I'm not completely programming illiterate; I mean, I passed my classes in college, but I can't figure out how to do this. They say they don't allow any FormMail or FormMail Clones, so I'm fairly lost. If anyone has any helpful hints or suggestions I would appreciate it greatly. Thanks, Zach This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=352526.0 The information on the php.net documentation seems to be out of date.
http://php.net/manua...databases.mssql
as the link to the necessary libraries for Linux is broken.
Can you tell me, or point me to what is needed to connect to MSSQL with PHP 5.3.3/Apache on Red Hat Linux
If there is more than one option, we would like to know what they are and the installation details.
Thanks
Hello, am having problem with connection to mssql server and database. Am using Xampp and i think there is some problem about his configuration. All the time am getting error : missing driver php_mssql.dll in xampp/php/ext/ ....and file php_mssql.dll is there (same problem with php_pdo_mssql.dll). Also am getting this error: "Fatal error: Call to undefined function mssql_connect() " I tried everything i could find on forums, blogs, and php documentation...but always same. btw... i removed ";" in php.ini from necessary lines and i copy ntwdblib.dll in necessary folders. This is my connection code: Code: [Select] $dbHost = 'Workstation:<port>'; $dbUser = 'user'; $dbPass = 'pass'; $dbName = 'database'; $con = mssql_connect ($dbHost, $dbUser, $dbPass) or die ('MsSQL connect failed. ' . mssql_error()); mssql_select_db($dbName) or die('Cannot select database. ' . mssql_error()); I also tried with: Code: [Select] $connection = odbc_connect("Driver={SQL Server Native Client 10.0};Server=$server;Database=$database;", $user, $password);but always same.... Can anybody please provide me some working solution ? Thanks. I'm running:
Windows Server 2003
IIS 6.0
Microsoft SQL 2005
PHP 5.3.28
Everything that i have read says, "5.3 got rid of mssql and now uses sqlsrv"
so i added extension=php_sqlsrv_53_nts_vc9.dll to my php.ini (and yes it is in the ext folder)
and when i run the script
$serverName = "localhost\phonebook"; //serverName\instanceName // Since UID and PWD are not specified in the $connectionInfo array, // The connection will be attempted using Windows Authentication. $connectionInfo = array( "Database"=>"XXXXX", "UID"=>"XXXXX", "PWD"=>'XXXXXXXX'); $conn = sqlsrv_connect( $serverName, $connectionInfo); if( $conn ) { echo "Connection established.<br />"; }else{ echo "Connection could not be established.<br />"; die( print_r( sqlsrv_errors(), true)); }i get Connection could not be established. Array ( [0] => Array ( [0] => IMSSP [SQLSTATE] => IMSSP [1] => -49 [code=auto:0] => -49 [2] => This extension requires either the Microsoft SQL Server 2008 Native Client (SP1 or later) or the Microsoft SQL Server 2008 R2 Native Client ODBC Driver to communicate with SQL Server. Neither of those ODBC Drivers are currently installed. Access the following URL to download the Microsoft SQL Server 2008 R2 Native Client ODBC driver for x86: http://go.microsoft..../?LinkId=163712 [message] => This extension requires either the Microsoft SQL Server 2008 Native Client (SP1 or later) or the Microsoft SQL Server 2008 R2 Native Client ODBC Driver to communicate with SQL Server. Neither of those ODBC Drivers are currently installed. Access the following URL to download the Microsoft SQL Server 2008 R2 Native Client ODBC driver for x86: http://go.microsoft..../?LinkId=163712 ) [1] => Array ( [0] => IM002 [SQLSTATE] => IM002 [1] => 0 [code=auto:0] => 0 [2] => [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified [message] => [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified ) ) What can i do to fix this? I assume use an older .dll? HI, I've upgraded from PHP version 5.2 to PHP version 5.4 and are not able to load / find mssql extension ? How do I use MSSQL in version 5.4 ?? Is MSSQL not supported in this version or am I (hopingly) missing something ??? Regards Dieter I'm having problems with enabling the sort functions of jqgrid. I think I've narrowed the problem down to the way MSSQL is returning the data to the SQL query. In an effort to troubleshoot, I've drastically simplified the problem. The query I'm using is below. Code: [Select] SELECT * FROM dbo.test ORDER BY locationName When I run the query directly in MSSQL Management Studio, the top 5 ID entries are 132, 1309, 1295, 1281, 1267. When I run the corresponding code in PHP, the top 5 ID entries are 1266, 1267, 1268, 1269, 1270 - it seems to be ignoring my order by clause. Is there something I need to do to force it to honor the ORDER BY locationName? Code: [Select] $kpiQuery = "SELECT * FROM dbo.test ORDER BY locationName"; $result = mssql_query($kpiQuery); while($kpiRow = mssql_fetch_array($kpiResult)) { echo $kpiRow[plDataID]."<br>"; } Hi, I have been working with inserting unicode characters into mssql database from a php application. My php web application displays the chinese characters as i entered and retrieves from database properly. But when I take a look at the database the fields are populated with some other values other than the characters i inserted. When i developed the same application in ASP.net the database has correct values inserted into it. Here is my code in php: Code: [Select] <?php // direct insert $var = mssql_connect('RAL-DEV-SQL01','TestDBSa','TestDB$@'); $selected = mssql_select_db('TestDB', $var); $myVar="日常生活"; $myChineseVar=$myVar; echo $myChineseVar; $query = "insert into TestChinese (TestName) values (N'{$myChineseVar}')"; $result = mssql_query($query,$var); echo "Inserted<br>"; echo $query; echo "<br>Result<br>"; $result2 = mssql_query("SELECT TOP 10 * FROM [TestChinese] order by SeqNum desc",$var); while($nt=mssql_fetch_array($result2)){ echo "$nt[SeqNum] - "."$nt[TestName] -"; echo "<br>"; } mssql_close($var); ?> Can someone help me with this problem Thanks Hi, I have tried to merge two queries into one however a piece of code keeps coming up with an error: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource. It relates to this. I cant see it doesn't work and I have tried around 10 different options but this is the nearest I can get. Can anyone advise me what the problem is and why this no longer works please? while($row = mysql_fetch_assoc($myQuery)) <?php ini_set('display_errors', 1); error_reporting(-1); if( isSet($_GET['description'])) $description = $_GET['description']; if(isSet($_GET['price'])) $price = explode('-',$_GET['price']); $low = (int)$price[0]; $high = (int)$price[1]; ($myQuery = "SELECT * FROM productfeed WHERE 1 . if(isset($description)) ' AND if description = '. $description; if(isset($price)) ' AND if price = '. $price; . "); while($row = mysql_fetch_assoc($myQuery)) { $id = $row['id']; $image = $row['awImage']; $link = $row['link']; $description = $row['description']; $fulldescription = $row['fulldescription']; $price = $row['price']; $fulldescription = substr("$fulldescription", 0, 400); echo "<div class='productdisplayshell'> <div class='productdisplayoutline'> <div class='productborder'><center> <a href='$link' target='_blank'><img src='$image' width=\"95%\" /></a> </center> </div></div> <div class='productdescriptionoutline'> <div class='productdescriptionbox'> <a href='$link' target='_blank' >$description</a> </div> <div class='productfulldescriptionbox'>$fulldescription</div> </div> <div class='productpriceoutline'> <div class='productpricebox'> <center>&#163; $price</center> </div> <div class='productbuybutton'> <center><a href='$link' target='_blank' ><img src=/images/buybutton.png /></a></center> </div> </div> </div>"; } Hi, thanks in advance for any help here. I have a PHP 'contact us' form on my website that recently stopped returning the information that gets entered into the form. I don't know why it's no longer working and was hoping someone here could help. It's worked for the last 4 years and only stopped working within the last week. I still get the email, but none of the information is returned, only blanks. Any ideas? Here's the script I'm using: Code: [Select] <?php /*----------------------*/ /* URL of the site. */ /*----------------------*/ $site_URL = "http://www.Website.com/"; /*----------------------*/ /* Name of the site. */ /*----------------------*/ $site_Name = "Website.com"; /*----------------------*/ /* ADMIN email id. */ /*----------------------*/ $admin_from = "webmaster@Website.com"; /*----------------------*/ /* ADMIN email id to which comments are sent. */ /*----------------------*/ $admin_email = "info@Website.com"; $name = $_REQUEST["firstname"]; $lastname = $_REQUEST["lastname"]; $email = $_REQUEST["email"]; $zipcode = $_REQUEST["zipcode"]; $phone = $_REQUEST["phone"]; $message = $_REQUEST["message"]; $subject = "$site_Name has Received your Message"; $sendmessage = "<font face='tahoma, verdana, arial, helvetica' size=2>New Comments Received...<br><br>"; $sendmessage .= "<strong>Name:</strong> $name $lastname<br>"; $sendmessage .= "<strong>Zipcode:</strong> $zipcode<br>"; $sendmessage .= "<strong>Phone:</strong> $phone<br>"; $sendmessage .= "<strong>Email:</strong> <a href='mailto:$email' style='color:#6095cc; text-decoration: none;'>$email</a><br>"; $sendmessage .= "<strong>Message:</strong> $message<br>"; $sendmessage .= "<br><a href='$site_URL' target=_blank>$site_Name</a></font>"; $headers = "Content-Type: text/html; charset=iso-8859-1\n"; // Mime type $headers .="From: $site_Name Registration <$admin_from>\n"; mail($admin_email, $subject, $sendmessage, $headers); $reply_msg = "<font face='tahoma, verdana, arial, helvetica' size=2>Thank you for your comments at $site_Name. We will reply soon!<br>"; $reply_msg .= "<br>- <a href='$site_URL' target=_blank>$site_Name</a></font>"; $headers = "Content-Type: text/html; charset=iso-8859-1\n"; // Mime type $headers .="From: $site_Name<$admin_from>\n"; // send an email to confirm the referer. mail($email, "$site_Name - Your comments have been received!", $reply_msg, $headers); ?> <center> <font face='tahoma, verdana, arial, helvetica' color='#333333'> <h2> <?=$site_Name?> </h2> <p><font size="2" face="Arial, Helvetica, sans-serif"><strong>Please wait while your comments are being sent.</strong>.<br /> If your page does not refresh automatically, <a href="<?=$site_URL?>">Click Here</a>.</font></p> </center> <script language="javascript"> window.location.href = "<?=$site_URL?>"; </script> MOD EDIT: [code] . . . [/code] BBCode tags added. Hi every one, i am trying to connect with a remote SQL server on window platform. i have hostname, username, password and database name, but when i try t connect using mssql_connect($server,$username,$password) i got this Warning: mssql_connect() [function.mssql-connect]: Unable to connect to server: Thanks Ok, I made some changes to my code (change in variable names only) and now it doesn't seem to work. Here is the code. <?php if ($_REQUEST['postal'] != "" && $_REQUEST['lbs'] != "") { $postal = $_REQUEST['postal']; $lbs = $_REQUEST['lbs']; $type = $_REQUEST['type']; if ($type == "splist") { $ztype = "cansp_zone" ; $lbstype = "sp"; } else { $ztype = "canmp_zone"; $lbstype = "mp"; } $qP1 = "SELECT * FROM " . $dbprefix . "_canzones WHERE canzone_postal = '$postal' "; $which = $handle_db2; $rsP1 = mysql_query($qP1,$which); if (mysql_num_rows($rsP1) > 0) { $row1 = mysql_fetch_array($rsP1); extract($row1); $prov = trim($canzone_prov); $zone = trim($canzone_zone); $dzone = $ztype.$zone; $dlbs = "can" . $lbstype . "_lbs"; $query = "SELECT $dzone FROM " . $dbprefix . "_can" . $type . " WHERE $dlbs = '$lbs' "; $which = $handle_db2; $result = mysql_query ($query,$which); $row = mysql_fetch_array($result); $dzone = $row[0]; $qP3 = "SELECT * FROM settings WHERE storeid = '$dbprefix' "; $which = $handle_db2; $rsP3 = mysql_query($qP3,$which); $row3 = mysql_fetch_array($rsP3); extract($row3); $taxsetting = trim($taxsetting); $gst = trim($gst); $pst = trim($pst); $hst = trim($hst); $cp_fuelcharge = trim($cp_fuelcharge); $cp_markup = trim($cp_markup); include("./inc/taxcalc.php"); include("./inc/markcalc.php"); ./inc/markcalc.php is as follows: <?php if ($cp_markup != "") { $cp_mark = ($dzone * ($cp_markup / 100)); When I output $cp_mark, it comes out as the same value as $cp_markup Any ideas? I've got some PHP code that accesses SQL on an Amazon cloud server. Other machines running Unix and Windows can perform accesses fine using the server name (IP for Windows, label for Unix), database name (string) and a password (string). However, the same code FAILS on OSX (my Macbook Pro). SQL managers on my MBP have no problem accessing it, since I've made the proper exceptions on the AWS firewall. But PHP can't do any MS SQL reads of this database. Is there something else I don't know? Is there some other key information being exchanged that my MBP needs to send that I can't see? TIA!! Hello,
I am trying to run a report as per the below mssql query:
$query = "SELECT tblWJCItem.AddedDescription, tblWJC.WJCPrefix, tblWJC.WJCNo, tblWJCItem.MaterialName, tblStockFamily.StockFamily, tblWJCItem.WeightToSend, tblWJC.DateCreated, tblWJC.WJCStatusID FROM tblWJC INNER JOIN tblCustomer ON tblWJC.CustomerID = tblCustomer.CustomerID INNER JOIN tblWJCStockStatus ON tblWJC.WJCStockStatusID = tblWJCStockStatus.WJCStockStatusID INNER JOIN tblStockStatus ON tblWJC.WJCID = tblStockStatus.WJCID LEFT OUTER JOIN tblWJCProductLine ON tblWJC.WJCID = tblWJCProductLine.WJCID LEFT OUTER JOIN tblWJCStockItem ON tblWJCProductLine.WJCProductLineID = tblWJCStockItem.tblWJCStockItem INNER JOIN tblStockFamily ON tblWJCItem.ProductFamilyID = tblStockFamily.StockFamilyID WHERE tblCustomer.CustomerName = 'NAME' AND tblWJCStockStatus.WJCStockStatus <> 'Stock Usage Confirmed' ORDER BY tblWJC.WJCID"; Hi, I knew the way to connect to mysql but i don't know how to connect mssql. Is it the same? here's an example for mysql. please teach me the mssql. $con = new mysqli(DB_HOST,DB_USER,DB_PASS,DB_NAME); $sql = "SELECT COUNT(*) FROM numbers"; $result = $con->query($sql); $r = $result->fetch_row(); thanks $query = "SELECT Table1.*, Table2.A, Table2.B, Table2.C, Table2.D, Table2.E FROM Table1 INNER JOIN Table2 ON Table1.A = Table2.A Issue is that there are multiple matches for some instances, like so: Table1.A value = 1777 (only once since it is a UniqueID) Table2.A value = 1777 (3 records with this ID value) So I will get 3 records returned since Table1.A matches 3 records in Table2.A. I want to merge the 3 records in Table2 into 1 record and then match that with Table1 where the UniqueID is the same. Make sense? Hi all,
I am trying to do a query on a database that takes a variable from a html drop down box. I've tried so many different forums and can't find the answers.
HTML PAGE:
<html> I am using PHP with ODBC to connect to an existing MSSQL database to query for some names. When I query a name that has an apostrophe in it, I get an error. Example typing O'Malley as the name: Quote Warning: odbc_exec() [function.odbc-exec]: SQL error: [Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near 'malley'., SQL state 37000 in SQLExecDirect I have used addslashes to the string but get the same result: Code: [Select] $string = addslashes($_POST['string']); $connect = odbc_connect("$mssql_name", "$mssql_user", "$mssql_pass"); $query_mssql = "SELECT pr.NameFirst, pr.NameLast, pr.NameMiddle, pr.Birthdate, p.Barcode, p.OrganizationID FROM PatronRegistration pr JOIN Patrons p ON (pr.PatronID = p.PatronID) WHERE pr.NameLast = '$string'"; $result = odbc_exec($connect, $query_mssql); Any ideas? |