Tag: php

How to insert data in database using php

I have just started to work with php. I write a simple code in php to insert data in a table customer. I am using mssql database. <?php function InsertData() { $link = mssql_connect(‘db’,’123′,’test’); if (!$link || !mssql_select_db(‘php’, $link)) { die(‘Unable to connect or select database!’); } $sql = ” INSERT INTO customer ([Name],[Website])VALUES(‘$txtName’,’$txtWebsite’)”; $result […]

Why is my SQL Server query failing?

connect(); $arr = mssql_fetch_assoc(mssql_query(“SELECT Applications.ProductName, Applications.ProductVersion, Applications.ProductSize, Applications.Description, Applications.ProductKey, Applications.ProductKeyID, Applications.AutomatedInstaller, Applications.AutomatedInstallerName, Applications.ISO, Applications.ISOName, Applications.Internet, Applications.InternetURL, Applications.DatePublished, Applications.LicenseID, Applications.InstallationGuide, Vendors.VendorName FROM Applications INNER JOIN Vendors ON Applications.VendorID = Vendors.VendorID WHERE ApplicationID = “.$ApplicationID)); $query1 = mssql_query(“SELECT Issues.AppID, Issues.KnownIssues FROM Issues WHERE Issues.AppID=”.$ApplicationID); $issues = mssql_fetch_assoc($query1); $query2 = mssql_query(“SELECT ApplicationInfo.AppID, ApplicationInfo.Support_Status, ApplicationInfo.UD_Training, ApplicationInfo.AtomicTraining, ApplicationInfo.VendorURL FROM ApplicationInfo […]

Running while($row = sqlsrv_fetch_array($result)) multiple times

I am retrieving a couple of tables from a MSSQL database, which I am then running through to obtain order information from. My code looks like this: while($row = sqlsrv_fetch_array($orderResult)) { ……code…….. ……………… while($statusRow = sqlsrv_fetch_array($statusResult)) { ….code…. } ….code…. } Now my problem is that after the second loop runs through, it never runs […]

sqlsrv access database and tables that have spaces in their names in PHP

I can access database and tables that don’t have spaces in their names but when they do I can’t. $result = “SELECT * FROM [LoLDatabase].[dbo].[Champ Stats]”; ^ has no errors but returns nothing $result = “SELECT * FROM [LoLDatabase].[dbo].Items”; ^Works echo $obj->Cost.'<br />’; ^works echo $obj->Item Name.'<br />’; ^Does not work nor do these… echo […]


I don’t know what is going on, but it just doesn’t want to work. I keep getting this error when I submit my form: Array ( [0] => Array ( [0] => 22001 [SQLSTATE] => 22001 [1] => 8152 [code] => 8152 [2] => [Microsoft][SQL Server Native Client 10.0][SQL Server]String or binary data would be […]

Call to undefined function sqlsrv_connect() in C:\wamp\www\Webs\client.php on line 7

Am using windows 8 pro, Wamp server (php V5.3.5, apache V2.2.17), Sql server 2005 express editon. I have downloaded the sqlsrv drivers and extracted them into the php extention folder (C:\wamp\bin\php\php5.3.5\ext), have also update the php.ini file by adding the extentions extension=php_sqlsrv_53_ts_vc6.dll extension=php_pdo_sqlsrv_53_ts_vc6.dll I used this two after series of try and error on all […]

Need help connecting my App Engine PHP with my Google Cloud SQL Database

Below is the sql connection code for my php script as it attempts to connect to my Google SQL Cloud Database <?php $con=mysqli_connect(“:/cloudsql/projectID:google-cloud-instance”,”root”,”root”,”DATABASE”); // Check connection if (mysqli_connect_errno()) { echo “Oops! Something Must Have Went Wrong?: ” . mysqli_connect_error() ;` but when I process the overall php script i get the following error: “php_network_getaddresses: gethostbyname […]

mysql php pdo select a part of row value date record

I want to select a part of a record in database. The record i want to select from is date. The record date is this format 07/02/2015. I want to have a select option where i can put option of year and month to used as parameter for the search.I want to know a select […]

MSSQL INSERT query failing for a specific table when called with PHP

I need to read the date that a request was created from our website. When that request is created, the information corresponding to that request and its meta-request is inserted in the DAI_REQ.REQUEST and DAI_REQ.META_REQUEST tables, respectively. We also have a dev server and a public deployment server. The problem happens only on our deployment […]

Character Set issue using SQL Server and ODBC in php

I connected to to sqlsever2008 with odbc(with dsn) and php but problem is that when I retrieve information from that it has character like ���������. My datatype in sqlserver is nvarchar. Any idea why it is happening? NOTE: The page is utf8. Edit: I use echo utf8_encode(odbc_result($this->result,’name’) ); and characters are like: ÂãæÒÔ ÒÈÇäÂãæÒ i […]

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