zq29
-
Posts
2,752 -
Joined
-
Last visited
-
Days Won
1
Posts posted by zq29
-
-
Not as straight forward as you may think, you'll have to evaluate the type of file and the run the correct functions...
[code]$pos = strrpos($image,".");
$ext = substr($image,$pos);
switch($ext) {
case ".jpg":
$src = ImageCreateFromJpeg($image);
$dst = ImageCreate($tn_width,$tn_height);
ImageCopyResized($dst, $src, 0, 0, 0, 0,
$tn_width,$tn_height,$width,$height);
header('Content-type: image');
ImageJpeg($dst, null, -1);
ImageDestroy($src);
ImageDestroy($dst);
break;
case ".gif":
$src = ImageCreateFromGif($image);
$dst = ImageCreate($tn_width,$tn_height);
ImageCopyResized($dst, $src, 0, 0, 0, 0,
$tn_width,$tn_height,$width,$height);
header('Content-type: image');
ImageGif($dst, null, -1);
ImageDestroy($src);
ImageDestroy($dst);
break;
}[/code]Thats just a basic example, you'd make it a bit more efficient that that though ;) -
Can't you just run a str_replace("-","",$string) on it beforehand?
-
I'd rearrange the following:
[code]if (isset($_POST['Submit'])) {
// POST variables
$section = $_POST['section'];
$added_by = $_POST['added_by'];
$headline = $_POST['headline'];
$opening = $_POST['opening'];
$body_text = $_POST['body_text'];
if(empty($_POST['opening']) || empty ($_POST['body_text'])) {
$error = "There is an error";
} else {
$query = "INSERT INTO cms_stories(section,added_by,headline,opening,body_text) VALUES
('$section','$added_by','$headline','$opening','$body_text')";
$msg = "A new Story has been added to the database - Please Click
<a href=\"http://index\">Here</a> to return to the main menu";
//You'd probably want to unset all of the variables you created above here on success - unset();
}
}
?>[/code]
Then to have the defaults on your inputs:
[code]<input type="text" size="48" maxlength="255" name="headline" <?php if(isset($headline)) echo "value='$headline'"; ?>/>[/code]
Hope this helps. -
[a href=\"http://www.devarticles.com/c/a/MySQL/Creating-a-Voting-Poll-With-PHP-And-MySQL-Part-1/\" target=\"_blank\"]Creating a Voting Poll With PHP and MySQL[/a]
-
[code]if (isset($_POST['Submit']) && (empty($_POST['opening']) || empty ($_POST['body_text'])))
{
$error = "There is an error";
}[/code]
[b]EDIT:[/b] Damnit Orio! You beat me to it again! haha -
Do you know if port 80 is being routed to your machine?
-
Have you configured Apache to use PHP?
You'll need to add the following lines within the relevent sections of httpd.conf:
[code]ScriptAlias /php/ "path/to/php/"
AddType application/x-httpd-php .php
Action application/x-httpd-php /path/to/php/executable
[/code] -
I know you can force users to a 403 (Forbidden) by using mod_rewrite in a .htaccess file. If that interests you, check the mod_rewrite section of the Apache manual, its in there somewhere.
-
Are you both measuring it in the same way? Is one of you measuring in KiB and the other in KB?
-
There is no mail server included with Apache that I know of.
Yes, you can have more than one domain pointing at the server, look up the Virtual Hosts section of the Apache manual. -
strstr() is used to find first occurrence of a string within a string. You will have better luck with str_replace(). You can use it like so: str_replace(","," ",$string);
-
When parsing XML, I personally have used the xml_parse_into_struct() function. Look it up in the manual, there are a couple of examples of how you can use it.
-
Moved to our Misc forum. The PHP Help forum is for requesting help with scripts that you are currently developing.
-
[!--quoteo(post=385439:date=Jun 18 2006, 11:01 PM:name=michaellunsford)--][div class=\'quotetop\']QUOTE(michaellunsford @ Jun 18 2006, 11:01 PM) [snapback]385439[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Really? This opens a whole new can of worms. Few questions for you.
Which version of MacOS?
Does your display adapter support core image?
32 bit color depth?
[/quote]
OS X (10.4.6)
No core image support (ATI Radeon 9200) - Running a non-Apple display, Iiyama 17" TFT.
32 bit colour depth.
Its not really high specced, its a PPC based MacMini (1.42GHz/1GB), my first Mac :) -
Do you mean you want an infinite amount of sub-categories within sub-categories?
-
[!--quoteo(post=385414:date=Jun 18 2006, 09:22 PM:name=yarub)--][div class=\'quotetop\']QUOTE(yarub @ Jun 18 2006, 09:22 PM) [snapback]385414[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Oh. I knew that too. Haha. Thanks a lot for your help.
[/quote]
No problem [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /] -
I guess you'd need to run the content through a couple of regular expressions to pull out the bits that you need.
-
You can convert to entities with htmlentities() or you can escape the quotes with str_replace()
-
You can either escape them with a backslash, or use their HTML entity instead.
[code]INSERT INTO `table` (`id`,`something`) VALUES ('1','There\'s a hole in my pocket')[/code]
[code]INSERT INTO `table` (`id`,`something`) VALUES ('1','There':s a hole in my pocket')[/code]
{Replace the colon with a semi-colon in ':) -
I think it's possible to do this with cURL (libcurl) and PHP. Search Google for "cURL tutorial" the official site should be at the top, or check out the curl functions in the PHP manual (I think there's some in there)
-
This might be the long way around it, but it works...
[code]<?php
$file = file("file.txt");
foreach($file as $line)
if(strpos($line,"TITLE") === 0)
echo "<p>$line</p>";
?>[/code] -
You can get the time with the date() function, then edit the text file with fopen(), fwrite() and fclose(). Then you can ftp the file with ftp_connect(), ftp_login(), ftp_put() and ftp_close().
-
Have you tried using exec() or system() ?
-
Are you positive that the needle exists in the haystack?
I don't see any problems with how you are using strpos(), well, no obvious ones...
validating arrays from a form
in PHP Coding Help
Posted