Re: [PHP-DB] Can't Insert more than 1 record
Hi KJ On 03 Apr,2003 at 22:18 Keven Jones wrote: snip attempt after the 1st fails. I have to delete the existing row in order to add a new record. /snip Sounds like you have auto-incremented unique indices to me - are you always trying to insert with an index of 1 ? Without seeing the code its hard to say snip Anyone know what I am doing incorrectl? KJ /snip -- Ronan e: [EMAIL PROTECTED] t: 01903 739 997 w: www.thelittledot.com The Little Dot is a partnership of Ronan Chilvers and Giles Webberley -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] How to use a Class?
Hi Shantanu To be honest you'd be far better off doing this manually, rather than using someone elses code - quite important bits and pieces of sql and db access logic which you'll need to learn, but On 03 Apr,2003 at 20:18 Shantanu Oak wrote: snip the following code mentioned on the page, $mysearch = new MysqlSearch; $mysearch-setidentifier(MyPrimaryKey); $mysearch-settable(MyTable); $results_array = $mysearch-find($mysearchterms); I am getting the text array() as a result. /snip This is php telling you that the variable is of the array type, ie: it is a variable containing many indexed values. BTW, have you changed the setidentifier() and settable() values to the correct ones for your db ? (just checking). snip Can someone explain to me how to use it and get result. /snip A handy utility function is var_dump(). This will echo out the contents of any variable type. So to display the contents of your $results_array variable you would do:- ?php echo pre; var_dump($results_array); echo/pre; ? That'll show you the contents of the array and what its structure looks like. Displaying it in a controlled form is just a matter of finding out the structure of the array and looping through it using one of php's many many loop constructs / array access functions. Have a read about arrays on www.php.net - they are very useful once you get the hang of them ... ;-) snip Shantanu Oak [EMAIL PROTECTED] http://www.shantanuoak.com Cheers -- Ronan e: [EMAIL PROTECTED] t: 01903 739 997 w: www.thelittledot.com The Little Dot is a partnership of Ronan Chilvers and Giles Webberley -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Can't Insert more than 1 record
If you are violating a primary key, try creating a sequence, and then passing this sequence name (i.e. nID.NextVal) as your parameter in the values of your query. This will automatically give you a new unique number in the sequence you created. Lex -Original Message- From: Keven Jones [mailto:[EMAIL PROTECTED] Sent: Thursday, April 03, 2003 5:18 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] Can't Insert more than 1 record Hello All, I am having a problem inserting records into my Database. I am passing fields from a FORM to my php program that adds 1 record to my DB. It will create the first attempt just fine, however any attempt after the 1st fails. I have to delete the existing row in order to add a new record. Anyone know what I am doing incorrectl? KJ _ Tired of spam? Get advanced junk mail protection with MSN 8. http://join.msn.com/?page=features/junkmail -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Permission Denied; Upload
Thanking in advance, Hi all- very new to php, and at the risk of being spoon fed here, I beg for your patience in advance. I am trying to have an entry page for user input/ pic upload into MySQL/win2k (www.sammiesmodels.com/entry.php ). I get this error during test of the above page: Warning: Unable to open '' for reading: Permission denied in C:\SammiWWW\entry.php on line 27 Couldn't copy the file! The upload folder, Temp sits in the root www dir, and the user has all permissions granted (or do i?) in the DB. Below is the syntax to the Entry page: *** html head titlePortfolio Entry /title meta http-equiv=Content-Type content=text/html; charset=iso-8859-1 /head body bgcolor=#FFEBEB ?php if ($submit) { $db=mysql_connect(66.220.69.20,admin,snoddy); mysql_select_db(sammies models,$db); $sql=INSERT INTO models (first, last, age, email, location, eye, hair, experience, aspirations, mtype, picname1, picname2, picname3, picname4, picname5, picname6, picname7, picname8) VALUES ('$first','$last','$age','$email','$location','$eye','$hair','$experience','$aspirations','$mtype','$picname1','$picname2','$picname3','$picname4','$picname5','$picname6','$picname7','$picname8'); mysql_query($sql) or die(mysql_error()); // if $_FILES['img1'] isn't empty, try to copy the file if ($_FILES['picname1'] != ) { // copy the file to a directory or //die and print an error message // NOTE! if you're on a Windows machine, // use Windows pathnames, like so: // copy($_FILES[picname1][$first], C:\\sammiwww\\directory\\path\\.$_POST[img1_name]); copy($_FILES['picname1']['$first . temp'], C:\\sammiwww\\upload\\.$_FILES['picname1']['$first']) or die(Couldn't copy the file!); } else { // if $_FILES['picname1'] was empty, die and let us know why die(No input file specified); } ? echo First: $firstbr\n; echo Last: $lastbr\n; echo Age: $agebr\n; echo Email: $emailbr\n; echo Location: $locationbr\n; echo Eye color: $eyebr\n; echo Hair color: $hairbr\n; echo Experience: $experiencebr\n; echo Aspirations: $aspirationsbr\n; echo Media Type: $mtypebr\n; echo Photo 1: $picname1br\n; echo img src=c:/sammiwww/pic/$picname1br\n; echo Photo 2: $picname2br\n; echo img src=c:/sammiwww/pic/$picname2br\n; echo Photo 3: $picname3br\n; echo img src=c:/sammiwww/pic/$picname3br\n; echo Photo 4: $picname4br\n; echo img src=c:/sammiwww/pic/$picname4br\n; echo Photo 5: $picname5br\n; echo img src=c:/sammiwww/pic/$picname5br\n; echo Photo 6: $picname6br\n; echo img src=c:/sammiwww/pic/$picname6br\n; echo Photo 7: $picname7br\n; echo img src=c:/sammiwww/pic/$picname7br\n; echo Photo 8: $picname8br\n; echo img src=c:/sammiwww/pic/$picname8br\n; echo bcenterThank you for registering,nbsp; $first /b/centerp; ? pcenter/p center a href=http://www.sammiesmodels.com; target=_selfReturn to Sammies Models Home/a ? } // display form else { ? /center center font face=Georgia, Times New Roman, Times, serifstrongSubmit Your Portfolio Here:/strong/font /center form enctype=multipart/form-data name=entry method=POST action=?php echo $PHP_SELF? nbsp; table width=95% border=0 cellspacing=0 cellpadding=0 tr td width=14%strongFirst Name:/strong/td td width=43%input name=first type=text size=30 maxlength=45/td td width=43%font size=2 face=Arial, Helvetica, sans-serifnbsp;/font/td /tr tr tdstrongLast Name: /strong/td tdinput name=last type=text size=30 maxlength=45/td tdfont size=2 face=Arial, Helvetica, sans-serifstrong*Last name shall not be used on the website, but/strong/font/td /tr tr tdstrongAge:/strong/td tdinput name=age type=text size=30 maxlength=3/td tdfont size=2 face=Arial, Helvetica, sans-serifstrongfor internal use only./strong/font/td /tr tr tdstrongEmail:/strong/td tdinput name=email type=text size=30 maxlength=45/td tdfont size=2 face=Arial, Helvetica, sans-serifnbsp;/font/td /tr tr tdstrongLocation:/strong/td tdinput name=location type=text id=location size=30 maxlength=60/td tdfont size=2 face=Arial, Helvetica, sans-serifstrong*Location- please do not be specific, but only/strong/font/td /tr tr tdstrongEye Color/strong/td tdinput name=eye type=text id=eye size=30 maxlength=45/td tdfont size=2 face=Arial, Helvetica, sans-serifstrongstate or region./strong/font/td /tr tr tdstrongHair Color:/strong/td tdinput name=hair type=text id=hair size=30 maxlength=45/td tdfont size=2 face=Arial, Helvetica, sans-serifnbsp;/font/td /tr tr td valign=topstrongExperience:/strong/td tdtextarea name=experience cols=60 rows=10 id=experience/textarea/td td valign=topfont size=2 face=Arial, Helvetica, sans-serifstrong* Any experience pertaining to your talent aspirations- school plays, photoshoots, etc../strong/font/td /tr tr td valign=topstrongAspirations:/strong/td tdtextarea name=aspirations cols=60 rows=10 id=aspirations/textarea/td td valign=topfont size=2 face=Arial, Helvetica,
RE: [PHP-DB] Permission Denied; Upload
Good job posting your username, password and server IP. I just logged into your database. Change your password immediately. -Original Message- From: John [mailto:[EMAIL PROTECTED] Sent: Friday, April 04, 2003 10:12 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] Permission Denied; Upload Thanking in advance, Hi all- very new to php, and at the risk of being spoon fed here, I beg for your patience in advance. I am trying to have an entry page for user input/ pic upload into MySQL/win2k (www.sammiesmodels.com/entry.php ). I get this error during test of the above page: Warning: Unable to open '' for reading: Permission denied in C:\SammiWWW\entry.php on line 27 Couldn't copy the file! The upload folder, Temp sits in the root www dir, and the user has all permissions granted (or do i?) in the DB. Below is the syntax to the Entry page: *** html head titlePortfolio Entry /title meta http-equiv=Content-Type content=text/html; charset=iso-8859-1 /head body bgcolor=#FFEBEB ?php if ($submit) { $db=mysql_connect(66.220.69.20,admin,snoddy); mysql_select_db(sammies models,$db); $sql=INSERT INTO models (first, last, age, email, location, eye, hair, experience, aspirations, mtype, picname1, picname2, picname3, picname4, picname5, picname6, picname7, picname8) VALUES ('$first','$last','$age','$email','$location','$eye','$hair','$exp erience','$aspirations','$mtype','$picname1','$picname2','$picname 3','$picname4','$picname5','$picname6','$picname7','$picname8'); mysql_query($sql) or die(mysql_error()); // if $_FILES['img1'] isn't empty, try to copy the file if ($_FILES['picname1'] != ) { // copy the file to a directory or //die and print an error message // NOTE! if you're on a Windows machine, // use Windows pathnames, like so: // copy($_FILES[picname1][$first], C:\\sammiwww\\directory\\path\\.$_POST[img1_name]); copy($_FILES['picname1']['$first . temp'], C:\\sammiwww\\upload\\.$_FILES['picname1']['$first']) or die(Couldn't copy the file!); } else { // if $_FILES['picname1'] was empty, die and let us know why die(No input file specified); } ? echo First: $firstbr\n; echo Last: $lastbr\n; echo Age: $agebr\n; echo Email: $emailbr\n; echo Location: $locationbr\n; echo Eye color: $eyebr\n; echo Hair color: $hairbr\n; echo Experience: $experiencebr\n; echo Aspirations: $aspirationsbr\n; echo Media Type: $mtypebr\n; echo Photo 1: $picname1br\n; echo img src=c:/sammiwww/pic/$picname1br\n; echo Photo 2: $picname2br\n; echo img src=c:/sammiwww/pic/$picname2br\n; echo Photo 3: $picname3br\n; echo img src=c:/sammiwww/pic/$picname3br\n; echo Photo 4: $picname4br\n; echo img src=c:/sammiwww/pic/$picname4br\n; echo Photo 5: $picname5br\n; echo img src=c:/sammiwww/pic/$picname5br\n; echo Photo 6: $picname6br\n; echo img src=c:/sammiwww/pic/$picname6br\n; echo Photo 7: $picname7br\n; echo img src=c:/sammiwww/pic/$picname7br\n; echo Photo 8: $picname8br\n; echo img src=c:/sammiwww/pic/$picname8br\n; echo bcenterThank you for registering,nbsp; $first /b/centerp; ? pcenter/p center a href=http://www.sammiesmodels.com; target=_selfReturn to Sammies Models Home/a ? } // display form else { ? /center center font face=Georgia, Times New Roman, Times, serifstrongSubmit Your Portfolio Here:/strong/font /center form enctype=multipart/form-data name=entry method=POST action=?php echo $PHP_SELF? nbsp; table width=95% border=0 cellspacing=0 cellpadding=0 tr td width=14%strongFirst Name:/strong/td td width=43%input name=first type=text size=30 maxlength=45/td td width=43%font size=2 face=Arial, Helvetica, sans-serifnbsp;/font/td /tr tr tdstrongLast Name: /strong/td tdinput name=last type=text size=30 maxlength=45/td tdfont size=2 face=Arial, Helvetica, sans-serifstrong*Last name shall not be used on the website, but/strong/font/td /tr tr tdstrongAge:/strong/td tdinput name=age type=text size=30 maxlength=3/td tdfont size=2 face=Arial, Helvetica, sans-serifstrongfor internal use only./strong/font/td /tr tr tdstrongEmail:/strong/td tdinput name=email type=text size=30 maxlength=45/td tdfont size=2 face=Arial, Helvetica, sans-serifnbsp;/font/td /tr tr tdstrongLocation:/strong/td tdinput name=location type=text id=location size=30 maxlength=60/td tdfont size=2 face=Arial, Helvetica, sans-serifstrong*Location- please do not be specific, but only/strong/font/td /tr tr tdstrongEye Color/strong/td tdinput name=eye type=text id=eye size=30 maxlength=45/td tdfont size=2 face=Arial, Helvetica, sans-serifstrongstate or region./strong/font/td /tr tr tdstrongHair Color:/strong/td tdinput name=hair type=text id=hair size=30 maxlength=45/td tdfont size=2 face=Arial, Helvetica, sans-serifnbsp;/font/td /tr tr td valign=topstrongExperience:/strong/td tdtextarea
[PHP-DB] Re: Permission Denied; Upload
You need to give the user permission to write in the destination directory, you can do this by using: chmod 666 directoryname John [EMAIL PROTECTED] escribió en el mensaje news:[EMAIL PROTECTED] Thanking in advance, Hi all- very new to php, and at the risk of being spoon fed here, I beg for your patience in advance. I am trying to have an entry page for user input/ pic upload into MySQL/win2k (www.sammiesmodels.com/entry.php ). I get this error during test of the above page: Warning: Unable to open '' for reading: Permission denied in C:\SammiWWW\entry.php on line 27 Couldn't copy the file! The upload folder, Temp sits in the root www dir, and the user has all permissions granted (or do i?) in the DB. Below is the syntax to the Entry page: *** html head titlePortfolio Entry /title meta http-equiv=Content-Type content=text/html; charset=iso-8859-1 /head body bgcolor=#FFEBEB ?php if ($submit) { $db=mysql_connect(66.220.69.20,admin,snoddy); mysql_select_db(sammies models,$db); $sql=INSERT INTO models (first, last, age, email, location, eye, hair, experience, aspirations, mtype, picname1, picname2, picname3, picname4, picname5, picname6, picname7, picname8) VALUES ('$first','$last','$age','$email','$location','$eye','$hair','$experience',' $aspirations','$mtype','$picname1','$picname2','$picname3','$picname4','$pic name5','$picname6','$picname7','$picname8'); mysql_query($sql) or die(mysql_error()); // if $_FILES['img1'] isn't empty, try to copy the file if ($_FILES['picname1'] != ) { // copy the file to a directory or file://die and print an error message // NOTE! if you're on a Windows machine, // use Windows pathnames, like so: // copy($_FILES[picname1][$first], C:\\sammiwww\\directory\\path\\.$_POST[img1_name]); copy($_FILES['picname1']['$first . temp'], C:\\sammiwww\\upload\\.$_FILES['picname1']['$first']) or die(Couldn't copy the file!); } else { // if $_FILES['picname1'] was empty, die and let us know why die(No input file specified); } ? echo First: $firstbr\n; echo Last: $lastbr\n; echo Age: $agebr\n; echo Email: $emailbr\n; echo Location: $locationbr\n; echo Eye color: $eyebr\n; echo Hair color: $hairbr\n; echo Experience: $experiencebr\n; echo Aspirations: $aspirationsbr\n; echo Media Type: $mtypebr\n; echo Photo 1: $picname1br\n; echo img src=c:/sammiwww/pic/$picname1br\n; echo Photo 2: $picname2br\n; echo img src=c:/sammiwww/pic/$picname2br\n; echo Photo 3: $picname3br\n; echo img src=c:/sammiwww/pic/$picname3br\n; echo Photo 4: $picname4br\n; echo img src=c:/sammiwww/pic/$picname4br\n; echo Photo 5: $picname5br\n; echo img src=c:/sammiwww/pic/$picname5br\n; echo Photo 6: $picname6br\n; echo img src=c:/sammiwww/pic/$picname6br\n; echo Photo 7: $picname7br\n; echo img src=c:/sammiwww/pic/$picname7br\n; echo Photo 8: $picname8br\n; echo img src=c:/sammiwww/pic/$picname8br\n; echo bcenterThank you for registering,nbsp; $first /b/centerp; ? pcenter/p center a href=http://www.sammiesmodels.com; target=_selfReturn to Sammies Models Home/a ? } // display form else { ? /center center font face=Georgia, Times New Roman, Times, serifstrongSubmit Your Portfolio Here:/strong/font /center form enctype=multipart/form-data name=entry method=POST action=?php echo $PHP_SELF? nbsp; table width=95% border=0 cellspacing=0 cellpadding=0 tr td width=14%strongFirst Name:/strong/td td width=43%input name=first type=text size=30 maxlength=45/td td width=43%font size=2 face=Arial, Helvetica, sans-serifnbsp;/font/td /tr tr tdstrongLast Name: /strong/td tdinput name=last type=text size=30 maxlength=45/td tdfont size=2 face=Arial, Helvetica, sans-serifstrong*Last name shall not be used on the website, but/strong/font/td /tr tr tdstrongAge:/strong/td tdinput name=age type=text size=30 maxlength=3/td tdfont size=2 face=Arial, Helvetica, sans-serifstrongfor internal use only./strong/font/td /tr tr tdstrongEmail:/strong/td tdinput name=email type=text size=30 maxlength=45/td tdfont size=2 face=Arial, Helvetica, sans-serifnbsp;/font/td /tr tr tdstrongLocation:/strong/td tdinput name=location type=text id=location size=30 maxlength=60/td tdfont size=2 face=Arial, Helvetica, sans-serifstrong*Location- please do not be specific, but only/strong/font/td /tr tr tdstrongEye Color/strong/td tdinput name=eye type=text id=eye size=30 maxlength=45/td tdfont size=2 face=Arial, Helvetica, sans-serifstrongstate or region./strong/font/td /tr tr tdstrongHair Color:/strong/td tdinput name=hair type=text id=hair size=30 maxlength=45/td tdfont size=2 face=Arial, Helvetica, sans-serifnbsp;/font/td /tr tr td valign=topstrongExperience:/strong/td tdtextarea name=experience cols=60 rows=10 id=experience/textarea/td td valign=topfont size=2 face=Arial, Helvetica, sans-serifstrong* Any experience pertaining to your talent aspirations- school plays, photoshoots, etc../strong/font/td /tr tr td
[PHP-DB] Offering alternatives in typing mistakes
Hello List, I'm currently doing a select like statement. No problem with that. But as no human being is perfect ;-) the input provided by the user is sometimes full of typing mistakes like informatoin, or informatin instead of information. I hope you know what I'm think about. Google offers you an alternative if google thinks you misspelled. Now my question, what is an algorithm for finding out which input was actually meant? I know I'll have to split the string like first letter than last letter, than second first etc. Is there a better solution, like taking the middle? I've already put some thought in it, but I see no reason to reinvent the wheel again. Has anybody any better ideas? I'm open to solutions. thx Jan Bro -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Re: Permission Denied; Upload
You should not make the directory world writeable, that is a security risk. You should chown it to the user the webserver runs as and make sure it is owner writeable. As a side note, a directory that is 666 is not traversable as it is missing the execution bit and you need to execute to get into it. -Original Message- From: Gustavo Del Castillo Meza [mailto:[EMAIL PROTECTED] Sent: Friday, April 04, 2003 12:10 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] Re: Permission Denied; Upload You need to give the user permission to write in the destination directory, you can do this by using: chmod 666 directoryname -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Permission Denied; Upload
Unable to open '' for reading: That means you're not actually sending a filename to be read! I get this error during test of the above page: Warning: Unable to open '' for reading: Permission denied in C:\SammiWWW\entry.php on line 27 Couldn't copy the file!
[PHP-DB] mail problem
hi i made a simple script to send e-mail to my mailing list it reads the e-mails from a text file and send it to them the problem that i want to send them once, not one by one which takes a lot of time cause i have a limited quota per day here is the script ?php $subject=subject; $sendmessage=hi; [EMAIL PROTECTED]; $fp = fopen(mails.txt, r); if (!$fp) { echo pstrongcan't Read emails. .Please try again later./strong/p/body/html; exit; } while (!feof($fp)) { $mail= fgets($fp, 200); mail($mail,$subject,$sendmessage,From: $from); echo $mail.br; } fclose($fp); ? can anyone help and can i use a smtp server instead? and if yes please tell me how, waiting for a reply thanks for your time
RE: [PHP-DB] Offering alternatives in typing mistakes
I'm currently doing a select like statement. No problem with that. But as no human being is perfect ;-) the input provided by the user is sometimes full of typing mistakes like informatoin, or informatin instead of information. I hope you know what I'm think about. Google offers you an alternative if google thinks you misspelled. Now my question, what is an algorithm for finding out which input was actually meant? I know I'll have to split the string like first letter than last letter, than second first etc. Is there a better solution, like taking the middle? I've already put some thought in it, but I see no reason to reinvent the wheel again. Has anybody any better ideas? I'm open to solutions. Doing a search on google for spelling suggestion algorithm turned up a few things. You may want to check them. You'll probably have to implement an outside program. The only way from within PHP that I can think of doing it is with soundex() and similar functions. I know MySQL implements something similar within it, so you can search for words whos soundex will match the soundex of the word the user supplied. ---John W. Holmes... PHP Architect - A monthly magazine for PHP Professionals. Get your copy today. http://www.phparch.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] variable within regular expression
Hi, This is the first time I've written to this list. If I'm not following accepted procedure, please let me know. I have a php query form in which the user input must be converted to a regular expression before querying the db. Something like this pseudo code: $var = $_GET['usr-input']; $var = '%$var%'; SELECT * FROM table WHERE field LIKE $var. I can't find the right syntax to make this work. Does anyone know? Thanks, Robbie Staufer -- -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* Robbie Staufer NCAR/SCD 1850 Table Mesa Dr. Rm. 42 Boulder, CO. 80305 (303) 497-1836 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] variable within regular expression
-Original Message- From: Robbie Staufer [mailto:[EMAIL PROTECTED] Sent: Friday, April 04, 2003 3:59 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] variable within regular expression I have a php query form in which the user input must be converted to a regular expression before querying the db. Something like this pseudo code: $var = $_GET['usr-input']; $var = '%$var%'; SELECT * FROM table WHERE field LIKE $var. I can't find the right syntax to make this work. Does anyone know? I think maybe the single quotes don't interpolate the value of the variable. In other words, let's say $var is 'fubar': $var = '%$var%'; // - is literally %$var% vs. $var = %$var%; // - is %fubar% Anyway, here's some of my code that is similar to (what I think) you're trying to do: if (isset($_GET['nstring'])) { $nstring = addslashes($_GET['nstring']); $squery = SELECT * FROM lead WHERE name LIKE '%{$nstring}%' ORDER BY source, ref_by, date DESC; $sresult = mysql_query($squery); } // etc... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] image resizing and saving
A single img src=script.php can only show a single image. If your script.php generates two complete images, then I would think the browsers would choke, but perhaps they fail gracefully and only show you the first one. If you want two images, you need 2 img src... tags and thus two calls to your resizing script. As for saving the images to disk, see the documentation for imagejpeg(). It takes a second optional parameter which is the filename to save the image as. -Rasmus On Sat, 5 Apr 2003, Fedde wrote: heyas i have the following code to resize an image to any wanted size: ? //$image2 = image.jpg; function resizeThatPic($image2){ $maxheight = 100; $maxwidth = 100; $size = getimagesize ($image2); $ratio = ($maxheight/$size[1]); $constrain_width = ($ratio * $size[0]); $constrain_height = ($ratio * $size[1]); if ($constrain_width $maxwidth){ $mess = ($maxwidth/$size[0]); $constrain_width = ($ratio * $size[0]); $constrain_height = ($ratio * $size[1]); } $image = imagecreate($constrain_width,$constrain_height); $colorblue = imagecolorallocate($image, 0, 0, 255); imagefill($image, 0,0, $colorblue); if(!($image2 = @imagecreatefromjpeg($image2))){ $image = imagecreate($constrain_width,$constrain_height); $colorwhite = imagecolorallocate($image, 255, 255, 255); $colorblack = imagecolorallocate($image, 0, 0, 0); imagefill($image, 0, 0, $colorwhite); imagestring($image, 4, 10, 10, Couldn't load image!, $colorblack); header(Content-type: image/jpeg); imagejpeg($image); exit(); } imagecopyresized($image, $image2 , 0, 0, 0, 0, $constrain_width, $constrain_height, imagesx($image2), imagesy($image2)); header (Content-type: image/jpeg); imagejpeg($image); } ? question 1: I want to use this in an other page: ? require (imagetest.php); resizeThatPic(image.jpg); resizeThatPic(image2.jpg); ? The problem is that this only shows a resized image.jpg and no image2.jpg at all, why is that? and what can i do about it? question 2: Is there a way to save the resized image to another directory on the server? Thanks in advance :) Fedde -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Offering alternatives in typing mistakes
On Saturday 05 April 2003 04:11, Jan Bro wrote: I'm currently doing a select like statement. No problem with that. But as no human being is perfect ;-) the input provided by the user is sometimes full of typing mistakes like informatoin, or informatin instead of information. I hope you know what I'm think about. Google offers you an alternative if google thinks you misspelled. Now my question, what is an algorithm for finding out which input was actually meant? I know I'll have to split the string like first letter than last letter, than second first etc. Is there a better solution, like taking the middle? I've already put some thought in it, but I see no reason to reinvent the wheel again. Has anybody any better ideas? I'm open to solutions. If you're going to be running on some *nix platform then have a look at the chapter on pspell. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-db -- /* Let us never negotiate out of fear, but let us never fear to negotiate. -- John F. Kennedy */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php