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 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
==================
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 thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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...
|
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...
|
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...
|
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 ?????...
|
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) {...
| |
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,...
|
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...
|
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,...
|
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...
|
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...
|
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,...
| |
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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...
| |