jcbones
Staff Alumni-
Posts
2,653 -
Joined
-
Last visited
-
Days Won
8
Everything posted by jcbones
-
How to load files from webpage protected by htaccess?
jcbones replied to supanova's topic in PHP Coding Help
Maybe, you don't understand. -
How to load files from webpage protected by htaccess?
jcbones replied to supanova's topic in PHP Coding Help
You can call it whatever you wish, receiving an image from a remote server = hotlinking. I don't care if you are trying to "edit" it. Anytime you request that image from outside of it's native domain, that is hotlinking (at least as the server sees it). If the administrators of that site has an .htaccess file that disables ANY call from outside of the native domain. YOU WILL NOT GET THE IMAGE. -
How to load files from webpage protected by htaccess?
jcbones replied to supanova's topic in PHP Coding Help
1. If it IS your webspace, change the .htaccess to allow calls from your other space. 2. If it IS NOT your space, leave it alone, the owner doesn't want you eating his bandwidth. -
What do you mean by "only works some of the time". What about it doesn't work "only works some of the time"?
-
Still don't know why you are stuck on Ajax. I wouldn't use Javascript for any calculations. Keep the calculations on the server, and away from the client. With javascript disabled, then no matter how cool the AJAX was integrated, the script wouldn't calculate anything. Take the data from the form, post it to the page, verify and sanitize your data, do your calculations, send the email. Once you have the PHP script up and running, you can build a second version with AJAX if you are so inclined. That way you have one pretty one, and one that users can use if they don't allow javascript.
-
Make sure C:\xxxx\xxxx\samples\upload\ exists.
-
This line: if(is_uploaded_file($_FILES["file"]["name"])) { Should probably be: if(is_uploaded_file($_FILES["file"]["tmp_name"])) { Or, if(move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_FILES["file"]["name"])) { echo "Stored in: " . "upload/" . $_FILES["file"]["name"]; }
-
It simply runs all your variables through a function that makes a string safe to interact with a database (mysql specifically). Otherwise people could rebuild your query to gain access to your database, and exploit your users, and/or destroy your tables.
-
Take your mysql_query string, and turn it into something like: $sql = sprintf("INSERT INTO mynews (user, title, message, type, url) VALUES ('%s', '%s', '%s', '%s', '%s')", mysql_real_escape_string($user), mysql_real_escape_string($title), mysql_real_escape_string($message), mysql_real_escape_string($type), mysql_real_escape_string($url)); $result = mysql_query($sql); As always Un-tested (may be a parse error).
-
Most of that is pretty easy, and none of it *REQUIRES* Ajax. Ajax just makes it prettier. I suppose you can build the form. Couple of simple inputs. Quantity and Product, or maybe you want a page with pics of product and an "add to cart" link? <?php function productPricing($price, $quantity, $discount, $discount_over_amount = 0) { $cost = floatval($price) * intval($quantity); $discount = str_replace(array('.','%'),'',strval($discount)); return ($cost > $discount_over_amount) ? number_format($cost - ($cost * floatval('.' . $discount)),2) : number_format($cost,2); } $price = 10; $quantity = 10; $discount = 20; $amount_to_apply_discount = 100; echo 'Your product cost $' . $price . ' and you have ordered ' . $quantity . ' of them. This will cost you $' . productPricing($price,$quantity,$discount,$amount_to_apply_discount) . ' after all discounts are applied.'; ?> I'm sure there is an easier faster way, but this is off the cuff.
-
Just don't index things that change on a regular basis, as that will cause the database extra work. It will have to re-write an index, everytime it is changed. Explained here
-
Just plain `ole $row = mysql_fetch_array($result, MYSQL_ASSOC); Works also.
-
This needs fixing as well: if(!empty($title)) { //if the title is not empty, than do this function <-This should be $_POST['title'], as the variable is not declared until the next line. $title = addslashes($_POST['title']);
-
Parse error: You forgot your semi-colon after your $amano variable declaration.
-
Group is a reserved word in mysql. put it in backticks. `group`
-
That sounds like a terrible idea. Why would *all* your classes be of the same type? I'm sorry, I took this post as satire.
-
I would use __autoload() in your situation. That would only work if the extended class of the core class doesn't have an error. If the extended class of the core class has a child class that reverts back to the extended class within a child class of the core class, none of these functions will work. Then you would have to us __toString().
-
Before you go any further, lets do some de-bugging. Top of script: echo '<pre>'; print_r($_REQUEST); echo '</pre>'; Change query call to: $query = mysql_query("SELECT * FROM `table` WHERE `uid` = '".$uid."'") or die(mysql_error()); And of course as Indicated above. Change your fetch call: //Either: while ($row = mysql_fetch_array($query, MYSQL_ASSOC)) { //or while ($row = mysql_fetch_assoc($query)) {
-
If you use print_r() or var_dump(), it is best to wrap them in <pre></pre> tags. This way they will show properly formatted in a browser window. Much easier to read, and figure depth.
-
Yes, you are correct, you can change it to: Should work but Un-tested. $html = json_decode($html,true); foreach($html['facilities'] as $v) { echo $v['fclt_name'] . '<br />' . $v['fclt_addr'] . '<br />' . $v['fclt_city'] . ', ' . $v['fclt_state'] . ' ' . $v['fclt_zip'] . '<br />Phone: ' . $v['tel_no']; }
-
how come my post method search box works only once?
jcbones replied to monger's topic in PHP Coding Help
PHP scripts run ONCE, before the server sends the browser the output generated by the script. If you want it to search over and over, you will need to couple it with some javascript to refresh the page on interval. -
You are asking for a numeric array, and trying to assign associative indexes. Change your while loop to: while ($row = mysql_fetch_assoc($query)) { $outArray[] = $row; //IF you only expect 1 row, you don't need a while loop, and you don't need the brackets on $outArray. }
-
It is in usable data: OK, I just want to extract the agency name, complete address, and phone number $html = json_decode($html,true); foreach($html as $v) { echo $v['fclt_name'] . '<br />' . $v['fclt_addr'] . '<br />' . $v['fclt_city'] . ', ' . $v['fclt_state'] . ' ' . $v['fclt_zip'] . '<br />Phone: ' . $v['tel_no']; } Edit: didn't notice it was multi-dimensional.
-
You could try a good `ole: echo '<pre>'; print_r($_FILES); echo '</pre>'; At the top.
-
how come my post method search box works only once?
jcbones replied to monger's topic in PHP Coding Help
Well, how many times do you want it to search?