Ok, so I'm trying to create a WBMP image on the fly. I want to add text to an already existing image. for some reason my code isn't working, it's just outputting the original image. here's my code:
So I made this AIM bot using the PHP:TOC class that plays a word game. See, you give it a word, let's say "cow" and he replies with another 3 letter word that's different from your word by a letter, like "how". It gets its words from a list I found on the internet, about 26,870 words.
Here's the thing: I wanna get it to learn new words. Let's say someone says "mow" after "cow" but it's not in the listing. Right now, it'll say that "mow" isn't a real word, but I want some way of verifying if in fact it is a real word, and adding it to the list. Is there some web API for dictionary.com or something similar I could talk to with PHP?
I'm think Google API might do it, but I haven't gotten to poke around with it yet. Anyone familiar with that API? How easy is it to use with PHP5?
Background
I started my career with C then move to C++ and finally stuck on with Java ever since late 1995. I learnt other languages like VB, Basic, Fortran, Pascal (I loved it!) and recently php and some smattering of perl, lisp etc. Yes I also dabbled in C#. As you know structurally all [...]
Do any of you bright minds know WHY some programmers decide to use Decimal Unicode notation (e.g., Firefox), whereas others decide to use Hex Unicode notation (e.g. the Gnome/libxml2/xmllint folks)?
My wish is that:
1.) They had all gotten together and decided on just one, 2.) They had all chosen Hex, padded on the left with zeroes so that all characters are represented by a full four digits (e.g.  rather than  for Â), the latter of which is NOT conformant to the Unicode specification, which requires four to six digits, not bloody darn one, two or three).
I know they are functionally equivalent, and I know it's a simple mathematical calculation to go from one to the other, and that Perl and PHP both probably have built-in functions that I could use to convert from one to the other, but GRRRR. I long for consistency, and god forbid, standards-compliance.
Also, why if Firefox smart enough to take UTF-8 input in an HTML form and convert it automatically to Decimal Unicode (which mySQL 4.0 can actually understand), but Safari is not smart enough (and of course, neither is I.E., duh).
--
Don't get me wrong, I don't hate Safari. Safari is FAR better than Firefox at rendering certain difficult Unicode glyphs, like Devanagari (Sanskrit) that has internal HTML markup inside conjunct consonants (Opera 6.03 comes close on this). However, when it comes to Hebrew, Greek, and Romanian (the others I've had to deal with recently), Firefox is just hands-down better.
During the install process for php4-gd2, I was prompted to modify php.ini with "extension=gd.so". I answered "Yes". I then verified that the line was added to php.ini.
And if I create a test PHP script utilizing a GD function, I get the following:
Fatal error: Call to undefined function: imagecreatefrompng() in /var/www/cparker15/test.php on line 3
Anybody know what I might be doing wrong? I've Googled and have come up with nothing. I'm thinking of asking on debian-user, but the last time I posted there, I didn't get any answers.
Lazy formatting cause I cant recall how to show code, so here is the quick and dirty. Inherited site with clickable menu, client is nitpicking over the fact that the menu does not disapear when you click on another object. (source http://gateway.rossoptical.com/nav.htm ) is there a simple way to pull this off? Drop down menu's with mouse over focus is not what the client wants (sadly).
script type="text/javascript" function toggle(obj) { var menu = document.getElementById(obj); if (menu.style.display == 'none'){ menu.style.display = 'block'; } else { menu.style.display = 'none'; } } /script
a href="#" onclick="toggle('menu2')">DOUBLETS and TRIPLETS/a ul style="display: none;" li a href="./php/product-doublets_standard_achromats.php" target="mainFrame" Standard Achromats /a /li> li a href="./php/product-doublets_precision_aplanats.php" target="mainFrame" Precision Aplants /a /li> li a href="./php/product-doublets_negative_achromats.php" target="mainFrame" Negative Achromats /a /li> li a href="./php/product-doublets_laser_achromats.php" target="mainFrame" Laser Achromats /a /li> li a href="./php/product-steinheil_triplets.php" target="mainFrame" Steinheil Triplets /a /li> /ul
My boss called me over and asked me to write a T-SQL function on behalf of our web guy, that would arbitrarily strip out all HTML tags from a VARCHAR. In any other language like PHP, Perl, etc., I'd employ Regular Expressions to do this globally. However, T-SQL only really has PATINDEX and CHARINDEX, those aren't all that powerful.
I did wind up coming up with an iterative solution, which I thought I'd share with everyone to get suggestions and feedback.
CREATE TABLE #tmpText ( id INT IDENTITY(1, 1), data varchar(4000) )
INSERT INTO #tmpText (data) VALUES ('this is some html')
INSERT #tmpText VALUES ( '
Some Name
SOME HTML text after the body' )
INSERT #tmpText VALUES ( 'Another Name
Another HTML text after the body' )
-- WHILE a '<' and '>' pair are present and the former's position is less than the latter's position value -- Find a '<' then the next '>' positions, and run a stuff to remove whatever's in between!
BEGIN TRANSACTION WHILE EXISTS (SELECT 1 FROM #tmpText WHERE PATINDEX('%<%>%', data) > 0 ) BEGIN UPDATE #tmpText SET data = STUFF(data, PATINDEX('%<%>%', data), CHARINDEX('>', data) - PATINDEX('%<%>%', data) + 1, '') WHERE PATINDEX('%<%>%', data) > 0 END
SELECT * FROM #tmpText
ROLLBACK
I'm going to keep trying to dissect this in order to come up with a cleaner, non-iterative solution. If anyone else already has a function that does this in one fell-swoop, rather than via looping, PLEASE share it! :-)
UPDATE: I've made further code changes to handle a few odd circumstances and have finished the function. Thought I'd share it with everyone for a "peer review." Please comment away!
ALTER FUNCTION uf_stripHTML ( @strHTML varchar(8000), @flgFormat int = 1 ) RETURNS varchar(8000) AS BEGIN
-------------------------------------------------------------------------------------------------- -- Date Written: 02-10-2005 -- Purpose: Arbitrarily strip all text between all pairs of < > tags. This SHOULD be -- HTML but theoretically could be other data? ---------------------------------------------------------------------------------------------------- -- Input Parameters: @strHTML = The string that we are stripping HTML from. -- @flgFormat = If set to 1 (DEFAULT), then the function will attempt to -- preserve basic formatting by detecting non-breaking spaces, start and end -- paragraph tags, and break-return tags, and replacing them with their -- ASCII equivalents. ---------------------------------------------------------------------------------------------------- -- Comments: This solution employs an iterative algorithm to repeatedly sweep through -- the variable's text, removing HTML tags one at a time. ----------------------------------------------------------------------------------------------------
DECLARE @ltPosition int
-- If flgFormat is 1, then replace pre-determined list of tags and characters with -- corresponding values! IF @flgFormat = 1 BEGIN SET @strHTML = REPLACE(@strHTML, '
', CHAR(10) + CHAR(13)) SET @strHTML = REPLACE(@strHTML, '
', CHAR(10) + CHAR(13)) SET @strHTML = REPLACE(@strHTML, ' ', CHAR(10)) END
-- STRIP OUT HTML HERE WHILE (SELECT PATINDEX('%<[^ ]%>%', @strHTML)) > 0 BEGIN -- Must search for the correct '>' because any unmatched ones will cause errors! SET @ltPosition = 0 WHILE (PATINDEX('%<[^ ]%>%', @strHTML) > @ltPosition) SET @ltPosition = CHARINDEX('>', @strHTML, @ltPosition + 1)
SET @strHTML = STUFF(@strHTML, PATINDEX('%<[^ ]%>%', @strHTML), @ltPosition - PATINDEX('%<[^ ]%>%', @strHTML) + 1, '') END
Can anyone recommend a good PHP based photo gallery, that's easily editable (header and footer), and can handle multiple file (or ideally folder) uploads at once.
Now that my cookie problem is all fixed, I find myself with another delimma. Already. ;)
I'd like to have an include on the main page of my site that would be something along the lines of, "Hello Name, you have 0 new private messages. Click to jump to the forums." Or, if the person visiting is not a member of the forums/not logged in, something like, "Hello guest, please login or register. [ login box ]"
I'm sure this must be possible, I just can't seem to figure it out, and Google searches are turning up nothing. I am still new to PHP so you'll have to excuse me. :)
If you believe you should be able to view this directory or page, please try to contact the Web site by using any e-mail address or phone number that may be listed on the www.cakesbytammy.com home page.
You can click Search to look for information on the Internet.
HTTP Error 403 - Forbidden Internet Explorer
I also get this when I type in her domain name, minus the specific HTML file. suchas http://www.somedomain.com/ Any suggestions as to WTF is going on?!??!
Just starting to switch over from Cold Fusion development to PHP development. I have a question about the apparent switchability between single (') abd double (") quotes. For instance, the following seem to be analagous:
Can anyone explain to me the differences between double and single quotes in PHP? When to use one and not the other? Still not sure what the real difference is between those two explode statements.
i doubt you can do this.. but i was wondering if there was a way to use any sort of programming to text wrap between 2 columns.
i have a page with 2 columns of text, side by side, and i don't want the white space at the bottom. however, since text is displayed differently on different platforms [mac and pc] i have to just leave it and increase the padding an paragraph set up specifically for the pc. i still have the white space and i can't stand it.
so, i was wondering if anyone knew of any code to text wrap in html, css, js, php - anything - between columns.
1.)PHP. Can someone please help me? I'm confused about it. See, I want to create a forum and a thing where you can post comments on articles of sorts, and maybe chatrooms, I'm not sure yet about that.
2.)Videos. Is there any way I can take out the actual video part and just have the audio? Like converting it to .MP3?
Thanks, Brad
P.S. If you want to help me, my AIM screen name is imakebrainstew, my MSN screen name is imakepoprocksandcoke@hotmail.com, and my e-mail is bassilik@yahoo.com
If you ever did any physics, engineering, or statistics work in Java, I'm sure you'll remember the classic Java Matrix package. We just finished porting it over to PHP over at phpMath.com, and the results are pretty cool. Anyone who's ever done clickstream modelling or any sort of complex online data analysis will really benefit from this package too. Just a few examples:
With JAMA, you can perform a least-squares regression for an n-th degree polynomial - this function returns the coefficients of the polynomial. $X and $Y are arrays of x- and y-values and $n is the degree of the polynomial. Make sure you provide at least $n+1 values for each. Check out the test script here: http://phpmath.com/~jama/add-ons/polyfit.php.
function polyfit($X, $Y, $n) {
if(count($X)!=count($Y) || count($X) < $n)
return false;
for ($i = 0; $i < sizeof($X); $i++)
for ($j = 0; $j <= $n; $j++)
$A[$i][$j] = pow($X[$i], $j);
for ($i=0; $i < sizeof($Y); $i++)
$B[$i] = array($Y[$i]);
$matrixA = new Matrix($A);
$matrixB = new Matrix($B);
return $matrixA->solve($matrixB);
}
Multivariate distributions are also a real breeze with JAMA. Check out how easy it is to calculate values for the probability distribution of a multivariate normal distribution, even when the correlation between variates is non-zero (e.g., not just the sum of the marginal probabilities). $a is the covariance matrix and $mu is the vector of means. This little snippet just iterates through [0,1] with Δ0.1, calculating the PDF for the standardized bivariate normal.
$a = new Matrix(array(array(1, 0), array(0, 1))); $ai = $a->inverse(); $sqadet = sqrt(pow(2*pi(), 2) * $a->det()); $mu = new Matrix(1, 2, 0); for($i = 0; $i < 1; $i += 0.1) { $y = new Matrix(array(array_fill(0, 2, $i))); $y->minusEquals($mu); $yt = $y->transpose(); $y = $y->times($ai); $y = $y->times($yt); $Q = -$y->get(0, 0) / 2; echo exp($Q)/$sqadet . ' '; }
We're also doing some work on implementing a complete statistical distribution library. They're both open-source community works, so if you're into this sort of thing, feel free to sign up for the mailing list and contribute too.
I know this isn't totally an advocacy group, but I think some of you might enjoy seeing the publicity that moz and firefox are getting. The Kojo Nnamdi show, on WAMU-FM (Howard University PBS radio) had a show on browsers today, and what I was able to catch of it sounded pretty positive to firefox. For a while they'll have a stream up on their web site: (updated edit: seems they're up for quite a while, the archive is back to 2003).
The Kojo Nnamdi show is always pretty interesting. Glad I found out about it. Too bad it wasn't in time for the show to post here so folks could call in or email. :( It aired Tuesday at 12.06 hours Eastern US time. On air were guests columnist Mark Kelner from the Washington Times (bleh ..to the paper not the columnist) and Alan Paller, research director of The Sans Institue (computer security).
And if folks really don't want these kinds of posts, let me know. :)
I'm using a script to upload files to my system. That means the files are created by Apache, and I can't access them with my FTP/SSH login. I need to back up the files uploaded, and mirror them.
So, what I'm looking for is a simple (php) script to recursively chown, chgrp and chmod the files and folders on a given path.
Yes, it's easy, and yes I could write it myself. But, I don't have time to do it tonight, and it's the kind of thing loads of people have hanging around, so if anyone has code they can 'lend' me to do the job that I can just run in the morning, that'd be great.
so, my quest for the perfect gallery continues. my question to you all is this: what gallery applications do you use and what do you think of them? I prefer php and no need for mysql, but I'm open to other options. the only thing I'm adamant about is not using javascript. ;)