
silkfire
Members-
Posts
569 -
Joined
-
Last visited
Everything posted by silkfire
-
How do you do the query?
-
You should definitely consider upgrading to PHP 5.4. PHP 4 is not even supported any longer.
-
I suspect your issue is with SQL variables. mysql_query does not allow more than one query (separated with ';'). So run mysql_query two times: mysql_query('SELECT @count := 0'); $wetqres = mysql_query("SELECT @count := IF(TotRain > 0, @count + 1, 0) AS wetcnt FROM daily_syn WHERE ID = '$row[iD]' AND YEAR(SynDate) = '$stryear' ORDER BY wetcnt DESC LIMIT 1");
-
Do you know what the difference between bindParam and bindValue is? Also you don't necerilly need those if you use ::execute() method.
-
You're welcome! Good luck with that one By the way there were errors in my code plus I missed 2 fetch constants so here's the correct code: $fetch_methods = array( 'assoc' => PDO::FETCH_ASSOC, 'lazy' => PDO::FETCH_LAZY, 'named' => PDO::FETCH_NAMED, 'num' => PDO::FETCH_NUM, 'both' => PDO::FETCH_BOTH, 'obj' => PDO::FETCH_OBJ, 'bound' => PDO::FETCH_BOUND, 'column' => PDO::FETCH_COLUMN, 'class' => PDO::FETCH_CLASS, 'into' => PDO::FETCH_INTO, 'func' => PDO::FETCH_FUNC, 'group' => PDO::FETCH_GROUP, 'unique' => PDO::FETCH_UNIQUE, 'key_pair' => PDO::FETCH_KEY_PAIR, 'classtype' => PDO::FETCH_CLASSTYPE, 'serialize' => PDO::FETCH_SERIALIZE, 'props_late' => PDO::FETCH_PROPS_LATE ); ... if (isset($fetch_methods[strtolower($method)])) $method = $fetch_methods[strtolower($method)]; else $method = $fetch_methods['assoc'];
-
Lol I can immediately see the cause of all your errors mate! PDO has a list of constants that correspond to numbers (see list here: http://www.php.net/manual/en/pdo.constants.php). You're trying to use the PDO::FETCH_* in string form! If I were you I'd make a mapping array but maybe this syntax works as well: PDO::{$fetch}, not sure though. $fetch_methods = array( 'assoc' => PDO::FETCH_ASSOC, 'lazy' => PDO::FETCH_LAZY, 'named' => PDO::FETCH_NAMED, 'num' => PDO::FETCH_NUM, 'both' => PDO::FETCH_BOTH, 'obj' => PDO::FETCH_OBJ, 'bound' => PDO::FETCH_BOUND, 'column' => PDO::FETCH_COLUMN, 'class' => PDO::FETCH_CLASS, 'into' => PDO::FETCH_INTO, 'func' => PDO::FETCH_FUNC, 'group' => PDO::FETCH_GROUP, 'unique' => PDO::FETCH_UNIQUE, 'serialize' => PDO::FETCH_SERIALIZE, 'props_late' => PDO::FETCH_PROPS_LATE ); ... if (isset($fetch_methods[strtolower($method)])) $method = $fetch_methods[strtolower($method)]); else $method = $fetch_methods['assoc']);
-
You're a veteran mate you're the one with more knowledge lol =) Once again, ::execute belongs to the PDOStatement class, but returns a bool, thus ($this->resource is a bool!) your error that you're trying to use a class method on a bool =D I can see in your code that you've saved the resouce in $prep ($this->temp) actually! So it's a matter of some minor changes and it should work. But I agree with you sometimes very obvious errors are invisible to the author but obvious to someone who sees the code for the first time.
-
I think the reference is pretty good, you just need to learn how to read it. If you read carefully, it says that the ::fetch() method belongs to PDOStatement class, not PDO. So you first must run the query, which in turn will give you a PDOStatement object you can use the fetch on. Is $qry your returned result set? Then use ::fetch on it.
-
And what did you get in return?
-
getElementsByTagName('img') INSIDE a specific DIV
silkfire replied to sblake161189's topic in PHP Coding Help
Use XPath, matey=) -
Need help creating an array of mobile useragents
silkfire replied to kimosiris's topic in PHP Coding Help
I usually use a stripos_inarray function for these kind of purposes. Thus you can write all your mobile strings in lowercase. function stripos_inarray($haystack, $needles) { if (!is_array($needles)) $needles = array($needles); foreach($needles as $needle) { if (($pos = stripos($haystack, $needle)) !== false) return $pos; } return false; } $useragents = array('iphone', 'ipod', 'incognito', 'webmate', 'android', 'dream', 'cupcake', 'blackberry', 'webos', 's8000', 'bada', 'googlebot-mobile'); if (stripos_inarray($_SERVER['HTTP_USER_AGENT'], $useragents) !== false) include_once 'template/phones.php'; -
<form action="emailer.php" method="post"> That seems to recirect you to another page. Remove that and you'll post to the same page you are on.
-
It's because you didn't escape the apostrophe by putting a backslash in front of it (\'). I could see the problem immediately in my text editor because i noticed the color for the string was not my default string color (light blue). But actually the solution here is simple, put the whole string into double quotes:
-
Extraction of values from a Twitter JSON array
silkfire replied to sdiegolo78's topic in PHP Coding Help
Probably because there is no method there called "request". See my syntax: $direct_message = $OAuth->oAuthRequest('https://api.twitter.com/1/direct_messages.json', 'GET', array('sender_id','screen_name' ,'text')); -
If the math answers are simple operand type, you can use eval but you might need some replacements done first. $answer = '4 x 5'; $answer = str_replace('x', '*', $answer); eval('$answer = ' . $answer . ';'); But be careful eval is discouraged but I don't know the alternative.
-
No matter what happens, it's never too late to switch to PDO. Try it, you won't go back
-
%T is basically date('H:i:s'). Don't be lazy =P. The following strftime formats are not supported on Windows platform: '%e' '%u' '%V' '%C' '%g' '%G' '%l' '%P' '%r' '%R' '%T' '%D' '%F' '%s' '%n' '%t' '%%'
-
This regular expression will split a string wherever it finds the following consecutive match: 1. A newline 2. The number '1' 3. All characters until the newline on this row 4. A newline 5. A hypen (-) or minus character So it would match the red in the following string: 0+432jkrouwer{€$@£$@^??423 1doeriwep4892304234puopi42348034 -iodfugo89042432purewrwerpuwer
-
Fatal error: [] operator not supported for strings in
silkfire replied to frankpetrov's topic in PHP Coding Help
as for what $monsters is: for($i=0;$i < $nbmonsters;$i++) echo "monsterid[$i]=".$monsters[$i].";\n"; Removing the whitespace doesn't change anything nor does moving it to before the while statement I saw something about var_dump() and print_r(), but I eally don't understand them. How can I use one of these to print out on the browser to see if maybe there's a DB error? I don't really understand what you want to achieve here? We still don't know how the array $monsters looks like. Does it have associative keys? If you want to strip the keys you can do like this: $monsterid = array_values($monsters) -
Very simple. The BLOB field contains the raw data of the file and that is the only thing you require. So if it's a doc document you could do something like: file_put_contents('document.doc', $file_contents); PHP makes reading and writing files a breeze! Change the first argument if you need the file in another folder, e.g. '../../path/to/folder/document.doc';
-
Fatal error: [] operator not supported for strings in
silkfire replied to frankpetrov's topic in PHP Coding Help
I can't from your code determine what $monsters is, but it seems like it's a string and not an array. You use the [] operator to add an item to an array, you can't do that on strings. -
$bookstart and $bookslutt, you have to encapsulate them in quotes ('') or it won't work.
-
You can JOIN a table on itself with previous id as a joiner. You must use RIGHT join to not drop the first NULL record. The two columns I select here are the ones I compare. Very important to not forget to ALIAS the columns to prevent name collision. SELECT `Films_Info`.`FilmRelease` AS `FilmRelease1`, `previous`.`FilmRelease` AS `FilmRelease2` FROM `Films_Info` AS `previous` RIGHT JOIN `Films_Info` ON (`previous`.id = `Films_Info`.id - 1)
-
Difference between mysql_fetch_array and mysql_query
silkfire replied to eldan88's topic in PHP Coding Help
You use mysql_query to perform the query itself. This function returns a resource that you iterate upon to extract the contents of the result of the query with various fetch functions, including the on you mentioned. -
Which line is missing and can you please show us your text file?