-
Posts
4,704 -
Joined
-
Last visited
-
Days Won
179
Everything posted by kicken
-
<?php function sortOverall($a, $b){ return $a->overall - $b->overall; } usort($arr, 'sortOverall');
-
Use ->fetch(), not ->fetchAll(). ->fetch() returns a single row at a time (call it multiple times to get multiple rows). ->fetchAll() returns all rows in a big array at once.
-
Doesn't really matter if the redirect "fails" or not, the code is still going to be run allowing them to do whatever they normally could without the redirect. I posted an example of why you need to exit after a redirect over on devshed. I'll re-post here, since DS appears to be having some issues lately (maybe just me).
-
I would do that. Just shove $_POST into your session under a key, then pull the values out of there. That way there is no way for a user to access anything other than what they submitted.
-
Yes, AP is for access point.
-
Here's a list of options from newegg. You'll probably want to check specs and read reviews. The first one on the list (EDIMAX EW-7228APn) says it has a 5-port switch, so you could replace your existing switch with it probably if you wanted. Has an average rating. If you want to keep your existing switch, you can just plug the ethernet cable from the wireless AP into a port on your switch.
-
I thought they made little wifi-to-ethernet adapters for connecting things like game consoles or printers via wifi that were not too expensive. I can't seem to find anything at the moment though for much less than $40-$50. For that price you'd probably better off just buying little wifi cards or adapters for your three computers.
-
I like the short tag echo as i use that in my templates, and now I won't need the str_replace then eval hack if short tags is disabled. The short array syntax and array-dereferencing will both be nice (eg $first=explode('.', $var)[0]); Also being able to call a member function directly will be nice, I've had a few cases where I wanted to do that, mainly with the DateTime object, eg: $date = (new DateTime($row['date'], $usersTimeZone))->format('m/d/Y H:i'); It's just a shame that I probably wont really get to use any of it for a year or more.
-
Inserting multidimensional array value into mysql
kicken replied to Drongo_III's topic in PHP Coding Help
String Parsing [ and ] are not considered valid variable name characters, so PHP stop at that point. It make a special case though where if the next character is a [, it will properly interpret it. This only works for one level though. For multiple levels, you have to explicitly tell PHP what the variable name is using the complex notation. This is also why PHP cannot handle quoted keys (such as $arr['hi']) in a string without the complex notation. After the [ it scans for more valid variable characters and stop at first invalid one. ' or " are not valid so you end up requesting the variable $arr[ which causes PHP to error. -
Please help! I go live tomorrow! (MySQL/PHP unknown error!
kicken replied to jessejarvis's topic in PHP Coding Help
$_REQUEST['rid'] will get your number, 929. md5() will change that number into a value such as: 0d0871f0806eae32d30983b62252da50 which means your doing WHERE id='0d0871f0806eae32d30983b62252da50' I doubt that is what you want. -
Please help! I go live tomorrow! (MySQL/PHP unknown error!
kicken replied to jessejarvis's topic in PHP Coding Help
Using INSERT SELECT might work better than trying to do a bunch of sub-selects. Really, your DB should be designed differently thought I believe. Also, you need to make sure you are properly escaping everything so your not vulnerable to SQL Injection. $sql = "INSERT INTO {$prefix}members ( firstname, lastname, email, address, city, state, postcode, country, telephone, username, password, refid1, refid2, refid3, refid4, refid5, refid6, refid7, refid8, refid9, refid10, geo, paypal_email, joindate, mtype, groupid, cb_id, status, signupip ) SELECT '".$_REQUEST["firstname"]."', '".$_REQUEST["lastname"]."', '".$_REQUEST["email"]."', '".$_REQUEST["address"]."', '".$_REQUEST["city"]."', '".$_REQUEST["state"]."', '".$_REQUEST["postcode"]."', '".$_REQUEST["country"]."', '".$_REQUEST["telephone"]."', '".$_REQUEST["username"]."', '".md5($_REQUEST["password"])."', id, refid1, refid2, refid3, refid4, refid5, refid6, refid7, refid8, refid9, '".$_REQUEST["geo"]."', '".$_REQUEST["paypal_email"]."', NOW(), ".$_REQUEST["mtid"].", $eogroup, '".$_REQUEST["cb_id"]."', '$memberstatus', '$signupip' FROM members WHERE id=".$_REQUEST["rid"]." )"; -
Sounds like your PHP file is not being run. You have not installed/activated PHP correctly.
-
I was messing with the beta's a bit. I haven't tried running any of my existing stuff on it, might give it a try over the weekend on my laptop. Not sure how soon it'll be before I take advantage of any of the features. Our prod stuff probably wont update for a long time.
-
Most hosting providers enable a range of extensions, especially popular ones like this. I happen to have a site on GoDaddy so I can tell you they do have it enabled. You can always check on your own though by simply looking at the output of phpinfo or using function_exists on one of the functions provided by the extension in question. It is a feature that has to be "installed", but since your not the one doing the PHP install (GoDaddy is), it's not something you need to really worry about. All you have to do is check if it is available. If by chance it were not available, then you'd have to contact godaddy about getting it setup (or find a different host that does have it).
-
This code appears to work for me (viewable at http://linode.aoeex.com/badge.html) <?php function resizeImage($im, $newW, $newH){ $imnew = ImageCreateTrueColor($newW, $newH); $transparent = imagecolorallocatealpha($imnew, 0, 0, 0, 127); imagefill($imnew, 0, 0, $transparent); ImageAlphaBlending($imnew, false); ImageSaveAlpha($imnew, true); imagecopyresampled($imnew, $im, 0, 0, 0, 0, $newW, $newH, imagesx($im), imagesy($im)); ImageDestroy($im); return $imnew; } $borderImage = ImageCreateFromPNG('surround.png'); ImageAlphaBlending($borderImage, false); ImageSaveAlpha($borderImage, true); $trophyImage = ImageCreateFromPNG('trophy.png'); //Resize the trophy down $trophyImage = resizeImage($trophyImage, 54, 54); //Copy the trophy to the border ImageCopy($borderImage, $trophyImage, 5, 5, 0, 0, 54, 54); header('Content-type: image/png'); ImagePNG($borderImage); exit;
-
You shouldn't just guess. Find out for sure by calling the phpinfo() function, it will tell you all the details about your environment including version numbers. If you are on a PHP4 setup, you should seriously consider moving somewhere else or upgrading to PHP5 (5.2 minimum, 5.3 preferably)
-
The proper setting is America/New_York, with an underscore, not a space. You can change the timezone to what you want in the script whenever you want, you do not have to set it in the ini file.
-
I don't believe there is a limit on the number of columns, persay. The limit is on how big an individual row can be in bytes. So if you had a bunch of TINYINT columns you could fit more in than if you had a bunch of VARCHAR(255) columns, for example. Regarless, if your hitting these limits chances are your probably doing something wrong and need to re-think your DB design. Perhaps someone more familiar with the inner workings of mysql could give a more detailed answer.
-
Do you remember your previous post about bits, bytes, characters, and how we said a character could consist of multiple bytes? That is where the problem comes in. Functions like substr, strlen, strpos, several others assume that a character is just a single byte. Since UTF-8 is a multi-byte encoding they will cause problems if used. What you need to do is use a multi-byte aware alternative. PHP has an extension full of [m=mbstring]multi-byte aware functions[/m] that you can use. For Mysql, you need to setup the connection between your server and your script to use UTF-8. You do this by issuing a query SET NAMES UTF8 after you connect. What do you mean? For your browser to interpret the page as UTF-8 you have to tell it that the page is encoded in UTF-8 by sending the appropriate header. I believe it is: header('Content-type: text/html; charset=utf8'); If your data is just plain english then there is no need to do any kind of conversion on the actual data, as it is the same between latin1 and utf8. You do need to alter your table though so that mysql knows your storing utf8 data in the column and not latin1.
-
Your input field is missing it's name attribute: name="userChoice"
-
There is a 'Topic Solved' button at the bottom of the thread you can click to mark it as solved.
-
If you're the one preparing and sending the POST request, you can send whatever you want whenever you want. If you want to automate a file-upload, write a small PHP script that uses cURL to do the upload. Then just use normal php file upload processing on the servers to accept the file.
-
This code should get you a fairly accurate guess: <?php $basedir = substr($_SERVER['REQUEST_URI'], -1)=='/'?$_SERVER['REQUEST_URI']:dirname($_SERVER['REQUEST_URI']); $http = (!empty($_SERVER['HTTPS'])) ? 'https://' : 'http://'; $url = $http.$_SERVER['SERVER_NAME'].$basedir; echo $url; Though you should have some way, perhaps during the installation process, for the user to manually enter this information. You can use the guessing code to pre-fill the box to try and make things easier for them.
-
What sort of options do you have for moving the data? FTP? PHP has [m=ftp]ftp functions[/m] you can use HTTP? You can use the [m=curl]curl functions[/m] to simulate a POST request and send the data as a file upload. SSH? There are [m=ssh2]SSH functions[/m] that will let you do things like sftp/scp or hack it with just a shell.
-
The only way you'd get a result like that is if $db->sp() is echoing the value, not returning it. If that is the case, it would echo 22, then 18, then your echo $total_stock_count would echo 0 because the other variables would have no value and nothing+nothing=0. Since it would all get echoed right next to each other it'd produce your 22180 number. A quick way to check that would be to: $stock_count_attrib1=$db->sp("attrib_stock1"); echo "<br>--<br>"; $stock_count_attrib2=($db->sp("attrib_stock2")); echo "<br>--<br>"; $total_stock_count = ($stock_count_attrib1+$stock_count_attrib2); echo $total_stock_count ; Those extra echo's would break up the number and you'd get output like: 22 -- 18 -- 0