By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,521 Members | 1,447 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,521 IT Pros & Developers. It's quick & easy.

function definition error

P: n/a
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
Share this Question
Share on Google+
10 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.