473,503 Members | 3,866 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

function definition error

I have a function definition error:
Warning: Missing argument 2 for makexcldata(), called on line 123 and
defined in on line 149

"Warning: mysql_fetch_row(): supplied argument is not a valid MySQL
result resource on line 157"

This is the function call on line 123:
$data .= makexcldata($str1);
Line 157 is the first line of the While loop.
On line 149 it ssay the 2nd argument is missing. The $result is a
result of a query earlier in the code. It should be a valid resource.

What I am trying to do is get the field names separated by tabs as a
string for the first row of excel output as the column headers. The
2nd part of the function takes the field data rows and separates with
a tab and new line. I just need to add these two strings together
into one string at the bottom and output it to the function call.

What is wrong?
tia,

-----function--------
function makexcldata($xclfields, $result){
$fields= $xclfields;
for($i=0; $i < sizeof($fields); $i++){
$str1.= ($fields[$i]);
$str1.'\t';
}
$str1.'\n';

while(mysql_fetch_row($result)){
$line = '';
foreach($row as $value) {
if((!isset($value)) OR ($VALUE =="")) {
$value = "\t";
}else {
$value = str_replace('"','""', $value);
$value = '"'.$value.'"'."\t";
}
}
$line .= $value;
$data .= trim($line)."\n";

}
$data = str_replace("\r","",$data);
$str1= $str1 . $data;
return $str1;
}
Sep 12 '08 #1
10 1487
JRough wrote:
I have a function definition error:
Warning: Missing argument 2 for makexcldata(), called on line 123 and
defined in on line 149

"Warning: mysql_fetch_row(): supplied argument is not a valid MySQL
result resource on line 157"

This is the function call on line 123:
$data .= makexcldata($str1);
Line 157 is the first line of the While loop.
On line 149 it ssay the 2nd argument is missing. The $result is a
result of a query earlier in the code. It should be a valid resource.
Which explains the bad $result. You only passed one parameter to the
function. According to the function definition, it requires two.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Sep 12 '08 #2
On Sep 11, 5:40*pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
JRough wrote:
I have a function definition error:
Warning: Missing argument 2 for makexcldata(), called on line 123 and
defined in *on line 149
"Warning: mysql_fetch_row(): supplied argument is not a valid MySQL
result resource *on line 157"
This is the function call on line 123:
$data .= makexcldata($str1);
Line 157 is the first line of the While loop.
On line 149 it ssay the 2nd argument is missing. * The $result is a
result of a query earlier in the code. *It should be a valid resource..

Which explains the bad $result. *You only passed one parameter to the
function. *According to the function definition, it requires two.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================
I passed two parameters to the function $result and xclfields. If you
could explain becuase you didn't really answer my question or I am
missing something. The $result variable has a value and it should
have passed to the function.
Sep 12 '08 #3
On Sep 11, 5:40*pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
JRough wrote:
I have a function definition error:
Warning: Missing argument 2 for makexcldata(), called on line 123 and
defined in *on line 149
"Warning: mysql_fetch_row(): supplied argument is not a valid MySQL
result resource *on line 157"
This is the function call on line 123:

Where exactly do I pass the 2 parameters? I tried to pass the 2nd
parameters by setting $result to $querydata and I got the same
message. Do you need to see the query for $result?

Warning: Missing argument 2 for makexcldata(), called in /home/allrail/
public_html/idle_cars.php on line 123 and defined in /home/allrail/
public_html/idle_cars.php on line 149

Warning: mysql_fetch_row(): supplied argument is not a valid MySQL
result resource in /home/allrail/public_html/idle_cars.php on line 15

thanks,
---changed function-----
function makexcldata($xclfields, $result){
$result = $querydata;
$fields= $xclfields;
for($i=0; $i < sizeof($fields); $i++){
$str1.= ($fields[$i]);
$str1.'\t';
}
$str1.'\n';

while(mysql_fetch_row($querydata)){
$line = '';
foreach($row as $value) {
if((!isset($value)) OR ($VALUE =="")) {
$value = "\t";
}else {
$value = str_replace('"','""', $value);
$value = '"'.$value.'"'."\t";
}
}
$line .= $value;
$data .= trim($line)."\n";

}
$data = str_replace("\r","",$data);
$str1= $str1 . $data;
return $str1;
}
Sep 12 '08 #4
JRough wrote:
On Sep 11, 5:40 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
>JRough wrote:
>>I have a function definition error:
Warning: Missing argument 2 for makexcldata(), called on line 123 and
defined in on line 149
"Warning: mysql_fetch_row(): supplied argument is not a valid MySQL
result resource on line 157"
This is the function call on line 123:
$data .= makexcldata($str1);
Line 157 is the first line of the While loop.
On line 149 it ssay the 2nd argument is missing. The $result is a
result of a query earlier in the code. It should be a valid resource.
Which explains the bad $result. You only passed one parameter to the
function. According to the function definition, it requires two.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================

I passed two parameters to the function $result and xclfields. If you
could explain becuase you didn't really answer my question or I am
missing something. The $result variable has a value and it should
have passed to the function.
You passed it one value - $str1.

You seem to be missing some very important basic concepts in PHP. You
really need to get a book on PHP programming and study.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Sep 12 '08 #5
JRough wrote:
On Sep 11, 5:40 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
>JRough wrote:
>>I have a function definition error:
Warning: Missing argument 2 for makexcldata(), called on line 123 and
defined in on line 149
"Warning: mysql_fetch_row(): supplied argument is not a valid MySQL
result resource on line 157"
This is the function call on line 123:


Where exactly do I pass the 2 parameters? I tried to pass the 2nd
parameters by setting $result to $querydata and I got the same
message. Do you need to see the query for $result?

Warning: Missing argument 2 for makexcldata(), called in /home/allrail/
public_html/idle_cars.php on line 123 and defined in /home/allrail/
public_html/idle_cars.php on line 149

Warning: mysql_fetch_row(): supplied argument is not a valid MySQL
result resource in /home/allrail/public_html/idle_cars.php on line 15

thanks,
---changed function-----
function makexcldata($xclfields, $result){
$result = $querydata;
$fields= $xclfields;
for($i=0; $i < sizeof($fields); $i++){
$str1.= ($fields[$i]);
$str1.'\t';
}
$str1.'\n';

while(mysql_fetch_row($querydata)){
$line = '';
foreach($row as $value) {
if((!isset($value)) OR ($VALUE =="")) {
$value = "\t";
}else {
$value = str_replace('"','""', $value);
$value = '"'.$value.'"'."\t";
}
}
$line .= $value;
$data .= trim($line)."\n";

}
$data = str_replace("\r","",$data);
$str1= $str1 . $data;
return $str1;
}
OK Functions 101 in session.

If you create a function:

function myFunction($arg1, $arg2) {
//Code
}

Then you need to call it with BOTH arguments:

myFunction(value1, value2);
Now your function:
function makexcldata($xclfields, $result)

2 parameters...

$xclfield = #1
$result = #2

Now you call your function:

$data .= makexcldata($str1);

$str1 = #1.

Where is #2?

If you listen to the advice Jerry gave you, he answered your question 100%.

Scotty
Sep 12 '08 #6
On Sep 11, 8:18*pm, FutureShock <futuresh...@att.netwrote:
JRough wrote:
On Sep 11, 5:40 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
JRough wrote:
I have a function definition error:
Warning: Missing argument 2 for makexcldata(), called on line 123 and
defined in *on line 149
"Warning: mysql_fetch_row(): supplied argument is not a valid MySQL
result resource *on line 157"
This is the function call on line 123:
Where exactly do I *pass the 2 parameters? *I tried to pass the 2nd
parameters *by setting $result to $querydata and I got the same
message. *Do you need to see the query for $result?
Warning: Missing argument 2 for makexcldata(), called in /home/allrail/
public_html/idle_cars.php on line 123 and defined in /home/allrail/
public_html/idle_cars.php on line 149
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL
result resource in /home/allrail/public_html/idle_cars.php on line 15
thanks,
---changed function-----
function makexcldata($xclfields, $result){
* * * * $result = $querydata;
* *$fields= $xclfields;
* * * * * *for($i=0; $i < sizeof($fields); $i++){
* * * * * * * * * *$str1.= ($fields[$i]);
* * * * * * * * * *$str1.'\t';
* * * * * * * * * *}
* *$str1.'\n';
* *while(mysql_fetch_row($querydata)){
* * * * * *$line = '';
* * * * * *foreach($row as $value) {
* * * * * * * * * *if((!isset($value)) OR ($VALUE =="")) {
* * * * * * * * * * * * * *$value = "\t";
* * * * * * * * * *}else {
* * * * * * * * * * * * * *$value = str_replace('"','""', $value);
* * * * * * * * * * * * * *$value = '"'.$value.'"'."\t";
* * * * * * * * * *}
* * * * * *}
* *$line .= $value;
* *$data .= trim($line)."\n";
* *}
$data = str_replace("\r","",$data);
$str1= $str1 . $data;
return $str1;
}

OK Functions 101 in session.

If you create a function:

function myFunction($arg1, $arg2) {
* * * * //Code

}

Then you need to call it with BOTH arguments:

myFunction(value1, value2);

Now your function:
function makexcldata($xclfields, $result)

2 parameters...

$xclfield *= #1
$result = #2

Now you call your function:

$data .= makexcldata($str1);

$str1 = #1.

Where is #2?

If you listen to the advice Jerry gave you, he answered your question 100%.

Scotty
I did call string2 I just didn't know you wanted that for the
function.
I called both of them.

$data= makexclheader($str);
$data .= makexcldata($str1);
Sep 12 '08 #7
On Sep 11, 8:18*pm, FutureShock <futuresh...@att.netwrote:
JRough wrote:
On Sep 11, 5:40 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
JRough wrote:
I have a function definition error:
Warning: Missing argument 2 for makexcldata(), called on line 123 and
defined in *on line 149
"Warning: mysql_fetch_row(): supplied argument is not a valid MySQL
result resource *on line 157"
This is the function call on line 123:
Where exactly do I *pass the 2 parameters? *I tried to pass the 2nd
parameters *by setting $result to $querydata and I got the same
message. *Do you need to see the query for $result?
Warning: Missing argument 2 for makexcldata(), called in /home/allrail/
public_html/idle_cars.php on line 123 and defined in /home/allrail/
public_html/idle_cars.php on line 149
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL
result resource in /home/allrail/public_html/idle_cars.php on line 15
thanks,
---changed function-----
function makexcldata($xclfields, $result){
* * * * $result = $querydata;
* *$fields= $xclfields;
* * * * * *for($i=0; $i < sizeof($fields); $i++){
* * * * * * * * * *$str1.= ($fields[$i]);
* * * * * * * * * *$str1.'\t';
* * * * * * * * * *}
* *$str1.'\n';
* *while(mysql_fetch_row($querydata)){
* * * * * *$line = '';
* * * * * *foreach($row as $value) {
* * * * * * * * * *if((!isset($value)) OR ($VALUE =="")) {
* * * * * * * * * * * * * *$value = "\t";
* * * * * * * * * *}else {
* * * * * * * * * * * * * *$value = str_replace('"','""', $value);
* * * * * * * * * * * * * *$value = '"'.$value.'"'."\t";
* * * * * * * * * *}
* * * * * *}
* *$line .= $value;
* *$data .= trim($line)."\n";
* *}
$data = str_replace("\r","",$data);
$str1= $str1 . $data;
return $str1;
}

OK Functions 101 in session.

If you create a function:

function myFunction($arg1, $arg2) {
* * * * //Code

}

Then you need to call it with BOTH arguments:

myFunction(value1, value2);

Now your function:
function makexcldata($xclfields, $result)

2 parameters...

$xclfield *= #1
$result = #2

Now you call your function:

$data .= makexcldata($str1);

$str1 = #1.

Where is #2?
Okay, then the problem is how to get the two calling functions into
one?
$data= makexclheader($str);
$data .= makexcldata($str1);

In this particular instance this is what I want. One array is the
field names for the first data row. The other array is capitalized
and is the header row in Excel. Here are the arrays:
$xclheader= array('L_E',
'Carnumber',
'Location',
'Sighting Date',
'Code',
'RR',
'Origin',
'Destination',
'ETA');
$xclfields= array('carnumber',
'location',
'sighting_date_asc',
'classification',
'railroad',
'origin',
'destination',
'ETA');

Can I put them in one calling function?
thanks,
Sep 12 '08 #8
On Sep 11, 8:18*pm, FutureShock <futuresh...@att.netwrote:
JRough wrote:
On Sep 11, 5:40 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
JRough wrote:
I have a function definition error:
Warning: Missing argument 2 for makexcldata(), called on line 123 and
defined in *on line 149
"Warning: mysql_fetch_row(): supplied argument is not a valid MySQL
result resource *on line 157"
This is the function call on line 123:
Where exactly do I *pass the 2 parameters? *I tried to pass the 2nd
parameters *by setting $result to $querydata and I got the same
message. *Do you need to see the query for $result?
Warning: Missing argument 2 for makexcldata(), called in /home/allrail/
public_html/idle_cars.php on line 123 and defined in /home/allrail/
public_html/idle_cars.php on line 149
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL
result resource in /home/allrail/public_html/idle_cars.php on line 15
thanks,
---changed function-----
function makexcldata($xclfields, $result){
* * * * $result = $querydata;
* *$fields= $xclfields;
* * * * * *for($i=0; $i < sizeof($fields); $i++){
* * * * * * * * * *$str1.= ($fields[$i]);
* * * * * * * * * *$str1.'\t';
* * * * * * * * * *}
* *$str1.'\n';
* *while(mysql_fetch_row($querydata)){
* * * * * *$line = '';
* * * * * *foreach($row as $value) {
* * * * * * * * * *if((!isset($value)) OR ($VALUE =="")) {
* * * * * * * * * * * * * *$value = "\t";
* * * * * * * * * *}else {
* * * * * * * * * * * * * *$value = str_replace('"','""', $value);
* * * * * * * * * * * * * *$value = '"'.$value.'"'."\t";
* * * * * * * * * *}
* * * * * *}
* *$line .= $value;
* *$data .= trim($line)."\n";
* *}
$data = str_replace("\r","",$data);
$str1= $str1 . $data;
return $str1;
}

OK Functions 101 in session.

If you create a function:

function myFunction($arg1, $arg2) {
* * * * //Code

}

Then you need to call it with BOTH arguments:

myFunction(value1, value2);

Now your function:
function makexcldata($xclfields, $result)

2 parameters...

$xclfield *= #1
$result = #2

Now you call your function:

$data .= makexcldata($str1);

$str1 = #1.

Where is #2?

If you listen to the advice Jerry gave you, he answered your question 100%.

Scotty
My function works now. Thanks.
Sep 12 '08 #9
On Sep 11, 8:18*pm, FutureShock <futuresh...@att.netwrote:
JRough wrote:
On Sep 11, 5:40 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
JRough wrote:
I have a function definition error:
Warning: Missing argument 2 for makexcldata(), called on line 123 and
defined in *on line 149
"Warning: mysql_fetch_row(): supplied argument is not a valid MySQL
result resource *on line 157"
This is the function call on line 123:
Where exactly do I *pass the 2 parameters? *I tried to pass the 2nd
parameters *by setting $result to $querydata and I got the same
message. *Do you need to see the query for $result?
Warning: Missing argument 2 for makexcldata(), called in /home/allrail/
public_html/idle_cars.php on line 123 and defined in /home/allrail/
public_html/idle_cars.php on line 149
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL
result resource in /home/allrail/public_html/idle_cars.php on line 15
thanks,
---changed function-----
function makexcldata($xclfields, $result){
* * * * $result = $querydata;
* *$fields= $xclfields;
* * * * * *for($i=0; $i < sizeof($fields); $i++){
* * * * * * * * * *$str1.= ($fields[$i]);
* * * * * * * * * *$str1.'\t';
* * * * * * * * * *}
* *$str1.'\n';
* *while(mysql_fetch_row($querydata)){
* * * * * *$line = '';
* * * * * *foreach($row as $value) {
* * * * * * * * * *if((!isset($value)) OR ($VALUE =="")) {
* * * * * * * * * * * * * *$value = "\t";
* * * * * * * * * *}else {
* * * * * * * * * * * * * *$value = str_replace('"','""', $value);
* * * * * * * * * * * * * *$value = '"'.$value.'"'."\t";
* * * * * * * * * *}
* * * * * *}
* *$line .= $value;
* *$data .= trim($line)."\n";
* *}
$data = str_replace("\r","",$data);
$str1= $str1 . $data;
return $str1;
}

OK Functions 101 in session.

If you create a function:

function myFunction($arg1, $arg2) {
* * * * //Code

}

Then you need to call it with BOTH arguments:

myFunction(value1, value2);

Now your function:
function makexcldata($xclfields, $result)

2 parameters...

$xclfield *= #1
$result = #2

Now you call your function:

$data .= makexcldata($str1);

$str1 = #1.

Where is #2?

If you listen to the advice Jerry gave you, he answered your question 100%.

Scotty
thank you both Scotty and Jerry for today and yesterday. It helped a
lot. It just took me a really long time to figure out the pages and i
had to do it by tomorrow. I'm sorry.
Sep 12 '08 #10
Message-ID:
<0f**********************************@b38g2000prf. googlegroups.comfrom
JRough contained the following:
>My function works now. Thanks.
I'd be surprised.

*if((!isset($value)) OR ($VALUE ==""))

Where is $VALUE defined?

--
Geoff Berrow 0110001001101100010000000110
001101101011011001000110111101100111001011
100110001101101111001011100111010101101011
http://slipperyhill.co.uk - http://4theweb.co.uk
Sep 12 '08 #11

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

Similar topics

12
3216
by: Bryan Parkoff | last post by:
CMain Class is the base class that is initialized in main function. CA Class is the base class that is initialized in CMain::CMain(). CMain Class is always public while CA Class is always...
12
426
by: Bryan Parkoff | last post by:
CMain Class is the base class that is initialized in main function. CA Class is the base class that is initialized in CMain::CMain(). CMain Class is always public while CA Class is always...
4
9603
by: Aniruddha | last post by:
I want to initialize an array of function pointers (global) If I do it like: /* definition of foo_1, foo_2, foo_3 all return void and take no args */ void (* foo) (); foo = foo_1 ; foo = foo_2...
14
1808
by: Mr Newbie | last post by:
I am often in the situation where I want to act on the result of a function, but a simple boolean is not enough. For example, I may have a function called isAuthorised ( User, Action ) as ?????...
11
2500
by: Old Wolf | last post by:
Does the following program require a diagnostic? Which section of the Standard deals with this? (I read the section on function calls and didn't see anything). void f(void); int main(void) {...
0
7207
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,...
0
7093
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7291
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,...
0
7357
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...
0
7468
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...
0
5598
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,...
1
5023
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...
0
3171
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
402
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...

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.