premiso
Members-
Posts
6,951 -
Joined
-
Last visited
-
Days Won
2
Everything posted by premiso
-
session_cache_expire That would be the function you are after. You will need to place that before the session_start call for it to work. Sorry the above was wrong information. ini_set('session.gc_maxlifetime', 300); session_start(); Where 300 is how long in seconds you want it to live. Place that before the session_start and it should only last as long as you set it to.
-
fopen fwrite fclose Simple as A B C.
-
In the php.ini (or where the extension information is listed) locate a line that has php_recode.dll (for windows) or recode.so (for *nix). If it does not have a ; infront, add one in, restart apache and see if that fixes the error. This information was found via Google at: http://daemon80.blogspot.com/2007/10/solved-php-segmentation-fault.html I am unsure if that is related to your problem, or if you tried it. As for me, I never heard of a segment fault error.
-
[SOLVED] Curl not retrieving image properly
premiso replied to scottybwoy's topic in PHP Coding Help
A simple test: <?php // create a new cURL resource $ch = curl_init(); // set URL and other appropriate options curl_setopt($ch, CURLOPT_URL, "http://www.google.com/intl/en_ALL/images/logo.gif"); curl_setopt($ch, CURLOPT_HEADER, 0); header("Content-Type: image/gif"); // grab URL and pass it to the browser curl_exec($ch); // close cURL resource, and free up system resources curl_close($ch); ?> If that does not display the google logo then there is something wrong with cURL on your webserver. I would look into re-installing or opening a ticket. -
Well that is different than this: I think the above just confused me, and everyone else. It sounded like you want to retrieve the full path name to use in the script, when you just want to upload a file and allow the user to browse to it... I have not looked at redarrows code, but here is a tutorial for what I think you want to do: http://www.html-form-guide.com/email-form/php-email-form-attachment.html
-
You can put it outside the www directory then use a file reading script to dish it out, they would have to have the right hash or something of that store. You would need to store the file path/hash in a DB with the associated username if you want.
-
$string = "Testing\nand testing again\n"; $string = str_replace("\n", "\n |", $string); Use str_replace for simple replacements.
-
Impossible. You cannot do it, even with Javascript because of Security reasons. I would hate to give anyone who I upload files to my directory structure. Stop turnin' your wheels, it cannot be done except with ActiveX controls as I stated above, which the user has to allow. There should be no reason for you to need that information anyways.
-
No fix without using ActiveX controls. This is a security feature of all browsers unless the user allows it (hence the ActiveX Control).
-
dynamic variable assignment from query results
premiso replied to moonlightinred's topic in PHP Coding Help
extract is what you are looking for, but why not just use the array? It really is not that much more code and is way faster. -
var_dump(get_defined_vars());
-
How big is the image you are trying to display and what is your Memory limit set at? Reason to ask, it could be eating up more memory than you think. $content takes up as much as it has, then $im now has that as well, so your memory doubled there. Then you resample it, which now your memory has tripled. You do destroy it, but you have used 3 times the memory. So if the image is 3MiB and your Memory limit is set to 8M then there is your answer. It went over the limit. You can try and temporarily increase the limit and see what happens: <?php // Create MySQL login values and // set them to your login information. $username = ""; $password = ""; $host = "localhost"; $database = "userimages"; // Make the connect to MySQL or die // and display an error. $link = mysql_connect($host, $username, $password); if (!$link) { die('Could not connect: ' . mysql_error()); } $connect = mysql_select_db($database) or die("Can not select the database: ".mysql_error()); $id = $_GET['id']; if(!isset($id) || empty($id)){ die("Please select your image!"); }else{ // Incase my items did not work uncomment the below and try that: // ini_set("memory_limit", "32M"); // set the memory limit to 32M to see if that is the issue. $query = mysql_query('SELECT `image`, `type` FROM `tbl_images` WHERE `userid`= "'.$id.'"'); // added type here cause you use it later. $row = mysql_fetch_assoc($query); // $content = $row['image']; // Why do this? $im = imagecreatefromstring($row['image']); // or die not needed this is not a sql statement. unset($row['image']); // hopefully clear up memory $x = imagesx($im); $y = imagesy($im); $desired_width = 300; $desired_height = ($y * ($desired_width/$x)); $new = imagecreatetruecolor($desired_width, $desired_height); // or die not needed you are not running sql here. imagecopyresampled($new, $im, 0, 0, 0, 0, $desired_width, $desired_height, $x, $y); // or die not needed you are not running sql here. imagedestroy($im); unset($im); // for good measure // you never pulled type out of the DB, added that column to the query so this part would work. header('Content-type: ' . $row['type'] .''); imagejpeg($new, null, 85); } ?> Some basic items added to increase/improve performance. See what happens.
-
Post your table structure. This should also of been posted in the MySQL Help section, as an FYI.
-
So the image uploads...we would not need to see the upload script then. Where is the script that fetches the image and displays it?
-
still cant get image to dispaly from image path
premiso replied to justAnoob's topic in PHP Coding Help
I take it this is what you are after: $images = glob($row['imgpath']. "{*.gif, *.jpg, *.png}", GLOB_BRACE); foreach ($images as $image) { echo "<img src='{$image}' />"; // either that or echo "<img src='{$row['imgpath']}{$image}' />"; (whichever one works) } -
Not much of a chance, but if your code has an exploit and someone can return the DB Values the password is not stored as hashed text. Thus anyone can get into anyone else's account. Hashing the password will make sure no one can ever see the password period. This is a huge security measure. I would have to signup for a site to find out my password is not hashed, because a lot of people tend to use the same password for other sites, so I basically just gave you a password you could use to exploit me. I see it as a prevention from you or an admin on your end from going Rogue with the passwords.
-
$_POST[] while using a class and a name in the <tag>
premiso replied to thewooleymammoth's topic in PHP Coding Help
In the form section you are outside of PHP, not sure how it ever worked to be honest. <form method="post"> <textarea onkeydown="return catchTab(this,event)" rows="50" id="myCpWindow" class="codepress <?php echo $extension;?>" wrap="off" name="<?php echo $pass;?>"><?php echo $contents; ?></textarea> <input type="submit" value="save" name="save"> </form> Try that and see if it works. -
I doubt you understand what I just did, or eve tried it. Anyhow your answer is simple. <?php $picname = $_GET['picname']; $root = "images/"; $image = glob($root . $picname . ".*"); if (!is_array($image) || count($image) < 1) { $image[0] = "no-image.gif"; // make sure you have this file incase there is no image found. } header("Location: images/" . $image); ?> Will redirect you, thus changing the url etc. That would be the only way to do what you have just described in the above. You cannot change the url without doing a redirect or formal submital. As far as will this work if you just include that URL in an image tag, I have no clue. I think it would, but yea. The only way to find out is for you to test it.
-
Make your folder names have - or _ in them, so Pan-Cakes I take it you want to do this for SEO Reasons. That is the best way to do it. A space is not kosher as it breaks the structure to say and causes you to have to use %20 for it to work. Convert your folder names to have - or _ in them whereever there is a space, then you can simply use a str_replace on space characters and convert them to whichever character you have chosen.
-
What exactly are you trying to do? Get an image to display when you goto your URL? <?php $picname = $_GET['picname']; $root = "images/"; $image = glob($root . $picname . ".*"); if (!is_array($image) || count($image) < 1) { $image[0] = "no-image.gif"; // make sure you have this file incase there is no image found. } $image = $image[0]; $type = end(explode(".", $image)); $size = filesize($image); ob_start(); header('Last-Modified: '.date('r')); header('Accept-Ranges: bytes'); header('Content-Length: '.$size); header('Content-Type: image/' . $type); readfile($image); ob_end_flush(); ?> The code is untested, but that is what I gather you are after.
-
AJAX to replace the use of header("Location: ")
premiso replied to jBooker's topic in Javascript Help
jQuery PHP Validation Look into using jQuery framework, it makes Ajax that much easier. There are plenty examples of how to get what you are after online. -
You want to look into Paypal IPN. Basically once the transaction is made the IPN lets you know and you can update your database for that user to give them access.
-
AJAX would be my first suggestion to look into, but that may be slow. You may want to look into a Java or Flash alternative, as that should be better suited for this.
-
You need to modify this as suggested above: $images = glob($path . "{*.gif,*.jpg}", GLOB_BRACE); Add the GLOB_BRACE to it and see what happens.
-
So your script is not finding the record to update in the table. Simple as that. What is returned from the "sql is " statement ? For debugging instead of just echoing out 1 2 etc, try this: (I would also stick to my function, it is way less error proned.) $return = insert($uid,$dist,$pb); if ($return === true) echo "The database should have been updated."; else echo "The database was not updated.<br />pb was {$pb}<br />dist was {$dist}<br />uid was {$uid}."; See what gets returned. Your function is never getting passed the if statements cause you are passing in bad data.