btherl
Staff Alumni-
Posts
3,893 -
Joined
-
Last visited
Everything posted by btherl
-
problem integrating mysql in an array if more than one element
btherl replied to thedevilinu's topic in PHP Coding Help
The problem is the part in bold: $badarray=explode(array("\r\n", "\r", "\n"),$bad); You can't put an array here - it has to be a string. -
problem integrating mysql in an array if more than one element
btherl replied to thedevilinu's topic in PHP Coding Help
That tells you there is a problem with your explode() then. Looking at the php manual, explode() does not take an array as the first argument. -
Well, that IS pagination Even if it's only two pages. Another way to do it is: $pageno = 2; # Show page #2 $files_per_page = 16; # Show 16 files on each page $page_files = array_slice($files, ($pageno - 1) * $files_per_page, $files_per_page); Then $page_files is an array containing just the files for the current page. The trickiest bit of pagination is generating the next/prev links, so if you are doing those manually then this should be all you need. Edit: Maybe you need to subtract one from the second argument to array_slice(). I don't remember.
-
Are you familiar with using loops to go through results from mysql? Such as "while" and "foreach"?
-
That's best done in php, I wouldn't try to express it in SQL. You can loop through the results from MySQL remembering the following values: 1. How long the current streak is 2. How long the longest streak was Remember to check at the end (after the loop has finished) to see if the last streak is the longest.
-
Checking if a port is being used with fsockopen?
btherl replied to gergy008's topic in PHP Coding Help
Hmm.. I would try adding this to the top: ini_set('display_errors', 1); Maybe it will tell you something useful. -
problem integrating mysql in an array if more than one element
btherl replied to thedevilinu's topic in PHP Coding Help
Try this: $badarray=explode(array("\r\n", "\r", "\n"),$bad); foreach($badarray as $value){ $value= str_replace(array("\r\n", "\r", "\n"),NULL,trim($value)); echo $value; $query="Update googlevacancies_junk SET exist='$no' WHERE email='$value' "; mysql_query($query) or die("Error in query:<br>$query<br>" . mysql_error()); } The only change is to check for errors from mysql_query() -
Oh I see the problem.. I had thought you said that mysql was returning multiple results for a quote, but it was the php loop calling multiple mysql statements. Sorry for misinterpreting your question.
-
That code looks ok to me.. is the "@" getting converted in the body of the email? Or is it in the headers?
-
Try this out. It's long and messy because of the unusual database design, but it may get you what you want. The key idea is rather than filtering rows by YES, which doesn't work because a single row can contain both YES and NO, it maps YES to 1 and NO to 0 and then adds up the total. $sql = "SELECT SUM(CASE WHEN rowBa = 'YES' THEN 1 ELSE 0 END) " . " + SUM(CASE WHEN rowBb = 'YES' THEN 1 ELSE 0 END) " . " + SUM(CASE WHEN rowBc = 'YES' THEN 1 ELSE 0 END) " . " + SUM(CASE WHEN rowBd = 'YES' THEN 1 ELSE 0 END) " . " + SUM(CASE WHEN rowBe = 'YES' THEN 1 ELSE 0 END) " . " AS cnt " . " FROM my_db2 "; But, like thorpe said, please consider redesigning the table
-
Yes.. if I understand correctly about what you mean by "duplicate posts". It's normal that if you have the same quote with 3 labels that you would get 3 rows back for one quote, each with a different label. And what your code is doing to merge them into a single result looks right to me. I guess that I can't see any problem with your code, especially not a problem relating to matching more than one searched term. SQL will not duplicate results just because more than one "OR" is matched. But it will duplicate results if there are multiple rows matching for a join. Eg if a quote appears 3 times in the categories table, the quote will appear 3 times in the result of a join with that table.
-
This function will give you the key: http://au2.php.net/manual/en/function.array-search.php array_filter() will let you use a callback to implement more complex filters on arrays.
-
Based on your output, it looks as if it returns multiple rows because of the multiple labels, not because the rows were matched on more than one search condition. Otherwise you would get repeated labels in your labels array.
-
Does the query succeed and return 0 results, or does it fail?
-
I think it's fine to echo inside the class if the purpose of the class is to echo your page. The Smarty display method is an example of this. But within the class I would recommend that you generate the entire output in a string, and only echo it with a single statement at the end. IE your display method would be function display() { $output = $this->generate(); echo $output; } And no other method from this class (and all other classes) would echo anything.
-
Can you please post your code.
-
The oppposite of < is >=, and the opposite of > is <=. That's another way to invert the comparisons.
-
Your original code would work if you add the missing "}" at the end. But I recommend doing as revraz suggested: if (...) { } elseif (...) { } else { } That makes the code more readable.
-
Try these settings: // Constants define('BASE_URI', '/01_KnowledgeIsPower/'); define('BASE_URL', 'localhost'); define('MYSQL', '/includes/mysql.inc.php'); It's a bit tricky to know what they're expecting there, as those are not what I would normally consider a URI or URL. So instead I'm trying to go based on the example values.
-
What do you type into the browser when you want to see the website?
-
BASE_URL should probably look like the original one, ie a host name.
-
CronJOb and Imap is not working when disable email
btherl replied to belick's topic in PHP Coding Help
How did you disable the cronjob email response?