472,993 Members | 2,185 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,993 software developers and data experts.

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 1461
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
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
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
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
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
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
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...
3
SueHopson
by: SueHopson | last post by:
Hi All, I'm trying to create a single code (run off a button that calls the Private Sub) for our parts list report that will allow the user to filter by either/both PartVendor and PartType. On...

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.