Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #14791 > unrolled thread

Error Connectivity with MS Sql-Server 2012

Started byjalaf28@gmail.com
First post2015-01-01 20:19 -0800
Last post2015-01-05 08:31 -0500
Articles 6 — 2 participants

Back to article view | Back to comp.lang.php


Contents

  Error Connectivity with MS Sql-Server 2012 jalaf28@gmail.com - 2015-01-01 20:19 -0800
    Re: Error Connectivity with MS Sql-Server 2012 Jerry Stuckle <jstucklex@attglobal.net> - 2015-01-01 23:28 -0500
      Re: Error Connectivity with MS Sql-Server 2012 jalaf28@gmail.com - 2015-01-01 21:07 -0800
        Re: Error Connectivity with MS Sql-Server 2012 Jerry Stuckle <jstucklex@attglobal.net> - 2015-01-02 08:39 -0500
          Re: Error Connectivity with MS Sql-Server 2012 jalaf28@gmail.com - 2015-01-05 00:49 -0800
            Re: Error Connectivity with MS Sql-Server 2012 Jerry Stuckle <jstucklex@attglobal.net> - 2015-01-05 08:31 -0500

#14791 — Error Connectivity with MS Sql-Server 2012

Fromjalaf28@gmail.com
Date2015-01-01 20:19 -0800
SubjectError Connectivity with MS Sql-Server 2012
Message-ID<2d5611ac-6526-4082-bef7-f92c23018243@googlegroups.com>
Hello Group,

i have  facing a problem with the php connectivity to the Ms Sql-server. i worked on a project for my lab its works fine with My-Sql(database) but now moved to My-sql server(database) to MS-Sql server 2012 (database) and getting an error while fetching the record from table.

Error :
"Array ( [0] => Array ( [0] => 42S02 [SQLSTATE] => 42S02 [1] => 208 [code] => 208 [2] => [Microsoft][SQL Server Native Client 11.0][SQL Server]Invalid object name 'usr'. [message] => [Microsoft][SQL Server Native Client 11.0][SQL Server]Invalid object name 'usr'. ) )"

if i am using the system table then its works but user-define table are generating error.

here is the code

file name : "conn.php"

[Code]


<?php
$server="xxx-server\SQLEXPRESS";

$conninfo=array("Database"=>"master");

$conn=sqlsrv_connect($server,$conninfo);

if($conn)
{
    echo("Connection Establish. <br />");
}
else
{
        echo "Could not established the connection <br />";
	die(printr(sqlsrv_errors(),true));
}

$tmt="select * from usr";

$stmt=sqlsrv_query($conn,$tmt);

if($stmt)
{
	echo "Statement Executed";
}
else
{
	die(print_r(sqlsrv_errors(),true));
}

error_reporting(E_ALL);


echo "<table border='1'>";

while( $row= sqlsrv_fetch_array($stmt))
{
	echo "<tr><td>". $row[0]."</td>";
	echo "<td>".$row[1]."</td></tr>";
	
}
echo "</table>";
sqlsrv_free_stmt($stmt);
sqlsrv_close($conn);
?>    


What i am doing wrong here please help me.  


Thanks

[toc] | [next] | [standalone]


#14792

FromJerry Stuckle <jstucklex@attglobal.net>
Date2015-01-01 23:28 -0500
Message-ID<m856pg$mmj$1@dont-email.me>
In reply to#14791
On 1/1/2015 11:19 PM, jalaf28@gmail.com wrote:
> Hello Group,
> 
> i have  facing a problem with the php connectivity to the Ms Sql-server. i worked on a project for my lab its works fine with My-Sql(database) but now moved to My-sql server(database) to MS-Sql server 2012 (database) and getting an error while fetching the record from table.
> 
> Error :
> "Array ( [0] => Array ( [0] => 42S02 [SQLSTATE] => 42S02 [1] => 208 [code] => 208 [2] => [Microsoft][SQL Server Native Client 11.0][SQL Server]Invalid object name 'usr'. [message] => [Microsoft][SQL Server Native Client 11.0][SQL Server]Invalid object name 'usr'. ) )"
> 
> if i am using the system table then its works but user-define table are generating error.
> 
> here is the code
> 
> file name : "conn.php"
> 
> [Code]
> 
> 
> <?php
> $server="xxx-server\SQLEXPRESS";
> 
> $conninfo=array("Database"=>"master");
> 
> $conn=sqlsrv_connect($server,$conninfo);
> 
> if($conn)
> {
>     echo("Connection Establish. <br />");
> }
> else
> {
>         echo "Could not established the connection <br />";
> 	die(printr(sqlsrv_errors(),true));
> }
> 
> $tmt="select * from usr";
> 
> $stmt=sqlsrv_query($conn,$tmt);
> 
> if($stmt)
> {
> 	echo "Statement Executed";
> }
> else
> {
> 	die(print_r(sqlsrv_errors(),true));
> }
> 
> error_reporting(E_ALL);
> 
> 
> echo "<table border='1'>";
> 
> while( $row= sqlsrv_fetch_array($stmt))
> {
> 	echo "<tr><td>". $row[0]."</td>";
> 	echo "<td>".$row[1]."</td></tr>";
> 	
> }
> echo "</table>";
> sqlsrv_free_stmt($stmt);
> sqlsrv_close($conn);
> ?>    
> 
> 
> What i am doing wrong here please help me.  
> 
> 
> Thanks
> 

It's been a while since I've used SQL Server, but I think your problem
is shown by the message "Invalid object name 'usr'.".

Are you sure there is a table or view named "usr" in the "master" database?

BTW - you should never use die() or exit() in a PHP web script on a
production system.  This causes all processing of the page to terminate
immediately, resulting in invalid html.

Rather, test for an error, and if one occurs, branch around all code
which depends on the call succeeding.  You can do this with if()
statements or by throwing an exception.

-- 
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================

[toc] | [prev] | [next] | [standalone]


#14793

Fromjalaf28@gmail.com
Date2015-01-01 21:07 -0800
Message-ID<0116368c-88c4-4077-a0eb-0e5e466e0045@googlegroups.com>
In reply to#14792
On Friday, 2 January 2015 09:59:03 UTC+5:30, Jerry Stuckle  wrote:
> On 1/1/2015 11:19 PM, jalaf28@gmail.com wrote:
> > Hello Group,
> > 
> > i have  facing a problem with the php connectivity to the Ms Sql-server. i worked on a project for my lab its works fine with My-Sql(database) but now moved to My-sql server(database) to MS-Sql server 2012 (database) and getting an error while fetching the record from table.
> > 
> > Error :
> > "Array ( [0] => Array ( [0] => 42S02 [SQLSTATE] => 42S02 [1] => 208 [code] => 208 [2] => [Microsoft][SQL Server Native Client 11.0][SQL Server]Invalid object name 'usr'. [message] => [Microsoft][SQL Server Native Client 11.0][SQL Server]Invalid object name 'usr'. ) )"
> > 
> > if i am using the system table then its works but user-define table are generating error.
> > 
> > here is the code
> > 
> > file name : "conn.php"
> > 
> > [Code]
> > 
> > 
> > <?php
> > $server="xxx-server\SQLEXPRESS";
> > 
> > $conninfo=array("Database"=>"master");
> > 
> > $conn=sqlsrv_connect($server,$conninfo);
> > 
> > if($conn)
> > {
> >     echo("Connection Establish. <br />");
> > }
> > else
> > {
> >         echo "Could not established the connection <br />";
> > 	die(printr(sqlsrv_errors(),true));
> > }
> > 
> > $tmt="select * from usr";
> > 
> > $stmt=sqlsrv_query($conn,$tmt);
> > 
> > if($stmt)
> > {
> > 	echo "Statement Executed";
> > }
> > else
> > {
> > 	die(print_r(sqlsrv_errors(),true));
> > }
> > 
> > error_reporting(E_ALL);
> > 
> > 
> > echo "<table border='1'>";
> > 
> > while( $row= sqlsrv_fetch_array($stmt))
> > {
> > 	echo "<tr><td>". $row[0]."</td>";
> > 	echo "<td>".$row[1]."</td></tr>";
> > 	
> > }
> > echo "</table>";
> > sqlsrv_free_stmt($stmt);
> > sqlsrv_close($conn);
> > ?>    
> > 
> > 
> > What i am doing wrong here please help me.  
> > 
> > 
> > Thanks
> > 
> 
> It's been a while since I've used SQL Server, but I think your problem
> is shown by the message "Invalid object name 'usr'.".
> 
> Are you sure there is a table or view named "usr" in the "master" database?
> 
> BTW - you should never use die() or exit() in a PHP web script on a
> production system.  This causes all processing of the page to terminate
> immediately, resulting in invalid html.
> 
> Rather, test for an error, and if one occurs, branch around all code
> which depends on the call succeeding.  You can do this with if()
> statements or by throwing an exception.
> 
> -- 
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> jstucklex@attglobal.net
> ==================

Thanks jerry for reply i create table"usr" in the  master database and it generate error if i used master database default table then it works fine i am bit confused here.

[toc] | [prev] | [next] | [standalone]


#14794

FromJerry Stuckle <jstucklex@attglobal.net>
Date2015-01-02 08:39 -0500
Message-ID<m8670u$hnt$1@dont-email.me>
In reply to#14793
On 1/2/2015 12:07 AM, jalaf28@gmail.com wrote:
> On Friday, 2 January 2015 09:59:03 UTC+5:30, Jerry Stuckle  wrote:
>> On 1/1/2015 11:19 PM, jalaf28@gmail.com wrote:
>>> Hello Group,
>>>
>>> i have  facing a problem with the php connectivity to the Ms Sql-server. i worked on a project for my lab its works fine with My-Sql(database) but now moved to My-sql server(database) to MS-Sql server 2012 (database) and getting an error while fetching the record from table.
>>>
>>> Error :
>>> "Array ( [0] => Array ( [0] => 42S02 [SQLSTATE] => 42S02 [1] => 208 [code] => 208 [2] => [Microsoft][SQL Server Native Client 11.0][SQL Server]Invalid object name 'usr'. [message] => [Microsoft][SQL Server Native Client 11.0][SQL Server]Invalid object name 'usr'. ) )"
>>>
>>> if i am using the system table then its works but user-define table are generating error.
>>>
>>> here is the code
>>>
>>> file name : "conn.php"
>>>
>>> [Code]
>>>
>>>
>>> <?php
>>> $server="xxx-server\SQLEXPRESS";
>>>
>>> $conninfo=array("Database"=>"master");
>>>
>>> $conn=sqlsrv_connect($server,$conninfo);
>>>
>>> if($conn)
>>> {
>>>     echo("Connection Establish. <br />");
>>> }
>>> else
>>> {
>>>         echo "Could not established the connection <br />";
>>> 	die(printr(sqlsrv_errors(),true));
>>> }
>>>
>>> $tmt="select * from usr";
>>>
>>> $stmt=sqlsrv_query($conn,$tmt);
>>>
>>> if($stmt)
>>> {
>>> 	echo "Statement Executed";
>>> }
>>> else
>>> {
>>> 	die(print_r(sqlsrv_errors(),true));
>>> }
>>>
>>> error_reporting(E_ALL);
>>>
>>>
>>> echo "<table border='1'>";
>>>
>>> while( $row= sqlsrv_fetch_array($stmt))
>>> {
>>> 	echo "<tr><td>". $row[0]."</td>";
>>> 	echo "<td>".$row[1]."</td></tr>";
>>> 	
>>> }
>>> echo "</table>";
>>> sqlsrv_free_stmt($stmt);
>>> sqlsrv_close($conn);
>>> ?>    
>>>
>>>
>>> What i am doing wrong here please help me.  
>>>
>>>
>>> Thanks
>>>
>>
>> It's been a while since I've used SQL Server, but I think your problem
>> is shown by the message "Invalid object name 'usr'.".
>>
>> Are you sure there is a table or view named "usr" in the "master" database?
>>
>> BTW - you should never use die() or exit() in a PHP web script on a
>> production system.  This causes all processing of the page to terminate
>> immediately, resulting in invalid html.
>>
>> Rather, test for an error, and if one occurs, branch around all code
>> which depends on the call succeeding.  You can do this with if()
>> statements or by throwing an exception.
>>

> 
> Thanks jerry for reply i create table"usr" in the  master database and it generate error if i used master database default table then it works fine i am bit confused here.
> 

How did you create the table?  Did you verify it was created correctly?
 Have you looked at the database definition?

Sorry for being repetitive here, but the message indicates the table
does not exist.

-- 
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================

[toc] | [prev] | [next] | [standalone]


#14807

Fromjalaf28@gmail.com
Date2015-01-05 00:49 -0800
Message-ID<994a9c62-b36b-475f-aadc-7a64249a3094@googlegroups.com>
In reply to#14794
On Friday, 2 January 2015 19:09:12 UTC+5:30, Jerry Stuckle  wrote:
> On 1/2/2015 12:07 AM, jalaf28@gmail.com wrote:
> > On Friday, 2 January 2015 09:59:03 UTC+5:30, Jerry Stuckle  wrote:
> >> On 1/1/2015 11:19 PM, jalaf28@gmail.com wrote:
> >>> Hello Group,
> >>>
> >>> i have  facing a problem with the php connectivity to the Ms Sql-server. i worked on a project for my lab its works fine with My-Sql(database) but now moved to My-sql server(database) to MS-Sql server 2012 (database) and getting an error while fetching the record from table.
> >>>
> >>> Error :
> >>> "Array ( [0] => Array ( [0] => 42S02 [SQLSTATE] => 42S02 [1] => 208 [code] => 208 [2] => [Microsoft][SQL Server Native Client 11.0][SQL Server]Invalid object name 'usr'. [message] => [Microsoft][SQL Server Native Client 11.0][SQL Server]Invalid object name 'usr'. ) )"
> >>>
> >>> if i am using the system table then its works but user-define table are generating error.
> >>>
> >>> here is the code
> >>>
> >>> file name : "conn.php"
> >>>
> >>> [Code]
> >>>
> >>>
> >>> <?php
> >>> $server="xxx-server\SQLEXPRESS";
> >>>
> >>> $conninfo=array("Database"=>"master");
> >>>
> >>> $conn=sqlsrv_connect($server,$conninfo);
> >>>
> >>> if($conn)
> >>> {
> >>>     echo("Connection Establish. <br />");
> >>> }
> >>> else
> >>> {
> >>>         echo "Could not established the connection <br />";
> >>> 	die(printr(sqlsrv_errors(),true));
> >>> }
> >>>
> >>> $tmt="select * from usr";
> >>>
> >>> $stmt=sqlsrv_query($conn,$tmt);
> >>>
> >>> if($stmt)
> >>> {
> >>> 	echo "Statement Executed";
> >>> }
> >>> else
> >>> {
> >>> 	die(print_r(sqlsrv_errors(),true));
> >>> }
> >>>
> >>> error_reporting(E_ALL);
> >>>
> >>>
> >>> echo "<table border='1'>";
> >>>
> >>> while( $row= sqlsrv_fetch_array($stmt))
> >>> {
> >>> 	echo "<tr><td>". $row[0]."</td>";
> >>> 	echo "<td>".$row[1]."</td></tr>";
> >>> 	
> >>> }
> >>> echo "</table>";
> >>> sqlsrv_free_stmt($stmt);
> >>> sqlsrv_close($conn);
> >>> ?>    
> >>>
> >>>
> >>> What i am doing wrong here please help me.  
> >>>
> >>>
> >>> Thanks
> >>>
> >>
> >> It's been a while since I've used SQL Server, but I think your problem
> >> is shown by the message "Invalid object name 'usr'.".
> >>
> >> Are you sure there is a table or view named "usr" in the "master" database?
> >>
> >> BTW - you should never use die() or exit() in a PHP web script on a
> >> production system.  This causes all processing of the page to terminate
> >> immediately, resulting in invalid html.
> >>
> >> Rather, test for an error, and if one occurs, branch around all code
> >> which depends on the call succeeding.  You can do this with if()
> >> statements or by throwing an exception.
> >>
> 
> > 
> > Thanks jerry for reply i create table"usr" in the  master database and it generate error if i used master database default table then it works fine i am bit confused here.
> > 
> 
> How did you create the table?  Did you verify it was created correctly?
>  Have you looked at the database definition?
> 
> Sorry for being repetitive here, but the message indicates the table
> does not exist.
> 
> -- 
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> jstucklex@attglobal.net
> ==================

i created table according to the Database if i used system table then works fine 

[toc] | [prev] | [next] | [standalone]


#14808

FromJerry Stuckle <jstucklex@attglobal.net>
Date2015-01-05 08:31 -0500
Message-ID<m8e3m7$kih$1@dont-email.me>
In reply to#14807
On 1/5/2015 3:49 AM, jalaf28@gmail.com wrote:
> On Friday, 2 January 2015 19:09:12 UTC+5:30, Jerry Stuckle  wrote:
>> On 1/2/2015 12:07 AM, jalaf28@gmail.com wrote:
>>> On Friday, 2 January 2015 09:59:03 UTC+5:30, Jerry Stuckle  wrote:
>>>> On 1/1/2015 11:19 PM, jalaf28@gmail.com wrote:
>>>>> Hello Group,
>>>>>
>>>>> i have  facing a problem with the php connectivity to the Ms Sql-server. i worked on a project for my lab its works fine with My-Sql(database) but now moved to My-sql server(database) to MS-Sql server 2012 (database) and getting an error while fetching the record from table.
>>>>>
>>>>> Error :
>>>>> "Array ( [0] => Array ( [0] => 42S02 [SQLSTATE] => 42S02 [1] => 208 [code] => 208 [2] => [Microsoft][SQL Server Native Client 11.0][SQL Server]Invalid object name 'usr'. [message] => [Microsoft][SQL Server Native Client 11.0][SQL Server]Invalid object name 'usr'. ) )"
>>>>>
>>>>> if i am using the system table then its works but user-define table are generating error.
>>>>>
>>>>> here is the code
>>>>>
>>>>> file name : "conn.php"
>>>>>
>>>>> [Code]
>>>>>
>>>>>
>>>>> <?php
>>>>> $server="xxx-server\SQLEXPRESS";
>>>>>
>>>>> $conninfo=array("Database"=>"master");
>>>>>
>>>>> $conn=sqlsrv_connect($server,$conninfo);
>>>>>
>>>>> if($conn)
>>>>> {
>>>>>     echo("Connection Establish. <br />");
>>>>> }
>>>>> else
>>>>> {
>>>>>         echo "Could not established the connection <br />";
>>>>> 	die(printr(sqlsrv_errors(),true));
>>>>> }
>>>>>
>>>>> $tmt="select * from usr";
>>>>>
>>>>> $stmt=sqlsrv_query($conn,$tmt);
>>>>>
>>>>> if($stmt)
>>>>> {
>>>>> 	echo "Statement Executed";
>>>>> }
>>>>> else
>>>>> {
>>>>> 	die(print_r(sqlsrv_errors(),true));
>>>>> }
>>>>>
>>>>> error_reporting(E_ALL);
>>>>>
>>>>>
>>>>> echo "<table border='1'>";
>>>>>
>>>>> while( $row= sqlsrv_fetch_array($stmt))
>>>>> {
>>>>> 	echo "<tr><td>". $row[0]."</td>";
>>>>> 	echo "<td>".$row[1]."</td></tr>";
>>>>> 	
>>>>> }
>>>>> echo "</table>";
>>>>> sqlsrv_free_stmt($stmt);
>>>>> sqlsrv_close($conn);
>>>>> ?>    
>>>>>
>>>>>
>>>>> What i am doing wrong here please help me.  
>>>>>
>>>>>
>>>>> Thanks
>>>>>
>>>>
>>>> It's been a while since I've used SQL Server, but I think your problem
>>>> is shown by the message "Invalid object name 'usr'.".
>>>>
>>>> Are you sure there is a table or view named "usr" in the "master" database?
>>>>
>>>> BTW - you should never use die() or exit() in a PHP web script on a
>>>> production system.  This causes all processing of the page to terminate
>>>> immediately, resulting in invalid html.
>>>>
>>>> Rather, test for an error, and if one occurs, branch around all code
>>>> which depends on the call succeeding.  You can do this with if()
>>>> statements or by throwing an exception.
>>>>
>>
>>>
>>> Thanks jerry for reply i create table"usr" in the  master database and it generate error if i used master database default table then it works fine i am bit confused here.
>>>
>>
>> How did you create the table?  Did you verify it was created correctly?
>>  Have you looked at the database definition?
>>
>> Sorry for being repetitive here, but the message indicates the table
>> does not exist.
>>
> 
> i created table according to the Database if i used system table then works fine 
> 

That doesn't answer the questions.  How did you create the table?
Exactly what statements did you use?  Did you verify it was created
correctly?  If so, how?  Did you look at the database definition?  What
did it show?

We don't have your database in front of us, so you need to answer the
questions.  And these are all questions I would ask myself if I had this
problem.

-- 
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.php


csiph-web