Implode() Not Working As Expected
I have one page with a form that uses an array ($order) to print out ordered items. This page then posts to a second page to get personal information from the person ordering. Before posting the form, I implode the array into another variable ($items_ordered), so that I can print a summary of the items ordered on the second page.
(The following code is all within the <form> tags.): Code:
View Complete Forum Thread with Replies
Related Forum Messages:
Ini_set() Not Working As Expected
When running the following code I get a warning: <? ini_set('session.use_cookies',0); ?> random text <? session_start(); ?> The output / warning I'm getting is this: random text Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /path/to/file.php:5) in /path/to/file.php on line 6 Shouldn't the fact that I'm setting session.use_cookies to 0, via ini_set, prevent this error from taking place?
View Replies !
If Statement Not Working As Expected.
I am trying to get my error message to print if either the login is incorrect or the dropdown variable is "Unknown" I get no errors and I know that the variable is posting correctly. I think I'm missing something or put it in the wrong place. Code:
View Replies !
Predefined Variable Not Working As Expected
I have a script that was working fine until I had to reinstall everything. Now my scripts says that : PHP Notice: Undefined index: LOGON_USER in D:Inetpubwwwroot ame.php on line 5 Where I have just made a new file to isolate the issue, but this derives from this script : <?php echo $_SERVER['LOGON_USER']; ?> Which worked fine before. Is this down to the way php is being run? As it stands it is being run via IIS 5 as cgi executable. I've looked over the install txt and it seems as though I have done everything correct.
View Replies !
Delete Query Not Working As Expected
I have 2 different php forms. One makes sure that a user has chosen an unique user name (below): $query_rsApp = "SELECT * FROM users where UserName=".$Registered." "; This Select query works right every time (as far as I can tell). I have a form that I want to use to delete user records. This Delete query works fine if the username and password are both numeric... But if the username or password is text, it returns the error "UNKNOWN FIELD 'whatever'" where whatever is my search criteria that I am trying to use.
View Replies !
Imagecolortransparent Not Working As Expected - Any Ideas?
I'm trying to rescale a gif file with transparency but am having difficulty with the imagecolortransparent() function - It's not working as I would hope... I'm telling it to replace the colour red with transparency and then overlay my transparent gif, but resized. For some reason, it is turning anything black in my transparent gif, transparent, instead of the red - Can anyone else figure out why it might be doing this? Code:
View Replies !
Expected Output
When I try to test my setup by making the file test.php with the single line PHP Code: <?php phpinfo(); ?> then goto http://localhost/test.php it displays Quote: <?php phpinfo(); ?> instead of all the info.
View Replies !
T_OLD_FUNCTION Expected???
I use EngIn editor, my code ran ok there... but not when I ran it on my apache server.. got the following error: Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in C:japachecaseFileCVf.php on line 5 Here's the code:
View Replies !
Loop Expected
i get it to loop, so that it keeps doing it for; $start =10 then 20 etc right up to 1000 the function is; function query($topic, $start = 0) { $googlelist = $this->_query("Google", $topic, $start); $yahoolist = $this->_query("Yahoo", $topic, $start); $this->found = array_unique(array_merge($googlelist, $yahoolist)); $this->counts = array("yahoo" => count($yahoolist), "google"=> count($googlelist), "total" => count($this->found)); return true;.
View Replies !
Could The Close_date Be One That Is Not The Expected Value?
Here's the code. $link="http://xbox360cheat.org"; $close_date=$_POST["close_date"]; #last content change check if ($close_date == 0) $close_date = date("Y-m-d H:m:s", mktime(12, 0, 0, date("m"), date ("d")+7, date("Y"))); else if ($close_date == 1) $close_date = date("Y-m-d H:m:s", mktime(12, 0, 0, date("m"), date Could the close_date be one that is not the expected value? For example, if the month is 11 and $close_date == 7, then the mktime function should return the next year for the year value, not the current year. And if the day is the last week of December, than the month and year should change if close_date == 7.
View Replies !
NULL Expected, Won't Show Up ...
I have tho following code. $_GET['artile'] looks like this: /2006/03/lorem_ipsum $locationinfo = explode('/', trim( $_GET['article'] , '/') ); list( $article_year, $article_month, $article_url ) = $locationinfo; echo '<br>year: '.(($article_year === NULL)? 'null': $article_year); echo '<br>month: '.(($article_month === NULL)? 'null': $article_month); echo '<br>article: '.(($article_url === NULL)? 'null': $article_url); The weird thing is, if $_GET['article'] is empty, $article_year isn't NULL, but the rest is. This doesn't make any sense to me ...
View Replies !
Preg_replace Not Matching As Expected
I'm attempting to write a bit of code that will parse a HTTP_REFERER from google and return the search data and the nationality (.fr, .co.uk, etc). I can get a rough output (see bellow) but the search value (2 in the script) continues past the '&' character which is where I need it to stop. PHP Code:
View Replies !
Function Not Returning Expected Value
I have a php file that contains a couple of arrays used for state/country pull-down lists. I have two global arrays and an accessor method for each. I have some simple logging methods, so I know a little bit about what I'm getting back. When I try to get the arrays from another file using the accessor methods, I get no array back. Within the file that contains the arrays, I can access them by global name and also by the accessor methods. Any ideas why I cannot access the arrays from another file? Code below. <SNIP FROM CALLING METHOD> require_once BASE . '/config/formfields.inc.php' // file with needed arrays // the calling method function display_states($smarty){ logobj(function_exists(get_states)); // returning True/1 $s = get_states(); logobj($s); // no love here logobj(BASE . '/config/formfields.inc.php'); // it's the right file }
View Replies !
CURL Results Not What Expected
I was playing with cURL on a website and it didnt work. So I switched to a different website and it worked just fine. So that little part of my brain that is always working started wondering why cURL wouldnt work with the first website that I had tried. I'm hoping that someone here can help me figure out why this particular website wont work with my cURL script, and help me get it working. Code:
View Replies !
Sort Results Not As Expected
In the actual array I'm working with, the a, b, c's are primary keys. One shouldn't expect them to actually be in order. This example uses a, b, c to verify if a sort worked properly. I want to sort the array so the result will have a,b,c,d,e,f,g,h, etc in order. Code:
View Replies !
Not Getting Expected MySQL Error
I am inserting values into a row.. works OK If I try to insert a value into a row that doesnt exist (using where) it always returns true the same as if it did work I want to update rows that have one unique field.. if the row doesnt exists it should return 0 rows updated.. I then create the row... But it always returns 1 even when I update a row that doesnt exist.. How do I get an error or a false return?
View Replies !
Ereg Not Behaving As Expected
I'm having a problem with the ereg function to verify a user submitted variable the situation is that the user is submitting a textarea post variable there are a number of allowed characters there are more in the actual application but i have removed to demonstrate the problem as removing them makes no difference the php code is as follows: $message=$_POST['textarea1']; if (ereg("^[A-Za-z0-9 ]*$",$message)) { $textValid=TRUE; } else { echo "error"; } but it seems to act like $message=$_POST['textarea1']; if (ereg("^[A-Za-z0-9]*$",$message)) { $textValid=TRUE; } else { echo "error"; }
View Replies !
Buffer Flush Doesn't Work Quite As Expected
I've got a PHP script (running on MacOS X, PHP 4.1.12) which uploads bookings from one database to another, and I'd like to have the screen show progress as it happens (each time I process a booking, I write a line summarising it to the browser with 'print') From RTFMing and Googling, it seems that I should be able to do this by turning output buffering on and using ob_flush() et al. However, this only sort-of works, in that instead of getting output line by line, I get a multi-line chunk on the browser from time to time. Am I stuck with having this chunk-by-chunk visualisation, or can anyone please suggest a way that I can make it force each line to the browser as I write it?
View Replies !
Unexpected Absence Of Expected Warning
The page 167 of book Learning PHP5 by David Sklar says that setcookie() and session_start() must be added before any output. I tried to use that functions at last line but no warning!. The warning which i got 1 month back is not issued now. ------------------------------------------------------------------ The following is my PHP program <?php function Intelli() { echo"Hello P"; } function Bitz() { echo"Hello MySQL"; } ; $a = 1; if($a) $myFunc = 'Intelli' else $myFunc ='Bitz' $myFunc(); print'header' session_start(); setcookie('userid') ?> ---------------------------------------------------------------- The following is the output i got. There is no warning [tdphpadmin@trgbws40 ~/public_html/demo]$ php dynamicfun.php X-Powered-By: PHP/5.2.0 Set-Cookie: ZDEDebuggerPresent=php,phtml,php3; path=/ Set-Cookie: PHPSESSID=bp1m17rlrgsa5g19tfekidov31; path=/ Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre- check=0 Pragma: no-cache Set-Cookie: userid= Content-type: text/html
View Replies !
Unexpected Absence Of Expected Warning.
The page 167 of book Learning PHP5 by David Sklar says that setcookie() and session_start() must be added before any output. I tried to use that functions at last line but no warning!. The warning which i got 1 month back is not issued now. Code:
View Replies !
Regex Doesent Work Expected...
i use this to get all html tags out of an string .. preg_match_all('/<[^>]*>|[^<>]+/', $data, $contentParts); worked wonderful till i noticed that this doesent work with something like "{if $commandCount > 0}" this will be split in 2 parts: "{if $commandCount " and " 0}" and the < is gone It shouldnt split anyway when it detects an " < " or ">=" or " <=" and so on..
View Replies !
Elegantly Handling An Expected Error
I have a very modest database on my server and I use php to allow people to query it. Its very simple, they enter a value that should be in column 1 (account_num) and I return the value for column 2 (balance) (same row). Here is the question: What if the value they enter doesn't match any values in column 1? Right now, I get this ugly error message: Code:
View Replies !
Line Breaks Don't Work As Expected
I wrote this small bit of code for a college class, but the instructor offered no feedback. Our textbook offered nothing and the teach yourself book I bought had typos in it. :mad: I don't understand why the linebreaks in the php code didn't work properly. I ended up putting them at the beginnings of the next line, rather than the end of the previous line. I think that's sloppy; I want to undertand why the line break worked on the first line but not subsequent lines. I expect it's something semantic, quotes or such. Code:
View Replies !
Problem Getting Script's URL ($_SERVER['PHP_SELF'] Not What I Expected)
I have a function that restricts access to a page to logged in users. When a user who isn't logged in goes to the page, it will dynamically generate a login form. I'm trying to use it in conjunction with the free shared SSL certificate offered by my host. To use SSL, you would change a URL like this http://mydomain.com/page.php to https://ssl.myhost.com/mydomain.com/page.php My problem: when my script dynamically generates the login form, it uses the $_SERVER['PHP_SELF'] value in the action field. But this ends up being '/page.php' rather than '/mydomain.com/page.php' so my form gets submitted to https://ssl.myhost.com/page.php instead of https://ssl.myhost.com/mydomain.com/page.php Simple I thought, I'll just use the SERVER or ENV variable that gives me the full url. My problem: it doesn't seem to exist!
View Replies !
Chmode With Mkidir Function, The Result Isn't As Expected
I've tried to create a directory with the php function mkdir(). I've used a "0777" mode , so that owner,group and other can read,write and exectue files in this directory. There's no problem creating the directory, but after it has been created, its mode is "0755". Where did I commit a mistake ?
View Replies !
PHP 404 Document's REQUEST_URI Does Not Hold Expected Value In $_ENV And $_SERVER
I wanted to migrate some custom 404 error pages from shtml to php for the ease of email notification of lost pages. However when PHP processes the page $_ENV['REQUEST_URI'] and $_SERVER['REQUEST_URI'] both now hold the error page eg "404.php". Does anyone have advice on how to dodge this? Should I just continue to use shtml error pages and do an shtml include on a little php script to do the mail?
View Replies !
Implode
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 have limited programming experience, most of it Pascal/C++ and I haven't programmed for many years now even then it was mediocre programming of small this and thats. Here is the code:
View Replies !
Implode()
how to put a data extracted from mysql_query() into a comma separated string, similar to implode(",", $var) function for array, without fetching through it first? here is what I query: Code: SELECT id FROM make WHERE make LIKE '%$make%' here is what I need: Code: array("23","45","46","72")
View Replies !
How To 'implode' A URL ?
using PHP 4.3.3 and Apache (ADVX) 2.0.47 and i want to get the contents of my SETI stats site : $personal = implode("", @file("http://setiathome.ssl.berkeley.edu/fcgi-bin/fcgi?email=$email&cmd=user_stats_new")); which gives me this : Warning: implode(): Bad arguments. in /home/rob/www/php/phpMySetiStats/download.php on line 4 what am i doing wrong ? i used this code a couple of months back on somewhat older versions of PHP/Apache in Windows2000 and it worked ... ?
View Replies !
Implode()?
I have checkboxes named service[] and am trying to get at them using implode(). $Offered_Service = $HTTP_POST_VARS["service"]; $O_Service = implode(",", $Offfered_Service); $message .= 'Services offered: <input type=text name=Offered_Service value="$O_Service"><br />' Why is this not working?
View Replies !
Using Implode
What I wanna do is implode this file so I can get the team name from the 2nd line. All files are the same and all team names are on the 2nd line for all the. txt files that will be submitted. The file is submitted from a form. the ID for the file would be $form_data I have tried this.
View Replies !
Using PHP To Implode
Supposing I have the following data in a table: NAME | COLOR ============= mpolo | Green mpolo | Blue mpolo | Yellow jfrost | Red jfrost | Black pbunyan | Brown pbunyan | Silver pbunyan | Gold pbunyan | Bronze
View Replies !
Implode <-> Explode
I'm able to figure out how implode() works. Now, my question is: is explode() the opposite of implode()? because, I've written a little test code: you have a select box and you can select multiple options. I implode these options and I put these in a database (I have too, won't explain it, it's quite hard hehe) so I get somehing like these in my database: option1|option2|option now, i want too extract these variables and put them again in a new select box, and I have to remove those '|', and I think it must be possible with explode() or split(), I'm not sure, I've tried a lot, rtfm', but it didn't work so fare, anyone an idea ? Code:
View Replies !
Checkboxes - Implode
This is my situation: I have an html form that has 4 checkboxes. <p><input type="checkbox" name="area[]" value="1" checked> Area1<br> <input type="checkbox" name="area[]" value="2" checked> Area2<br> <input type="checkbox" name="area[]" value="3" checked> Area3<br> <input type="checkbox" name="area[]" value="4" checked> All other areas</p> This array is passed to a php page that runs a query on a mySQL table. The possible values for area in the mySQL table are 1, 2, 3, 4, 5, 6. So, I want to display records that match the appropriate checkboxes except if checkbox 4 is checked I want the value to be 4, 5, and 6. (>=4). I just can't get the implode to do this. The problem is the last. If checkbox 4 is checked it displays records with area=4 and doesn't display records with area =5 and area=6. How could I do this?
View Replies !
Implode() Function
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 contains the fields. I want to convert it into an XHTML table to echo to the browser. For a 1-dimensional array, I would do this with implode(). Can I use implode() on a 2D array? If not, is there some other function I could use to do this, or will I have to write my own? Or has anyone already written one?
View Replies !
Implode Notice
I don't particularly need to do this but I've just found out that print implode("<br>", $_SERVER); Gives the warning : Notice: Array to string conversion in c:phpdevwww... Doesn't do it with any other array and of course foreach($_SERVER as $value){ print "$value<br>"; } does exactly the same thing with no warning.
View Replies !
PHP Implode Error
I have the following code, a simple implode function: $titles = $_POST['titles']; $titles = implode("#", $titles); I am positive that "$titles" is an array, but I get an error message from PHP saying: Warning: implode() [function.implode]: Bad arguments. in /home/.... on line 12*I replaced the rest of the URL with "...." to save space. Does anyone know why I'm getting this error? I've also tried removing the first value from the function, so it would read "implode($titles)". Using another variable with the implode doesn't work either, eg: "$newVariable = implode("#", $titles)"
View Replies !
Using Implode With Windows UNC
I'm creating a build environment with one system acting as the main build dispatcher and other systems as the build hosts. On the main build system I have Apache, MySQL and PHP installed and I'm building a website that will allow people to view/start/etc. builds. I'm trying to get PHP to implode a log file that resides on one of the host builds systems. I have the host and and the share, so what I'm passing into the implode command is: NH8516D02Dpj302weblog.txt This gives me the following warning: Warning: file("NH8516D02Dpj302weblog.txt") - No such file or directory in C:apachehtdocsldcentralviewlog.php on line 21 Is there a way for PHP to open a file on a different system from a folder that has been shared? I'm not too worried about security as this is an internal site to the company.
View Replies !
Serialize Or Implode
At the moment I am working on a webservice to store measurement data. The data in general comes as a massive list of numbers, which I read as an array. At the moment I am storing the data as a serialized array in a text field. However, since each list is about 2000 values long, the keys of the array take a bit of space. I was thinking about storing them as imploded arrays, e.g., by semicolon. That would save a lot of storage space. However, I would need to implode & explode the arrays every time I try to accas that. How do the resource requirements for implode / explode compare to serialize / unserialize? I am assuming serialize would be quite effective, but I am not sure.
View Replies !
Implode Prob
i'm using implode to insert checkbox data as an array into database.. the input in the database is like this: Code:
View Replies !
Implode(): Bad Arguments
Below is the code this inquiry refers to. Curiously, it works well; when the user fills out the text fields and makes checkbox selections, the site sends them the echo statement and sends me (via an email) the information input into the form fields. BUT in addition to "Thank you, , for your registration. You will receive confirmation of your registration details in the mail." They get the above Warning statement "Warning: implode(): Bad arguments." Also interesting is that the same code did not trigger the warning in earlier runs? $msg .= "InstitutionName: $_POST[InstitutionName]"; $msg .= "Address: $_POST[Address]"; $msg .= "City: $_POST[City]"; $msg .= "State: $_POST[State]"; $msg .= "Zip: $_POST[Zip]"; $msg .= "Registrant : $_POST[Registrant].................
View Replies !
Implode & Explode
explain me implode & explode in dumb english slang. i've read the manual, and i dont register. i''ve tried echoing examples based on the manuel, and perhaps i'm not getting it.
View Replies !
Implode Function
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() [function.implode]: Bad arguments. in /home/xxxxxx/public_html/login.php on line 177 Couldn't execute insert query." PHP Code: $today = date("Y-m-d"); Â Â Â Â Â Â Â Â $fields_str = implode(",", $fields); Â Â Â Â Â Â Â Â $values_str = implode('","',$values);Â Â <=line177 Â Â Â Â Â Â Â Â $fields_str .=",createdate"; Â Â Â Â Â Â Â Â $values_str .='"'.",".'"'.$today; Â Â Â Â Â Â Â Â $fields_str .=",password"; Â Â Â Â Â Â Â Â $values_str .= '"'.","."md5"."('".$password."')"; Â Â Â Â Â Â Â Â $sql = "INSERT INTO member "; Â Â Â Â Â Â Â Â $sql .= "(".$fields_str.")"; Â Â Â Â Â Â Â Â $sql .= " VALUES "; Â Â Â Â Â Â Â Â $sql .= "(".'"'.$values_str.")"; Â Â Â Â Â Â Â Â $result = mysql_query($sql) Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â or die("Couldn't execute insert query."); Â Â Â Â Â Â Â Â $_SESSION['auth']="yes";Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â $_SESSION['logname'] = $loginname;
View Replies !
IMPLODE Arguments
Two problems in two situtations with the same code: If I do this: implode(",", array_map("sqlesc", array($wantusername, $wantpasshash,  $secret, $editsecret, $a['inviter'], $email))) ."'". get_date_time() ."')"); It does not expect the last ) out of ))). Although I count three opening if I do this: implode(",", array_map("sqlesc", array($wantusername, $wantpasshash,  $secret, $editsecret, $a['inviter'], $email)) ."'". get_date_time() ."')");
View Replies !
Implode Works
PHP Code: echo"<b>Genre</b>:"; $result = mysql_query("SELECT wgenre.*, wrelgenre.*Â Â FROM wgenre, wrelgenre WHERE wrelgenre.wcontent_id = $row[wcontent_id] AND wrelgenre.wgenre_id=wgenre.wgenre_id "); $genre= array(); while($row = mysql_fetch_array($result)) { $genre[] = $row[0]; } foreach ($genre as $key => $value) { Â Â Â if ($value == NULL) { unset($genre[$key]); } } $data = implode(", ", $genre); Â Â Â Â Â echo"$data";
View Replies !
Implode() Question
$myarray[0]="Hello"; $myarray[1]="World"; $imploded_myarray=implode(",", $myarray); $imploded_myarray="Hello, World"; Is there a simple way to get the results coverted to "'Hello', 'World'"; For example, I wanted to implode the array first, and use it in the mysql query "in the set" test. And the field is type varchar(100). I would need "'Hello', 'Word'", instead of "Hello, World".
View Replies !
Include Vs File Implode
What is the most efficient way of including a file inside of another file with considerations of server load, page loading time, etc? For instance, lets say I want to include the search results on an example page. So in example.php something like: include("http://www.domain.com/search.php?x=1&y=2"); or echo implode("",file("http://www.domain.com/search.php?x=1&y=2")); So which of these is better, or alternatively, is there a better, faster option?
View Replies !
PHP Implode File Question
Can I not use a variable with implode such as implode('', file('$url')); as opposed to implode('', file('http://www.example.com/')); When I pass the variable, nothing comes up, yet if I pass the actual url, it works.
View Replies !
Implode, Explode Problems
I am trying to make a script work for a game I am working on at the moment. The problem comes at the explode() and implode() functions. I am pulling an array out of a database with 5 items in it (ex. 1,0,0,0,0) Once the array is pulled I change one of the zeros to a new number and then implode the array back into the variable then back to the database. There is also a check to make sure that you have an open zero to use and change.Here is the code:
View Replies !
|