Tag: php

Sql-server: trigger and last inserted ID

I have a PHP application using a sql-server database and trigger. The workflow is the following: – I create an object in the DB, – a trigger logs the creation into a dedicated table, by inserting a row within, – then from PHP I get the last inserted ID. The problem is that the last […]

Mysql query/server optimization

Recently I changed MySQL version to 5.6.23 from 5.5.8 and got stuck in some query performance issue. In old MySQL; query is executed in some reasonable time, but in new one freebsd server+mysql server becomes unresponsive. Linux command [linux~] top show mysql >100% wcpu when query is executed. If I execute each subquery seperately, results […]

WAMP | Installing PDO drivers into PhP extensions

WAMP is relatively new ground to me. I have currently only done basic installations and vhosts configurations. Issue I am trying to get the PDO drivers installed on my WAMP server so I can connect to SQL Server Databases. From a previous question I asked it was determined i do not have the correct drivers. […]

How to escape wild cards in SQL Server Like Clause

I am using mssql and sqlsrv libraries (cross platform site) with php and I have had to use a snippet for string sanitation as neither library provides a mysqli_real_escape_string equivelent. My function is this: public function sanitize($string) { if (is_numeric($string) || $string === ‘NULL’ { return $string; } $unpacked = unpack(‘H*hex’, $string); return ‘0x’ . […]

Converting image datatype from Sql Server to php

I’m trying to show an image saved from SQL Server from the database to the php page I am creating. What I’ve done so far is I get the necessary data from the database, which is the image , and the image type(if its a jpg). This is what I did: $idata = base64_decode($imageResult); imagejpeg($idata); […]

SQL join table result of 2 statements

I am trying to get data with SQL from my WordPress database by a JOIN, but I do not get it working. What I need: Posts where the meta_key “gtp_product_dont_show” exists and where the meta_value not is “true”. And posts where the meta_key “gtp_product_dont_show” does not exists. My Problem: I now only get the results […]

sql select from table then compare with other table in one statement

I have to tables in one database. users user_activate I have to variables in php $username = foo; $key = jas823k123ksd34324; Now I want to select from the table users the attribute user_id where user_username == $username I do this with this statement $sql = “SELECT user_id FROM users WHERE user_username = ‘$username'”; $result = […]

Error connecting to MSSQL using PHP

I am receiving an error as below: PHP Fatal error: Uncaught exception ‘PDOException’ with message ‘SQLSTATE[08001]: [Microsoft][ODBC Driver 11 for SQL Server]SQL Server Network Interfaces: Connection string is not valid [87]. ‘ My codes are as follow: $this->link = new PDO( “sqlsrv:server=$this->serverName:$this->port;Database=$this->db”, “$this->uid”, “$this->pwd” ); I wish someone can enlighten me on what is causing […]

How can I get users to connect to my database if my server deny's remote access for allowing all i.p's (*.*) ?

I am making a web application, but I also want to make it a desktop application. The problem is that my server (for security purposes) does not allow remote access to connect outside of the server unless you manually import the i.p. addresses and this will not work because it needs to allow access to […]

PHP sql_srv_rows_affected to return multiple outputs

I have created a stored procedure to import a list of records. This stored procedure INSERTs to a temporary table then MERGEs based on if contract numbers match. WHEN NOT MATCHED BY TARGET it INSERTs into the real table and WHEN NOT MATCHED BY SOURCE it DELETEs from the real table. This works fine, the […]

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