473,732 Members | 1,924 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Argument is not a valid MS SQL-result resource

3 New Member
I am using a text box to search database for a reference number, the search is working ok but i am getting this error when i load the page for the first time:

Warning: mssql_fetch_obj ect(): supplied argument is not a valid MS SQL-result resource in C:\Documents . . . on line 167

When i do a search i get the expected results and the error disappears

here is my code:
Expand|Select|Wrap|Line Numbers
  1. <form id="refsearch" name="searchRef" method="post">
  2.   <table>
  3.     <tr>
  4.       <td>Enter Call Ref</td>
  5.       <td><input name="searchref" type="text" class="textfield" id="searchref" /></td>
  6.     </tr>
  7.     <tr>
  8.       <td><input type="submit" name="search" value="Search" /></td>
  9.     </tr>
  10.  
  11. <?php
  12.     $reference = $_POST['searchref'];
  13.     $query = "SELECT AmberCatRequestId ";
  14.     $query.= "FROM Customer_Calls ";
  15.     $query.= "WHERE CustomerCallId = $reference";
  16.  
  17.     $result = mssql_query($query);
  18.     if($row = mssql_fetch_object($result))
  19.     {
  20.         $ref = $row->AmberCatRequestId;
  21.     }
  22.  
  23. ?>
  24.     <tr>
  25.     <td><h4><br />AmberCat Request:&nbsp;</h1></td>
  26.     <td><h1><br /><?echo $ref;?></h4></td>
  27.     </tr>
  28.   </table>
  29. </form>
  30.  
how do i stopped the error from appearing when the page is first loaded?
Mar 8 '10 #1
4 5856
johny10151981
1,059 Top Contributor
Can you please post your code in code format.

Expand|Select|Wrap|Line Numbers
  1. $reference = $_POST['searchref'];
  2. $query = "SELECT AmberCatRequestId ";
  3. $query.= "FROM Customer_Calls ";
  4. $query.= "WHERE CustomerCallId = $reference";
  5.  
  6. $result = mssql_query($query);
  7. if($row = mssql_fetch_object($result))
  8. {
  9. $ref = $row->AmberCatRequestId;
  10. }
  11.  
  12. ?>
your PHP code start with the line
$_POST['searchref']
but when you load your page for the first time there is no $_POST['searchref'] exists

take a closer look at isset() function. you would definitely get an error. so what you can do is first make sure
whether $_POST['searchref'] exists. If it exists perform rest of the operation otherwise skip it.

Regards,
Johny
Mar 8 '10 #2
jpr0325
4 New Member
First time when u load a page there won't be value set for $_POST['searchref'] so you query will be worng..

Check condition if $_POST['searchref'] is not equal to null and then execute the query part.

Hope this will help u...:)
Mar 8 '10 #3
Dormilich
8,658 Recognized Expert Moderator Expert
see also PHP - Common Newbie Pitfalls, 2: Supplied argument is not a valid MySQL result
Mar 8 '10 #4
JamieC
3 New Member
thanks jpr0325, this is exactly what i was looking for
Mar 9 '10 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

9
5810
by: subdhar | last post by:
I'm getting following error in asp.net application.I search the web and couldn't find error like this can any one help me in trouble with this error Specified argument was out of the range of valid values. Parameter name: U Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
69
16880
by: markarichman | last post by:
Why is Firefox complaining with this error: ------------------------------------------------------------ missing ) after argument list setTimeout('breakOut',5000); ------------------------------------------------------------ Here is the HTML that I'm producing:
1
17044
by: Timbo | last post by:
Hi all, This is my first message here so i'll try and include all the information that will help you help me out, if possible. Basically I am using C# in ASP.NET 2.0 and have a Repeater control in my aspx page with two image buttons, one for an edit command, another a delete command. Here is a cut down code fragment. ...
0
2031
by: Subhankar | last post by:
Hi, I am trying to open a MS Project residing in a MS SQL Server. I have the following code for the FileOpen: projectApp.FileOpen("<ChouOister>\\Test Project 2", false, 0, null, null, null, null, "e454581", "", null, null, PjPoolOpen.pjPoolReadWrite, null, null, null, null); I am getting the error 'The argument value is not valid.'. Can somebody
2
2175
by: Nathan Sokalski | last post by:
I have a DataList in which the ItemTemplate contains two Button controls that use EventBubbling. When I click either of them I receive the following error: Server Error in '/' Application. -------------------------------------------------------------------------------- Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/in configuration or <%@ Page EnableEventValidation="true"...
7
8131
by: bowlderster | last post by:
Hello,all. I want to get the array size in a function, and the array is an argument of the function. I try the following code. /*************************************** */ #include<stdio.h> #include<stdlib.h> #include<math.h>
3
1609
by: linarin | last post by:
#include <iostream> using namespace std; typedef bool (*CallableFunction)(int argc,char* argv); void DefineMyFunction(const char* name,CallableFunction func){ //here do the define action. } template<typename R,typename A,R (*pFunc)(A)>
2
3087
by: Chapi | last post by:
hi, i'm having problems with a datagrid paging. it's populates fine, but when i click the paging button appears this error:"Specified argument was out of the range of valid values.Parameter name: index" I paste the code here in case someone can help me. Sub paginaNueva(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridPageChangedEventArgs) DataGrid1.CurrentPageIndex = e.NewPageIndex
7
11058
by: mirandacascade | last post by:
The questions are toward the bottom of this post. Situation is this: 1) Access 97 2) Multi-user appplication 3) SQL Server 2000 4) Sporadically (i.e. less than 1% of the time) encounter the following error: 3218 Couldn't update; currently locked
9
4562
by: 200dogz | last post by:
Hi guys, I want to have a button which opens up a new window when pressed. <asp:Button ID="Button1" runat="server" Text="Open new window" /> ... Button1.Attributes.Add("OnClick",
0
8944
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9445
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9306
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9180
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6733
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4548
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4805
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3259
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2177
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.