Jump to content

Recommended Posts

Hi... I never used MySQL database that much needless to say MSSQL so, bear with me.

I have this code, and it's not working.. can anyone see anything wrong with it ??

I am not getting any errors, my page is blank and my source view is empty with standard html tags.

[code]
<?php

$myServer = "888.88.88.888";
$myUser = "888888";
$myPass = "8888888";
$myDB = "888888";

$dbhandle = mssql_connect($myServer, $myUser, $myPass)
  //select a database to work with
$selected = mssql_select_db($myDB, $dbhandle)
or die("Couldn't open database $myDB");

//declare the SQL statement that will query the database
$query = "SELECT CartID FROM WSTOrders;";

$selected = mssql_query($query);


$numRows = mssql_num_rows($selected);
echo "<h1>" . $numRows . " Row" . ($numRows == 1 ? "" : "s") . " Returned </h1>";
//display the results
while($row = mssql_fetch_array($selected))
{
  echo $row["CartID"] . "";
}


?>

[/code]


Any and much help appreciated..
Link to comment
https://forums.phpfreaks.com/topic/35607-new-to-mssql-under-php-help/
Share on other sites

This should do it

<?php

$myServer = "888.88.88.888";
$myUser = "888888";
$myPass = "8888888";
$myDB = "888888";

// [color=red]$dbhandle = mssql_connect($myServer, $myUser, $myPass)  - This is where the error is. Missing semi-colon at end of line.[/color]
$dbhandle = mssql_connect($myServer, $myUser, $myPass);
  //select a database to work with
$selected = mssql_select_db("$myDB", $dbhandle)
or die("Couldn't open database $myDB");

//declare the SQL statement that will query the database
$query = "SELECT CartID FROM WSTOrders;";

$selected = mssql_query($query);
$numRows = mssql_num_rows($selected);
echo "<h1>" . $numRows . " Row" . ($numRows == 1 ? "" : "s") . " Returned </h1>";

//display the results
while($row = mssql_fetch_array($selected))
{
  echo $row["CartID"] . "<br />";
}


?>
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.