Jump to content

Recommended Posts

I am working on this script to populate a dropdown list from the SQL server express database but each time i run the script i get these errors. I am honestly really new with sqlserv syntax

 

 

[21-Nov-2012 15:54:34 UTC] PHP Warning: sqlsrv_query() expects parameter 1 to be resource, boolean given in line 36

[21-Nov-2012 15:54:34 UTC] PHP Warning: sqlsrv_fetch_array() expects parameter 1 to be resource, boolean given in 37

[21-Nov-2012 15:54:34 UTC] PHP Warning: sqlsrv_free_stmt() expects parameter 1 to be resource, boolean given in 44

 

Here is my script

If anyone is interested:

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" http://www.w3.org/TR/html4/loose.dtd>
<head><title>UG Pipeline Fiedl Data Capture</title></head>
<body>
<?php $serverName = "SQLEXPRESS";
$uid = "sa";
$pwd = "Casa2009";
$databaseName = "UGSPIPELINE";

$connectionInfo = array("UID"=>$uid,
"PWD"=>$pwd,
"Database"=>$databaseName);
/* Connect using SQL Server Authentication. */
$conn = sqlsrv_connect( $serverName, $connectionInfo);
if(!$conn) {
echo "Connection established.<br />";
}else{
echo "Connection could not be established.<br />";
die( print_r(sqlsrv_errors(), true));
}
//$query = "SELECT pipeno,heatno,pipeno2,jointno,from UGSPIPELINE.fieldtally order by fieldtallyID asc";
$query = 'select PIPENO from fieldtally';
$params = array();
$options = array( "Scrollable" => SQLSRV_CURSOR_KEYSET );
$result = sqlsrv_query($conn,$query,$params,$options);
if( $result === false) {
die( print_r( sqlsrv_errors(), true) ); // what appears to be line 26
}
while( $row = sqlsrv_fetch_array( $result, SQLSRV_FETCH_ASSOC)){
echo $row['PIPENO']."<br />";
}
// This function creates dropdowns that can be used in your forms
function dropdown($field_name, $num){
// Creates the Dropdown
echo "<select name=\"".$field_name."\" id=\"".$field_name.$num."\"\n";
echo "<option value=\"\"> --- Select --- </option>\n";
// Chooses which array to use for Dropdown options
global $pipeno_array;
$name_array = ($field_name == 'pipeno') ? $pipeno_array: $y;
// Creates the Dropdown options based off the array above
foreach($name_array as $k){
echo "<option value=\"$k\">$k</option> \n"; }
// Ends the Dropdown
echo "</select>\n";
}
?>

<p></p>
<form action="" method="post">
<table width="800" cellpadding= "10" cellspacing="1" border="2">
<tr align="center" valign="top">
<td align="center" colspan="1" rowspan="1" bgcolor="#00CC00">
<h3>Input Field Tally Information</h3>
Select Wall Thickness:<select name="wthick" id="wthick">
<option value=""> --Select-- </option>
<option value="9.80"> 9.80 </option>
<option value="13.50"> 13.50 </option>
<option value="15.90"> 15.90 </option>
</Select>
Select Pipe No:<?php dropdown('pipeno', 1);?> HeatNo1: <input type="text" name="heatno1" id="heatno1"><br /><br />
PipeNo2: <input type="text" name="pipeno2" id="pipeno2"> HeatNo2: <input type="text" name="heatno2" id="heatno2">DJoint No: <input type="text" name="Djointno"><br /><br />
Input measured Length: <input type="text" name="measuredlength"> Input Serial No: <input type="text" name="serialno"><br><br> Remarks: <input type="text" name="remarks"><br><br>
<input type="Submit" name="submit_1" value="Submit">
</td></tr></table>
</form>
<form action="" method="post">
<table width="800" cellpadding= "10" cellspacing="1" border="2">
<tr align="center" valign="top">
<td align="center" colspan="1" rowspan="1" bgcolor="#FF99FF">
<h3>Input Field Bend Information</h3>
Select Wall Thickness:<select name="wthick1" id="wthick1">
<option value=""> --Select-- </option>
<option value="9.80"> 9.80 </option>
<option value="13.50">13.50 </option>
<option value="15.90"> 15.90 </option>
</select>

Select Pipe No:<?php dropdown('pipeno', 2); ?> HeatNo1: <input type="text" name="heatno1" id="heatno1_2"> <br><br>
PipeNo2: <input type="text" name="pipeno2" id="pipeno2_2"> HeatNo2: <input type="text" name="heatno2" id="heatno2_2"> DJoint No: <input type="text" name="Djointno"> <br><br>
Input Measured Distance: <input type="text" name="measureddistance"> Input Bend Angle: <input type="text" name="benddegree"> <br><br>
Select Bend Type:<select name="bendtype" id="bendtype">
<option value=""> --Select-- </option>
<option value="Combo">Combo</option>
<option value="SAG">SAG</option>
<option value="OB">OB</option>
<option value="SBRT">SBRT</option>
<option value="SBLT">SBLT</option>
<option value="HBLT">HBLT</option>
<option value="HBRT">HBRT</option>
</select>
Remarks: <input type="text" name="remarks">
<input type="Submit" name="submit_2" value="Submit">
</td></tr></table>
</form>
<form action="" method="post">
<table width="800" cellpadding= "10" cellspacing="1" border="2">
<tr align="center" valign="top">
<td align="center" colspan="1" rowspan="1" bgcolor="#99FF33">
<h3>Input App. Tally Information</h3>
Select Wall Thickness:<select name="wthick2" id="wthick2">
<option value=""> --Select-- </option>
<option value="9.80"> 9.80 </option>
<option value="13.50"> 13.50 </option>
<option value="15.90"> 15.90 </option>
</select>
Select Pipe No:<?php dropdown('pipeno', 3); ?> <br><br> Input Tally Type: <input type="text" name="tallytype">
Input Tally Qty: <input type="text" name="qty"> ?><br /><br /> Input Serial No: <input type="text" name="serialno">
RefID: <input type="text" name="referenceid"> ?><br /><br />
<input type="Submit" name="submit_3" value="Submit">
</td></tr></table>
</form>
</body>

Edited by SocialCloud
When I run the script above , this is the error i get now and im just stuck here, i have exhausted all my ideas on how to resolve the SQL server error

 

 

 

Array ( [0] => Array ( [0] => IMSSP [sqlSTATE] => IMSSP [1] => -14
 => -14 [2] => An invalid parameter was passed to sqlsrv_query. [message] => An invalid parameter was passed to sqlsrv_query. ) )

 

Pls can someone help!

Edited by emmy

I removed the other thread you created for this problem.

 

No one asked you to repost your question. Asking you to repost your code, just means to repost your code. It doesn't mean to throw-a-way your existing thread. That just wastes the forum member's time and reduces the chance of anyone helping you.

Edited by PFMaBiSmAd
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.