Tag: php

Pagination using PHP and SQL Server

I have a following sql query which works fine for paging $tsql = “SELECT * FROM (SELECT ROW_NUMBER() OVER(ORDER BY ClientID) AS rowID, Status, FirstName, LastName FROM Client) AS TEMP WHERE (rowID BETWEEN ? AND ? + 1)”; When I add one more condition (Status != -1) in where clause, it doesn’t show me the […]

Array returning blank on Azure

Currently trying to do a web service at Azure. Despite tweaking around, the array returned is always blank. There is a response code #3 when I inserted echo to $stmt <?php // Include confi.php include_once(‘confi.php’); $asset_id = $_GET[‘asset_id’]; if(!empty($asset_id)){ $qur = sqlsrv_query(“SELECT asset_name,operating_system ,serial_no ,asset_status FROM [dbo].[assets] WHERE [asset_id]='”.$asset_id.”‘”); $stmt = sqlsrv_query( $conn, $qur); $result […]

MSSQL driver for PHP (ODBC) randomly stop sending Unicode chars

I’m getting data from a MSSQL database* with PHP and the ODBC/FreeTDS drivers. I’m running PHP-FPM 7.0 and my freetds.conf looks like this: [NAME] host = HOST_NAME instance = ISTANCE_NAME tds version = 8.0 text size = 193536 My /etc/odbcinst.ini looks like this: [FreeTDS] Description = FreeTDS Driver v0.91 Driver = /usr/lib/libtdsodbc.so fileusage=1 dontdlclose=1 UsageCount=1 […]

Filter Dropdown Based on Another Dropdown Selection

I have multiple dropdowns and want to filter the contents of the second dropdown based on what is selected in the first dropdown. Here is the following code that I have so far. How could I do this? HTML/PHP: <td> <select id=”major” onChange=”updateCat();”> <?php foreach ($dropdown_major->fetchAll() as $drop_major): ?> <option value=”” data-name=”<?php echo $drop_major [‘Major […]

I have a PHP code to insert into SQL Server 2014 through a form, but it does not work. Can you help me?

When I execute the code give me the next error: Array ( [0] => Array ( [0] => 42000 [SQLSTATE] => 42000 [1] => 102 [code] => 102 [2] => [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Sintaxis incorrecta cerca de ‘ł’. [message] => [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Sintaxis incorrecta cerca de ‘ł’. ) […]

(PHP) Insert a base64_decoded string to an image column sql server

I have a problem when adding a base64 decoded string to a database, it says incorrect syntax.. heres the thing First I have the $image string and decode it using base64_decode function $image = ‘/9j/4AAQSkZJRgABAQAAAQABAAD/’; $decoded = base64_decode($image); It will become ÿØÿàJFIFÿ and when I try to insert in the database (sql server) MSSQL error: […]

Query using data from wrong column

The title may be a bit misleading as I didn’t know exactly how to phrase it. I have a PHP page which shows a listing of records with search filters. The code is given below. The page gets displayed correctly but in one of the columns I get following database error for MS SQL Error […]

Date Select boxs values convert to SQL data base date type value

My web site have three select box which are year, month and date. Those selector boxes values are like this. Year box value – 1992 Moth box value – 02 Date box value – 05 I want to convert to store my SQL data base in date type column. First I tied to give directly […]

Pass array to SQL server stored procedure from PHP

I need to call stored procedure on SQL server and pass array of items. Example passing student info with multiple awards: [awards] id, description 1, Award 1 2, Award 2 3, Award 3 4, Award 4 5, Award 5 students: id, first_name, last_name I need to pass one student with multiple award ID’s (this number […]

MSSQL Parameterized Queries

Over MySQLi I would do: $sql = $connect->prepare(“INSERT INTO Table (a, b) VALUES (?, ?)”); $sql->bind_param(‘ss’, $a, $b); $sql->execute(); $sql->close(); Now the question is, how I do the same thing with mssql for a SQL Server instead of MySQL? I know I could do: $sql = sqlsrv_query($connect, “INSERT INTO Table (a, b) VALUES (?, ?)”, […]

MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.