473,549 Members | 2,723 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Function does not (appear to) return resource correctly

This function:

function queryDataConnec tion($query) {
return mysql_query($qu ery) or die("Oops");
}

doesn't seem to properly return the result set, since this script:

$resultSet = queryDataConnec tion("select * from articles where
id=$id");
if (mysql_num_rows ($resultSet) == 1) {
$result = mysql_fetch_arr ay($resultSet);
} else {
$result = FALSE;
}

gives the following warning:

Warning: mysql_num_rows( ): supplied argument is not a valid MySQL
result resource.

Simply replacing the call to queryDataConnec tion() with the equivalent
(?) call to mysql_query() makes the script work properly. So, why
doesn't the function work? Is there something funny about resources
that isn't covered in the manual?

Thanks in advance,

-- Craig Putnam
Jul 16 '05 #1
0 1917

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1381
by: Michael Klatt | last post by:
I have a resource handle class (call it ResourceHandle) that works like std::auto_ptr to automatically manage resource pointers from a C API (call them T*): class ResourceHandle { public : ResourceHandle(T* ptr) { /* take ownership of T* */ } ~ResourceHandle() { /* release T* resource */ } };
38
2742
by: Lasse Vågsæther Karlsen | last post by:
After working through a fair number of the challenges at www.mathschallenge.net, I noticed that some long-running functions can be helped *a lot* by caching their function results and retrieving from cache instead of calculating again. This means that often I can use a natural recursive implementation instead of unwinding the recursive calls...
6
1408
by: ash4640 | last post by:
1.Guys how do i write a function similar to the strcmp() in the librar like some xstrcmp(). 2. How do i write another function eg x() which compares two strings const char *string, const char *strSearch ie *string="Hai hello" *strSearch="ai" I have to search for ai in the string "Hai Hello" and then return "a Hello" if found or return NULL...
9
1903
by: Grumble | last post by:
Hello everyone, I've come across some strange code. Here it is, stripped down: int main(void) { int *foo; int *bar(); foo = bar(0); return 0;
6
7595
by: karthi | last post by:
hi, I need user defined function that converts string to float in c. since the library function atof and strtod occupies large space in my processor memory I can't use it in my code. regards, Karthi
3
3633
by: Beta What | last post by:
Hello, I have a question about casting a function pointer. Say I want to make a generic module (say some ADT implementation) that requires a function pointer from the 'actual/other modules' that takes arguments of type (void *) because the ADT must be able to deal with any type of data. In my actual code, I will code the function to take...
32
3309
by: chris.fairles | last post by:
Just want an opinion. I have an algorithm that needs to run as fast as possible, in fact. Its already too slow. I've done as much algorithmic changes as I can to reduce the amount of code, so now I'm turning to micro-optimizations. One function that gets run a bazillion times is the pow() function from math.h. However I've realized probably...
9
1752
by: noor.fatma | last post by:
Hi all, if I declare a function as one returning int and do not return anything from the function ,what will it return? for example. the following function returns the value of sum correctly. int sum1(int a,int b) {
21
479
by: coolguyaroundyou | last post by:
See the below code: void func(int x) { printf("%d",x); } int main() { int j=0;
0
7520
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...
0
7957
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...
1
7470
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7809
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...
0
6043
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5088
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3500
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...
0
3481
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
763
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...

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.