Hi,
I am having a problem with implode() function in PHP.
whenever i am running my code it display an error like.
Warning: implode() [function.implode]: Bad arguments. in D:\xampp\htdocs\admin\addspecs.php on line 8
and my code is -
$as = $_POST;
-
$i=1;
-
while($i<=16)
-
{
-
$ad = $as['txtRow'.$i];
-
$aw = implode(",",$ad);
-
$qw = "#".$aw;
-
echo $qw;
-
$i++;
-
}
-
what is the error in this code can anybody tell me.
6 2409
the problem is that $ad is not an array (it's the value of a POST element). further you should call implode() outside the while-loop.
you can create arrays like - // repeat
-
$array[] = $value;
-
// or
-
$array[$key] = $value;
or use some of the array functions
hi,
still i am not getting the solution. and how we can put the implode to outside of the while loop because all the text field name are unique and i can take the value of text fields without while loop.
what I wanted to say is, you need to change the code structure - while (…)
-
{
-
// …
-
$array[] = $_POST[$key];
-
}
-
$string = implode(",", $array);
Now its not giving an error, but when i am trying to print the value it showing only array like this:
Array,Array,Array,Array,Array,Array,Array,Array,Ar ray,Array,Array,Array,Array,Array,Array,Array,Arra y,Array -
$i=0;
-
while($i<=$count)
-
{
-
$arr[] = $_POST['txtRow'.$i];
-
$i++;
-
}
-
$str = implode(",",$arr);
-
echo $str;
-
looks like $_POST['txtRow'.$i] is an array. if you set error reporting to E_ALL you should get the according notices.
I too think there's some problem with $_POST thingie itself. You should see what you are actually POST'ing to the page. Use - echo"<pre>"; print_r($_POST); echo "</pre>";
in the starting of the page. Then you can see what's going wrong.
Also, if you have to iterate through the POST'ed array anyhow, then you can just concat the POST variable instead of imploding it after converting it to another array. - while (condition)
-
{
-
$str .= $_POST[whatever];
-
//increment thing
-
}
-
echo $str;
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Jeff |
last post by:
Hello.
Quick background as I dont wish to hog anyones time. I am a customer of a
PHP/SQL programmer. A website that I had the programmer build for me is
working great, with one exception.
I...
|
by: DJ Craig |
last post by:
I have 2-dimensional array with numeric indices for both dimensions,
called $results, which contains the search results from a database.
The first dimension contains the records, and the second...
|
by: Leszek |
last post by:
Hi
I' m trying convert a php array to a javascript array like this:
var danevar1 = "<? print $dane1; ?>";
var danearray1= new Array();
danearray1 = danevar1.split(",");
var suma1=0;
for(var...
|
by: bb nicole |
last post by:
BElow is my php code for candidate search, it have 4 criteria which is academic background, functional experience, preferred location and languages ability. but it show yhe blanks page..
Emm, is it...
|
by: NoWhereMan |
last post by:
Maybe a stupid question.
-------------------------
1
-------------------------
$str = '';
for($i=0; $i<10; $i++)
$str .= $i;
|
by: scatfly |
last post by:
I have a set of values that were put into a form and am now using this to put into a database. this is my error:
"Warning: implode() : Bad arguments. in /home/xxxxxx/public_html/login.php on line...
|
by: atyndall |
last post by:
OK, this is the relevant portion script:
<?php
$username = '__'; // MySQL Database Username.
$password = '__'; // MySQL Database Password.
$server = '__'; // MySQL Database server (most...
|
by: Einstein30000 |
last post by:
Hi,
in one of my php-scripts is the following query (with an already open
db-connection):
$q = "INSERT INTO main (name, img, descr, from, size, format, cat,
host, link, date) VALUES ('$name',...
|
by: swethak |
last post by:
hi,
i want to zip the folder using php. Any body plz help for that.
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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...
| |