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;
} 10 1389
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
==================
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.
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;
}
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
==================
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
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);
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,
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.
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.
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 This discussion thread is closed Replies have been disabled for this discussion. Similar topics
12 posts
views
Thread by Bryan Parkoff |
last post: by
|
12 posts
views
Thread by Bryan Parkoff |
last post: by
|
4 posts
views
Thread by Aniruddha |
last post: by
|
14 posts
views
Thread by Mr Newbie |
last post: by
|
11 posts
views
Thread by Old Wolf |
last post: by
| | | | | | | | | | |