Jump to content

Search the Community

Showing results for tags 'sqlsrv'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 7 results

  1. Hi, Is that possible to connect to microsoft sql server by using mysqli? Currently i connected by using sqlsrv. For example, $serverName = "servername.com"; //serverName\instanceName $connectionInfo = array("Database" => "DB1", "UID" => "user99", "PWD" => "12345"); $conn = sqlsrv_connect($serverName, $connectionInfo); i have try quite some time to use mysqli to connect. But I keep getting errors.. Thank You
  2. I have a stored procedure with 2 parameters. I'm able to execute stored procedures with one parameter using the same script below. But I couldn't make it work with two parameters. $stmt = "{CALL VM_GETPRs_CAMPS (?,?)}";**//SP has 160 rows of data.** $fdate=date("Y-m-d"); $tdate=date("Y-m-d"); $params = array( array($fdate,SQLSRV_PARAM_IN), array($tdate,SQLSRV_PARAM_IN) ); $result = sqlsrv_query( $conn, $stmt,$params,array('Scrollable' => 'buffered')); //not getting any error if( $result === false) { die( print_r( sqlsrv_errors(), true) ); } else{ **//**I tried sqlsrv_num_rows and sqlsrv_has_rows sqlsrv_fetch_array all are giving zero rows.** $row_count = sqlsrv_num_rows( $result ); if ($row_count === false) echo "No rows"; else if ($row_count >=0) echo "\n$row_count\n"; //outputs 0 ---------------------------------- if(sqlsrv_has_rows($result)) echo "has rows"; else echo "No rows"; //outputs No rows ---------------------------------- $data = sqlsrv_fetch_array($result, SQLSRV_FETCH_ASSOC); var_dump($data); //outputs bool(false) I'm looking for a solution since four days. Please help me.
  3. 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
  4. I have the following code which prints results from a sqlsrv_fetch_array() using a while loop. For one segment, however, I only need the first $value of the $key=>$value pair, and obviously with the code written this way it returns all rows. I have an idea of an approach, and I'm wondering if I'm headed in the right direction or if anyone has experience with this that they can share. So, during the while loop, I am pushing the elements of the sqlsrv_fetch_array() into a separate array. So I see two potential options: 1. Print from the $actcontacts[] array rather than from the sqlsrv fetch array. 2. During the while loop, rather than pushing anything into a new array, build a conditional that says to only print the record if $row['ENDTIME'] is in position $row[0]. I'm leaning toward #2, but I'm not quite sure how to get there...and if there is a better way under door #3, I would like to try that. while ($row = sqlsrv_fetch_array( $stmt_act, SQLSRV_FETCH_ASSOC) ) { $actcontacts[] = "N/A" . "," . $row['COMPANYNAME'] . "," . $row['CITY'] . "," . $row['STATE'] . "," . $row['CUST_Salesman_124705300'] . "," . $row['ENDTIME'] . "," . "ACT"; // I have done a print_r() on $actcontacts and the data is correct. $endtime[] = $row['ENDTIME']; echo "<tr>"; echo "<td>" . "<i>N/A</i>" . "</td>"; echo "<td>" . $row['COMPANYNAME'] . "</td>"; echo "<td>" . $row['CITY'] . "</td>"; echo "<td>" . $row['STATE'] . "</td>"; echo "<td>" . $row['CUST_Salesman_124705300'] . "</td>"; echo "<td>" . $row['ENDTIME'] . "</td>"; // This is the bugger that is printing eleventy records. It may be one customer, but there are always multiple contact/history entries. echo "<td>" . "ACT" . "</td>"; echo "</tr>"; }
  5. Hello, I have successfully installed PHP onto an IIS/SQL Server environment. I can get a DB connection and I can also post and display variables from one PHP page to another. I am trying to create a login script for a web application, but I am am having trouble getting any results from any select query that I write. Here is my login.php page: <body> <?php ob_start(); session_start(); $username = $_POST['username']; $password = $_POST['password']; $serverName = "localhost"; $connectionInfo = array("Database"=>"Derm", "UID"=>"xxxxxxxx", "pwd"=>"xxxxxxxxx"); $conn = sqlsrv_connect( $serverName, $connectionInfo); $query = "SELECT username, password, level, type, location FROM user_access WHERE username = '$username'"; $result = sqlsrv_query($conn, $query); if(sqlsrv_num_rows($result) == 0) // User not found. So, redirect to login_form again. { header('Location: index.html'); } $userData = sqlsrv_fetch_array($result, SQLSRV_FETCH_ASSOC); $hash = hash("sha512", $password); if($hash != $userData['password']) // Incorrect password. So, redirect to login_form again. { header('Location: index.html'); } else{ session_regenerate_id(); $_SESSION['username'] = $userData['username']; $_SESSION['level'] = $userData['level']; $_SESSION['type'] = $userData['type']; $_SESSION['location'] = $userData['location']; session_write_close(); header('Location: main.php'); } ?> </body> I have checked the query many times in SQL Server management studio and it always returns the correct result using my username. However, here, the page keeps refreshing itself and never progresses to 'main.php'. Is there a way to solve this or are there any alternatives to do the same thing? I don't actually want to display the query results, rather just assign them as session variables. Thanks
  6. Hello all! Does anyone know how to insert directly into an image field of a SQL Server table, the image that the user selects from the input file of the form? thanks in advance!
  7. Hello all, I have a Windows Server 2008 R2 Standard 64-bit server running WAMP 2.2 along with PHP 5.3.13 and a SQL Server Enterprise 64-bit. SQLSRV is registered as a PHP stream using Microsoft Drivers 3.0 for PHP and SQL Server. The connection is made without issue and the query is working as it should, the only problem is that I haven't figured out the correct way to display what is returned by the query. Maybe you all might be able to help me out! Here's a look at a couple things I've been trying. if( $conn ) { echo "Connection established.<br />"; }else{ echo "Connection could not be established.<br />"; die( print_r( sqlsrv_errors(), true)); } $query = "SELECT top (10) docid, sequence, server, share, path, filename "; $query .= "FROM files "; $query .= "WHERE filename like '%2008010639029%'"; $result = sqlsrv_query($conn, $query) or die (sqlsrv_errors()); if(sqlsrv_has_rows($result)){ echo "1 or more rows have been returned<br />";} else {echo "No results were found.<br />";} while($row = sqlsrv_fetch_array($result, SQLSRV_FETCH_ASSOC)) { print_r ($row); } When that script is run the results of the query are correct it is just displayed like so: Here is the other method that I'm using that gets close. if( $conn ) { echo "Connection established.<br />"; }else{ echo "Connection could not be established.<br />"; die( print_r( sqlsrv_errors(), true)); } $query = "SELECT top (10) docid, sequence, server, share, path, filename "; $query .= "FROM files "; $query .= "WHERE filename like '%2008010639029%'"; $result = sqlsrv_query($conn, $query) or die (sqlsrv_errors()); if(sqlsrv_has_rows($result)){ echo "1 or more rows have been returned<br />";} else {echo "No results were found.<br />";} while($row = sqlsrv_fetch_array($result, SQLSRV_FETCH_ASSOC)) { $docid = sqlsrv_get_field($result, 0); $sequence = sqlsrv_get_field($result, 1); $server = sqlsrv_get_field($result, 2); $share = sqlsrv_get_field($result, 3); $path = sqlsrv_get_field($result, 4); $filename = sqlsrv_get_field($result, 5); echo "$docid" . "$sequence, " . "$server, " . "$share, " . "$path, " . "$filename, " . '<br />'; } The result is: Do you all have any suggestions? Thanks a ton for looking at this.
×
×
  • 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.