-
Posts
14,780 -
Joined
-
Last visited
-
Days Won
43
Everything posted by .josh
-
Unable to access the search daemon
.josh replied to Coreye's topic in PHPFreaks.com Website Feedback
Yay! Now users can finally start using it and...no wait...I don't think average joe was using it to begin with... -
split the number 100 into arrays of numbers that add up to 100
.josh replied to tallberg's topic in PHP Coding Help
Agreed. I'm kind of curious as to what you really need here. From what you are saying, you will end up with a massive amount of arrays. I mean think about it: 95 + n = 100 n = 1 + 4 n = 1 + 3 + 1 n = 1 + 2 + 2 n = 1 + 2 + 1 + 1 n = 1 + 1 + 1 + 1 + 1 n = 2 + 3 n = 5 That's 7 arrays for the number 95. 7 ways to mix and match n adding up to 5. Can you imagine how many different ways there are to mix and match numbers that add up to 50? Because the last combo will be 50 + 50 = 100. -
split the number 100 into arrays of numbers that add up to 100
.josh replied to tallberg's topic in PHP Coding Help
So basically you want to end up with 50 individual two element arrays? I don't really see why you would want to do that...I would suggest you have a single multi-dim array, like: $array[0][0] = 1; $array[0][1] = 99; $array[1][0] = 2; $array[1][1] = 98; etc... <?php $a = range(1,50); $b = range(99,50); foreach($a as $k => $n) { $array[] = array($n,$b[$k]); } echo "<pre>"; print_r($array); output: Array ( [0] => Array ( [0] => 1 [1] => 99 ) [1] => Array ( [0] => 2 [1] => 98 ) [2] => Array ( [0] => 3 [1] => 97 ) [3] => Array ( [0] => 4 [1] => 96 ) [4] => Array ( [0] => 5 [1] => 95 ) etc... -
In your query, you are using a column named "from" well "from" is a reserved word, part of the mysql syntax. It's like naming one of your columns the name "select" or "insert" well that's a keyword that mysql uses to perform queries. So mysql is getting confused, thinking you are trying to use as such. You can tell mysql to treat it as a column by wrapping backtics around it like so: `from` but you shouldn't do that. Instead, you should pick a column name that is not a reserved word.
-
also, when you get that sorted out, you're going to find yourself having that same error for a couple of those other columns, as well. Wash, rinse and repeat for them.
-
from is a mysql reserved word. mysql will allow you to use reserved words as column or table names if you wrap it in backticks `from` but the better solution would be not to use reserved words to begin with.
-
What happened to the old phpfreaks tutorials?
.josh replied to sKunKbad's topic in PHPFreaks.com Website Feedback
I think it was lost, unless Dan or someone happens to have a copy stored locally. I got a sql dump of the tutorials that were salvaged not too long after the loss, and it's not in there. -
[SOLVED] I'm thinking preg_replace might get this done?
.josh replied to immanuelx2's topic in Regex Help
$string = str_replace(' ','-',$string); // replace all spaces with hyphen $string = preg_replace('~[^-a-z0-9]+~i','',$string); // remove anything not alphanumeric or hyphen with $string = strtolower($string); // make it lowercase? (that's what you have in your from -> to example As far as changing for instance "Numb3rs" to "numbers" (changing the 3 to an e) that's a bit more complex. Think it would be practically impossible to transform arbitrary text like that. I suppose you can catch most of those by first exploding at a space (or dash, if you have it post-str_replace), then loop through each element and check to see if it's a combo of words and letters (to avoid changing for instance 333 to eee), and if so, loop through each letter and check against an array containing "3" => 'e', "0" => 'o', etc... and replace if found. But that's not going to be perfect, as you will end up changing 3rd to erd, sort of thing. you could further have a list of exceptions, like number, followed by st,nd,rd,th I guess. -
if it's in the url that means the user does not allow cookies to be set.
-
[SOLVED] Parse error: syntax error, unexpected ...
.josh replied to randallc's topic in PHP Coding Help
if ( ($category_depth == 'products') || (isset($HTTP_GET_VARS['manufacturers_id']) ) { you are missing a closing ) -
google for mod rewrite tutorials. Virtually every single one of them out there shows how to do that.
-
That's the basic idea, yes. But there is a lot of work to be done with that. Examples: - Since you don't have any form tags, there's not going to be anything in that $_POST array. You will need to put form tags in your form, specifying the method as post. - Your variable names are not right. (ex: in your form you use underscores but in your post array you have spaces) - Use <?php not <? - You can't use spaces in variables (ex: "$other ins claim no" php will see that as a variable called "$other" and then throw an error because the rest of that is invalid syntax) - You need to validate the data (ex: making sure the user entered in properly formatted data, there's nothing dangerous in it, like attemped sql injection attacks, etc...) - you should not end things in ..or die(mysql_error()); setup proper error handling instead.
-
I see an html table with a couple of input fields in it. I don't see any form tags, so you don't even have a working html form. Also, I don't see any php code for handling data submitted from this non-existent form. Maybe this tutorial might help you out: http://www.phpfreaks.com/tutorial/php-basic-database-handling
-
[SOLVED] Set SQL Query For Certain Number Of Days
.josh replied to refiking's topic in PHP Coding Help
are you saying that $seasoned is for instance 28 as in 28 days old? $seasoned = time() - $seasoned * 60 * 60 * 24; ...where `stamp` < $seasoned -
pass them as a session variable/array or on "next" page, echo the previous info out as hidden fields.
-
[SOLVED] What is more precise microtime() or microtime(TRUE)?
.josh replied to WolfRage's topic in PHP Coding Help
Don't blame us if you aren't understanding. microtime() and microtime(true) both return the same thing, only in a different format. So it's not a matter of which one is more precise, but a matter of how you want the result to be formatted. Do you want it in "seconds.microseconds" ex: 123.456 or "microseconds seconds" 456 123 what part of that don't you understand? -
[SOLVED] What is more precise microtime() or microtime(TRUE)?
.josh replied to WolfRage's topic in PHP Coding Help
They both return the same info, but in a different format. It's like the date. July 19, 2009 is the same thing as 2009-07-19. It's just formatted differently. Get it? -
no. unless it is within something greater, like styling making it white or covering it with something. Suppose you can quickly answer that by rightclick > view source and ctrl+f'ing for it.
-
[SOLVED] Making this secure, is it even possible?
.josh replied to Michdd's topic in PHP Coding Help
Technically, yes. But you'd at least have it narrowed down to just him (or people with direct server access), rather than some random Joe. But at that point, they could just flub the numbers in the DB anyways, and there's nothing you can do about that. -
Think I'm about out of ideas now. Only thing I can think of is maybe your code somehow got changed since the time you posted the snippet in your OP.
-
[SOLVED] Making this secure, is it even possible?
.josh replied to Michdd's topic in PHP Coding Help
use cURL to send it via post. Make the forum owner give you (and update if necessary) the server IP address. Check the IP address making the request. Also, assign a key to the forum owner. Have the cURL script send that as well, and check to make sure it matches what you have on file. -
well the query is inside that condition and he's saying it is executing and all of the data is being inserted except for that one column, so that can't be the issue. Okay so if you're 100% sure you are absolutely sure that all of the other data is being pulled from the old table and put into the new table from this script, all except for AGENT, then let's go back to just that column. So you checked the data type of the old vs. new. Spelling the same? Did you make sure you didn't accidentally set it up as some auto-populated column?