$sql = "SELECT Ptittle FROM dbo.Pcontent WHERE Pname='$Fname'"; $result = sqlsrv_query ($conn,$sql); echo $result; Why without:
WHERE Pname='$Fname' returns the value of Resursid#6 , and if I add a variable returns nothing?
$sql = "SELECT Ptittle FROM dbo.Pcontent WHERE Pname='$Fname'"; $result = sqlsrv_query ($conn,$sql); echo $result; Why without:
WHERE Pname='$Fname' returns the value of Resursid#6 , and if I add a variable returns nothing?
echo $result; use var_dump($result); and you will see that you actually returned to the answer (for example, false );Before asking questions, review the Microsoft SQL Server DBMS Driver Documentation for PHP and see examples of using functions:
<?php $serverName = "serverName\sqlexpress"; $connectionInfo = array( "Database"=>"dbName", "UID"=>"username", "PWD"=>"password" ); $conn = sqlsrv_connect( $serverName, $connectionInfo); if( $conn === false ) { die( print_r( sqlsrv_errors(), true)); } $sql = "INSERT INTO Table_1 (id, data) VALUES (?, ?)"; $params = array(1, "some data"); $stmt = sqlsrv_query( $conn, $sql, $params); if( $stmt === false ) { die( print_r( sqlsrv_errors(), true)); } Source: https://ru.stackoverflow.com/questions/598537/
All Articles