-
Posts
4,268 -
Joined
-
Last visited
Everything posted by BlueSkyIS
-
Dynamically Create Every Combination of Words Possible
BlueSkyIS replied to Masna's topic in PHP Coding Help
the number of possible combinations is n!/(n-r)! where n is the number of words in the collection and r is the number of words taken from the collection. So knowing that the minimum number of words is 1 and the maximum is the total number of words in the sentence: $words = explode(" ",$sentence); for ($i=0;$i<count($words);$i++) { // Make every possible permutation using $words[$i]; } -
if nothing else, you probably need to wrap some of your arrays, for instance: {$sharedinfo[id]} I always try to consistently single-quote every field. Sometimes you do, sometimes you don't. If you made it consistent, that might help you fix the problem.
-
"How do I only show the error AFTER the user has pressed my submit button??" check to see if the form was POSTed. I use this: if ($_SERVER['REQUEST_METHOD'] == "POST") { // The form was posted }
-
[SOLVED] getting from one table listing from another
BlueSkyIS replied to nathanmaxsonadil's topic in MySQL Help
SELECT `names` FROM `table` WHERE `names` IN (SELECT `names` FROM `othertable`) ORDER BY `points` DESC -
try this? $result = mysql_query($query) or die(mysql_error());
-
while($i_main < $count_main) { $links .= " <a href=\"".$main_nav['pages'][$i_main]."\" class=\"glink\" id=\"g".$i_main2."\">".$main_nav['names'][$i_main]."</a> "; $i_main++; $i_main2++; } echo $links;
-
because your function echos $links, then loops over some numbers doing nothing: echo $links; // You echo one time, but then.... while($i_main < $count_main) { // Nothing is happening here. $i_main++; $i_main2++; }
-
what do you mean by "if I leave out $fname='fname' it does not work"? Do you see an error, a "Notice"? You shouldn't need to declare a variable unless you have Notices turned on... Anyway, try using this instead: $output = $row[${$fieldList[0]}];
-
if i understand correctly, you are trying to get the value of N in: <include picture# N> If you need to get the value of N, you might want to try int preg_match ( string pattern, string subject [, array &matches [, int flags [, int offset]]] ) and look in &matches. perhaps like this: $pattern = '/<include picture# ([0-9]+)>/'; $matches = array(); if (preg_match($pattern, $string, $matches)) { // found at least one match: $image_number = $matches[1]; } Edited: $matches[0] will be the part that matches. $matches[1] is the value in the parentheses. $image_number is N, assuming N is always a number [0-9]+
-
and then you can refer to it as a variable: ${"var_" . $i}
-
should have the exact same result either way.
-
passing variable between a window and an open page
BlueSkyIS replied to isaac_cm's topic in PHP Coding Help
Javascript. You could add an onClose() event to the window to send a value to the window's opener. not php.... -
how to declare $var as int in PHP: you don't. secondly how to cast a variable like () in PHP: if you want the integer value of a string, use intval($string). If you need to determine if a value is a number, you can use is_numeric(). to test whether a value is an integer, I use if (intval($string) == $string) {}
-
It looks like you're expecting $ipresult to contain a single value when it will actually contain an entire row. You might try this instead: list($ipresult) = mysql_fetch_row($ipsearch); ...and there is no need to check $ipsearch a second time since you already tested with if ($ipsearch... you probably don't need this: if (!$ipsearch); { echo "Could not run query:" . mysql_error(); exit; }
-
how to handle 2 mysql database connections with php
BlueSkyIS replied to bruckerrlb's topic in PHP Coding Help
no. use this to get the result of the query the first time and then use it as you like: $result = mysql_query($sql, $connect1); then you can do stuff like loop over results, etc: while ($row = mysql_fetch_array($result)) { // Do something with the row of data... } -
how to handle 2 mysql database connections with php
BlueSkyIS replied to bruckerrlb's topic in PHP Coding Help
^^^ yes! I didn't know this and had been doing it a not-so-easy way myself. i think i found my own answer. mysql_query() takes an options resource link, so we can query each separately with: mysql_query($sql, $connect1); mysql_query($sql, $connect2); -
how to handle 2 mysql database connections with php
BlueSkyIS replied to bruckerrlb's topic in PHP Coding Help
after connect2 = mysql_connect(), a mysql_query() is performed. Which connection does the mysql_query() act on? -BSIS -
I don't see anything obvious, but I'd be wary of an if (mail()) I'd step through, putting echo() here and there, hack away, etc. etc.
-
the page is probably going blank due to code after the if. For sure, if you use $_POST['buttonname'] without an _x or _y, you'll get nothing.
-
exactly. the result of the implode will be INSERT INTO dbTable ('column1') VALUES ('$val1'), ('$val2'), ('$val3'), etc. There will be one row for each value.
-
I see this in there: if(isset($_POST['register'])) should be if(isset($_POST['register_x']))
-
I use implode. Something like this: "INSERT INTO dbTable ('column1') VALUES ('".implode("'), ('", $_POST['myArray'])."')"; -BSIS