Jump to content

MS SQL Query Failure


uchacker11

Recommended Posts

I am trying to run a Select statement that will return an int to then be fed into an insert statement but I keep getting the following error:

 

Warning: mssql_query() [function.mssql-query]: message: Conversion failed when converting the varchar value 'Resource id #3' to data type int. (severity 16) in C:\www\Rentals\Add\InsertRenter.php on line 33

 

$server = 'HomeServer';

$link = mssql_connect($server, 'username', 'password');

if(!$link)
{
    die('Failure to connect to Server');
}

$db = mssql_select_db('Rentals', $link) or die('Database Connection Failed');

$Last=$_POST['RenterLast'];
$First=$_POST['RenterFirst'];
$Temp=$_POST['RenterHouse'];
$Sec8ID=$_POST['RenterSec8ID'];
$MoveInDate=$_POST['RenterMoveInDate'];
$MoveOutDate=$_POST['RenterMoveOutDate'];
$Phone=$_POST['RenterPhone'];
$Deposit=$_POST['RenterDeposit'];
$Sec8Payment=$_POST['RenterSec8Payment'];
$RenterPayment=$_POST['RenterRenterPayment'];
$Comments=$_POST['RenterComments'];

$HouseIDLookup = "SELECT HouseID from Houses WHERE Alias LIKE '$Temp'";

$HouseID = mssql_query($HouseIDLookup, $link, 0);

$query= "INSERT INTO Renters ([LastName], [FirstName], [HouseID], [section8ID], [MoveInDate], [MoveOutDate], [Phone], [Deposit], [section8PaymentAmt], [RenterPaymentAmt], [Comments]) VALUES ('$Last', '$First', '$HouseID', '$Sec8ID', '$MoveInDate', '$MoveOutDate', '$Phone', '$Deposit', '$Sec8Payment', '$RenterPayment', '$Comments')";

$insert = mssql_query($query, $link, 0);
?>

 

Any help would be greatly appreciated!

Link to comment
https://forums.phpfreaks.com/topic/179012-ms-sql-query-failure/
Share on other sites

Thanks for the help but now i get a similar error:

 

Warning: mssql_query() [function.mssql-query]: message: Conversion failed when converting the varchar value 'Array' to data type int. (severity 16) in C:\www\Rentals\Add\InsertRenter.php on line 34

 

I added the line: $House = mssql_fetch_assoc($HouseID);

 

Did i mess up syntax or something

Link to comment
https://forums.phpfreaks.com/topic/179012-ms-sql-query-failure/#findComment-944468
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.