PHP - Help With Implode
when i echo count($words) it is 1.
but when i print_r($itemid) it displays this.. Code: [Select] Array ( [2] => 17 [3] => 15 [4] => 17 ) when i count($words) it should echo 3. Code: [Select] print_r($itemid); $words = implode(" ", $itemid); echo count($words); Similar TutorialsThis topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=319071.0 I get this error on my homepage : Warning: implode() [function.implode]: Invalid arguments passed in /home/shqip1/peqini.com/wp-content/themes/sportpress/functions/wpzoom-widgets.php on line 1469 This is the code to modify http://pastebin.com/RiBsyG3c Thanks This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=308349.0 i have a problem i cant solved for cople of hours! this is the function: function show_posts($user_id,$limit=0){ $posts = array(); $user_string = implode(',', $user_id); $extra = " and id in ($user_string) "; if ($limit > 0){ $extra = "limit $limit"; }else{ $extra = ''; } $sql = "SELECT userid, caption, stamp, filename FROM photographs WHERE userid in ($user_string) order by stamp desc $extra"; //echo $sql; $result = mysql_query($sql) or die(mysql_error()) ; while($data = mysql_fetch_object($result)){ $posts[] = array( 'stamp' => $data->stamp, 'userid' => $data->userid, 'caption' => $data->caption, 'filename' => $data->filename, ); } return $posts; } and thats the full error: Warning: implode() [function.implode]: Invalid arguments passed in C:\wamp\www\includes\functions.php on line 12 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') order by stamp desc' at line 2 and the intresting thing that if i echo the sql i get a working one i checked it in phpmyadmin + it shows what it need to show in the index.php if i comment the "or die(mysql_error()) " here the sql when its do echo SELECT userid, caption, stamp, filename FROM photographs WHERE userid in (4,7,2) order by stamp desc limit 5 so y the hell this problem is keep coming? i really cant understand what wrong! tnx for the help! I am getting this error in the header.php of my wordpress theme... Can anyone help? Thanks! Warning: implode() [function.implode]: Invalid arguments passed in /home/bexxx/public_html/wp-content/themes/organic_portfolio_gray/header.php on line 74 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>> <head profile="http://gmpg.org/xfn/11"> <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" /> <meta name="distribution" content="global" /> <meta name="robots" content="follow, all" /> <meta name="language" content="en" /> <title><?php wp_title(''); ?><?php if(wp_title('', false)) { echo ' :'; } ?> <?php bloginfo('name'); ?></title> <link rel="Shortcut Icon" href="<?php echo bloginfo('template_url'); ?>/images/favicon.ico" type="image/x-icon" /> <link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" /> <link rel="alternate" type="application/rss+xml" title="<?php bloginfo('name'); ?> RSS Feed" href="<?php bloginfo('rss2_url'); ?>" /> <link rel="alternate" type="application/atom+xml" title="<?php bloginfo('name'); ?> Atom Feed" href="<?php bloginfo('atom_url'); ?>" /> <link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" /> <?php if ( is_singular() ) wp_enqueue_script( 'comment-reply' ); ?> <?php wp_enqueue_script("jquery"); ?> <?php wp_head(); ?> <script type="text/javascript" src="<?php bloginfo('template_url'); ?>/js/superfish/superfish.js"></script> <script type="text/javascript" src="<?php bloginfo('template_url'); ?>/js/superfish/hoverIntent.js"></script> <script type="text/javascript" src="<?php bloginfo('template_url'); ?>/js/jquery.flow.1.1.js"></script> <script type="text/javascript" src="<?php bloginfo('template_url'); ?>/js/iepngfix_tilebg.js"></script> <!--IE6 Fix--> <style type="text/css"> img, div, a, input, body, span { behavior: url(<?php bloginfo('template_url'); ?>/images/iepngfix.htc); } </style> <script type="text/javascript"> var $j = jQuery.noConflict(); $j(function() { $j("div#controller").jFlow({ slides: "#slides", width: "960px", height: "480px", timer: <?php echo ot_option('slider_interval'); ?>, duration: 400 }); }); </script> <script type="text/javascript"> $j(document).ready(function() { $j('ul.ot-menu').superfish(); }); </script> </head> <body> <div id="wrap"> <div id="header"> <div class="headercenter"> <p id="title"><a href="<?php echo get_option('home'); ?>/" title="Home"><?php bloginfo('name'); ?></a></p> </div> </div> <div id="navbar"> <div id="nav"> <div id="navbarleft"> <ul class="ot-menu"><li<?php if (is_home()) { echo " class=\"current_page_item\""; }?>><a href="<?php echo get_settings('home'); ?>"><?php _e("Home", 'organicthemes'); ?></a></li> <?php $include_categories = ot_option('include_categories'); ?> <?php wp_list_categories('depth=4&title_li=&sort_column=menu_order&include='.implode(',', $include_categories)); ?></ul> </div> <div id="navbarright"> <ul class="ot-menu"> <?php $include_pages = ot_option('include_pages'); ?> <?php wp_list_pages('title_li=&sort_column=menu_order&include='.implode(',', $include_pages)); ?> </ul> </div> </div> </div> <div style="clear:both;"></div> Hello, I'm just a beginner (and french sorry for my language) : have some pb with my little implode function. It's Running well on my local webserver (MAMP - PHP PHP Version 5.2.17) but when tested on ovh server (PHP4) show this error : Warning: implode() [function.implode]: Invalid arguments passed in /homez.xx/myPathHere/entete.php5 on line 6 I understand 1/ that one argument is missing but don't find the right syntax 2/ I have tried to turn this file on php5 with this extension (ovh is under php4) Here is my code in page defining the value and where stay my query (entete.php5) <?php if (isset($theme)) { $t = implode(',',$theme); $lien = "aide.php5?theme=".$t; $aide = '<a href="'.$lien.'">'.$onglet[0].'</a>'; } else { $aide = ""; } ?> Here is my code in page which show result (aide.php5) $t = explode(',',$_GET['theme']); $n = count($t); if ($n == 1) { $where = "id = ".$t[0]; } else { $where = "id = ".$t[0]; for ($i=1;$i<$n;$i++) { $where .= " OR id=".$t[$i]; } } Hope someone kindly help me : thanks in advance I am using a PHP class (it is attached) for Google Analytics that I got from this link below: http://www.acleon.co.uk/?p=173 Unfortunately, it appears the Class has a PHP error: Warning: implode() [function.implode]: Invalid arguments passed in Galvanize.php on line 114 and line 181. This is line 114: setcookie('__utmc', implode('.', $this->UTMC), 0, $this->CookiePath, $this->getDomain()); Here is line 181: $urchinUrl .= '&utmcc=__utma%3D'.implode('.', $this->UTMA).'%3B%2B__utmz%3D'.implode('.', $this->UTMZ).'%3B'; I did not see UTMC and UTMZ declared anywhere in the Class. The class file is attached. Thanks for your help in advance. My error is 'Warning: implode() [function.implode]: Invalid arguments passed in /home/definiti/public_html/contact.php on line 73' Im not sure how to fix this error, as I looked online and it says that my implode() has the right layout too it.. Line 73 in my code (I took the HTML code out) is this line; Code: [Select] $message = implode("<br>\n", $messages); My whole code is; Code: [Select] <?php # PHP Copyright 2007, Thomas Boutell and Boutell.Com, Inc. # Edited by Definition Designs. $recipient = 'defenitiondesigns@googlemail.com'; $serverName = 'www.definition-designs.co.uk'; if ($_POST['send']) { sendMail(); } elseif (($_POST['cancel']) || ($_POST['continue'])) { redirect(); } else { displayForm(false); } function displayForm($messages) { global $login; $escapedEmail = htmlspecialchars($_POST['email']); $escapedRealName = htmlspecialchars($_POST['realname']); $escapedSubject = htmlspecialchars($_POST['subject']); $escapedBody = htmlspecialchars($_POST['body']); $returnUrl = $_POST['returnurl']; if (!strlen($returnUrl)) { $returnUrl = $_SERVER['HTTP_REFERER']; if (!strlen($returnUrl)) { $returnUrl = '/'; } } $escapedReturnUrl = htmlspecialchars($returnUrl); ?> <?php if (count($messages) > 0) { $message = implode("<br>\n", $messages); echo("<h4>$message</h4>\n"); } ?> <form method="POST" action="<?php echo $_SERVER['DOCUMENT_URL']?>"> <p> <b>Your</b> Email Address <input name="email" size="35" maxlength="35" value="<?php echo $escapedEmail?>"/> </p> <p> Your <b>Real</b> Name <input name="realname" size="35" maxlength="35" value="<?php echo $escapedRealName?>"/> </p> <p> Subject Of Your Message <input name="subject" size="35" maxlength="35" value="<?php echo $escapedSubject?>"/> </p> <p> <i>Please enter the text of your message in the field that follows.</i> </p> <textarea name="body" rows="10" cols="60"><?php echo $escapedBody?></textarea> <p> <input type="submit" name="send" value="Send Your Message"/> <input type="submit" name="cancel" value="Cancel - Never Mind"/> </p> <input type="hidden" name="returnurl" value="<?php echo $escapedReturnUrl?>"/> </form> <?php } function redirect() { global $serverName; $returnUrl = $_POST['returnurl']; $prefix = "http://$serverName/"; if (!beginsWith($returnUrl, $prefix)) { $returnUrl = "http://$serverName/"; } header("Location: $returnUrl"); } function beginsWith($s, $prefix) { return (substr($s, 0, strlen($prefix)) === $prefix); } function sendMail() { global $recipient; $messages = array(); $email = $_POST['email']; if (!preg_match("/^[\w\+\-\.\~]+\@[\-\w\.\!]+$/", $email)) { $messages[] = "That is not a valid email address. In format: You@something.com"; } $realName = $_POST['realname']; if (!preg_match("/^[\w\ \+\-\'\"]+$/", $realName)) { $messages[] = "The real name field must contain only alphanumeric characters, spaces and + or - signs."; } $subject = $_POST['subject']; if (preg_match('/^\s*$/', $subject)) { $messages[] = "Please specify a subject for your message. "; } $body = $_POST['body']; if (preg_match('/^\s*$/', $body)) { $messages[] = "Your message was blank. Fill out a message or Click Cancel to cancel message."; } if (count($messages)) { displayForm($messages); return; } mail($recipient, $subject, $body) or die("unable to send the mail!"); $escapedReturnUrl = htmlspecialchars($_POST['returnurl']); ?> <form method="POST" action="<?php echo $_SERVER['DOCUMENT_URL']?>"> <input type="submit" name="continue" value="Click Here To Continue"/> <input type="hidden" name="returnurl" value="<?php echo $escapedReturnUrl?>"/> </form> <?php } ?> I am having trouble with passing the results of this first query into the next. I first query the db to get the sub id's that belong to the cat id coming through the url. This query gives me the correct results. //query for subcat id $var1_getCAT = "-1"; if (isset($_GET['cat'])) { $var1_getCAT = (get_magic_quotes_gpc()) ? $_GET['cat'] : addslashes($_GET['cat']); } mysql_select_db($database_conntest, $conntest); $query_getCAT = sprintf("SELECT subs.subcat_id, subs.subcategory FROM subs WHERE subs.cat_id = %s ORDER BY subcat_id", GetSQLValueString($var1_getCAT, "int")); $getCAT = mysql_query($query_getCAT, $conntest) or die(mysql_error()); $row_getCAT = mysql_fetch_assoc($getCAT); $totalRows_getCAT = mysql_num_rows($getCAT); Then, I use the array $subCATS in the next query to search the results that are in that array: //set var for subs $subCATS = array(); while ($row = mysql_fetch_assoc($getCAT)) { $subCATS[] = $row['subcat_id']; } $subCATS = implode( ', ', $subCATS); $query_rsSearch = "SELECT advs.adv_id, cinfo.c_id, FROM cinfo LEFT JOIN advs USING (adv_id) WHERE (cinfo.subcat_id IN ($subCATS) OR cinfo.subcat_id2 IN ($subCATS)) ORDER BY RAND()"; If I put exit in front of the second query, I see that the array is dropping the first result. For example, if the first query returns (2, 3, 4, 6, 9, 52), the value of the $subCATS array in the second query is only searching in (3, 4, 6, 9, 52). I hope this makes sense. I am not sure why it would only drop the first result. I figured it would either work or not work, not just partially work - it has thrown my brain into a do while loop that is making me dizzy! What am I doing wrong? I keep getting the "Invalid arguments passed in..." error when trying to use implode. Here's the code: Code: [Select] $getPilots = "SELECT * FROM users WHERE emailOption = '1' AND status = '1'"; $runGetPilots = mysql_query($getPilots); while ($info = mysql_fetch_array($runGetPilots)) { $emails = $info['email']; $to = implode(', ', $emails); The ending bracket is there, i just didn't include it in the code. Any suggestions? Thanks. Code: [Select] $birthday = implode(",",$_POST['BirthDay']); $bday = array( "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31" ); echo $birthday['0']; exit; //var_dump($colorarrays); if (!in_array($birthday['0'], $bday)) { message("Please select a Correct Birthday, or u trying to hack"); } Okay, if I enter "55325" for my first birthday POST, it only shows "5" and thus making the in_array not work correctly how can i implode my data correctly ty I want to store an array in a mysql table. all of the values in the array are numbers. Should I serialize or implode? What's the difference? Thanks! I have a pretty basic form mailer where I need to have the results of a multi-select box sent through the mail function. I have used the same script before without errors, the only difference now it that I am using jQuery to submit the form instead of the form action attribute. Does anyone know what it is that I am doing wrong here? Here is the error I am receiving: Warning: implode() [function.implode]: Invalid arguments passed in /usr/home/affo14/www/htdocs/home-care-information/request-home-care-processer.php on line 25 The form I am working on is located he http://www.affordablehomecare.org/home-care-information/how-to-get-home-care.html My full PHP code: Code: [Select] <?php /*subject and email variables*/ $emailSubject = 'Request Home Care'; $webMaster = 'XXXXXXX@affordablehomecare.org'; /*gathering data variables*/ $Mname = $_POST['Mname']; $email = $_POST['email']; $phone = $_POST['phone']; $Btime = $_POST['Btime']; $Cname = $_POST['Cname']; $city = $_POST['city']; $state = $_POST['state']; $age = $_POST['age']; $gender = $_POST['gender']; $startDate = $_POST['startDate']; $hours = $_POST['hours']; $days = $_POST['days']; $list2Field = $_POST['list2']; $extra = $_POST['extra']; $referral = $_POST['referral']; $list2 = implode(', ', $list2Field); /*email field*/ $body = <<<EOD <br><hr><br> <h2>Contact Person</h2> <hr> Contact Name: $Mname <br> Contact Email: $email <br> Contact Phone Number: $phone <br> Best to Call Around: $Btime <br> <h2>Client Info</h2> <hr> Client Name: $Cname <br> Client City: $city <br> Client State: $state <br> Client Age: $age <br> Client Gender: $gender <br> Date Service is Needed By: $startDate <br> Days Service is Needed: $days <br> Number of Hours Needed: $hours <br> Client Problems: $list2 <br> <h2>Extra Info</h2> <hr> Extra Info: $extra <br> Referral Source: $referral EOD; /*email sender script*/ $headers = "From: $email\r\n"; $headers .= "Content-type: text/html\r\n"; $success = mail($webMaster, $emailSubject, $body, $headers); /*results*/ print "Thank you for your interest in Affordable HomeCare. You should expect contact from out office within 24 hours. If you do not receive a call within 24 hours please call 800-968-8195"; ?> Guys,
What is wrong in this query? It's throwing an error.
$upit = "SELECT Br_artikla, Prodana_kolicina, Godina FROM katalog_pribora_povijest WHERE Br_artikla = " . implode(' OR Br_artikla = ', $kataloski) . " GROUP BY Godina";Error I get: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '02 83-01 OR Br_artikla = 503 86 27-02 OR Br_artikla = 503 86 27-03 OR Br_artikla' at line 3 i keep on getting this error.. Warning: implode() [function.implode]: Invalid arguments passed in... $rowinformation is an array, i don't see where the problem is. Code: [Select] for($v=1;$v<11;$v++) { $rowinformation = $_SESSION[$v]; echo "<div style='display:none;' id='$v'>".implode("<p> </p>",$rowinformation)."</div>"; // outcome string information } Hi All, After a query runs, I want to grab the ID's and separate them with a comma because they will be used in the next query. What I currently have does not work, although the query is correct. Code: [Select] $sql = "SELECT a.app_id FROM applications a LEFT JOIN tenants t ON a.app_id = t.app_id WHERE t.tenant_id IN (".implode(",", $checked).")"; $result = mysqli_query($connect, $sql); $checked1 = array(); while($row = mysqli_fetch_array($result)) { foreach($row['app_id'] as $value1) {$checked1[] = $value1;} } echo implode(",", $checked1); Code: [Select] $DB->query("SELECT tid FROM reports WHERE id IN ($ids)"); while ($max = $DB->fetch_row()){ echo $max['tid']; } This code spits out: 12012167 It's grabbing 120, and 121 and 67. Those are my "tid" for each column in my database "reports" The problem I am trying to make it echo 120,121,67 So I use the explode: Code: [Select] $tids = explode(",", $max['tid']); echo $tids; Then it echo's out. ArrayArrayArray Any idea guys? Hi All, Just now I had a thought in mind for using regular expression in implode. I know I can get the solution using foreach loop but just trying whether can we do it without using foreach. I have an array here I want to create a table with array. I can do it using for or foreach loop but just a thought came in my mind doing it without using loop. $arr = array(1,2,3,4,5); echo "<table border='2'>"; echo "<tr>".implode("<td>[u]I WANT MY VALUES HERE[/u]</td>",$arr)."</tr>"; echo "</table>"; can we pass regular expression in implode() so that i will get record something like this <td>1</td> <td>2</td> <td>3</td> <td>4</td> <td>5</td> Code: [Select] while($row=mysql_fetch_assoc($query)) { $id = $row['id']; $col1 = $row['name1']; $col2= $row['name2']; $col3= $row['name3']; ${"$id"} = array("$col1","$col2","$col3"); ${"$s".$i}[] = ${"$id"}; } This is just a brief example of what i'm trying to accomplish,$i is incremented somewhere else. I'm trying to implode the arrays in the array. So below i have imploded the main array but how do i implode the other arrays? Code: [Select] for($i=0;$i<11;$i++) { $array = ${"s" . $i}; $outcomes = implode("",$array); //implodes main array } |