-
Posts
2,965 -
Joined
-
Last visited
Everything posted by mikesta707
-
well, if you have the raw html, a simple regular expression (regex) would probably do the trick. Can you give a couple example urls? preg_match() regex function: http://php.net/manual/en/function.preg-match.php site with regex tutorials http://www.regular-expressions.info/ a basic example would be like //get html from page. store in variable $html; $pattern = '#generic/part/of/url/(.+?)#i'; if (preg_match_all($pattern, $html, $matches)){ array_shift($matches);//take out first entry because it is entire match, which we dont need print_r($matches);//show array structure
-
strtotime() $date = "01/12/2009"; $time = strtotime($date); thats how you can convert dates of most any format into a unix timestamp. as far as the query, yeah it looks fine. I'm not sure what you mean by care to clarify?
-
im assuming by image from url, you mean you need to get a certain image from a certain page (that certain page residing at the URL in question) There are numerous ways to do it, but using the Curl library, or simply using the file_get_contents() function will get the raw html of the page. From there you could simply use regex or the html DomDocument class to get the image you want
-
$username = $_POST['nickname']; ?
-
remove the quotes around the mysql_query code. Instead of calling the function mysql_query, you are just creating a strign with some PHP code. alternatively, you could keep the code like that and use eval(), but just removing the quotes is easier and better
-
<a href="http://www.mydomain.com/indexOLD.php?lang=eng" target="blank">Link text</a>
-
i have a line error and i cant find what is is !!!!!!
mikesta707 replied to tenfoottrike's topic in PHP Coding Help
you forgot to close the copy() function on the following line copy($_FILES['file']['tmp_name'], 'images/a_video/' . $_FILES['file']['name'] or die("Could not copy file"); should be copy($_FILES['file']['tmp_name'], 'images/a_video/' . $_FILES['file']['name']) or die("Could not copy file"); -
As long as we are posting alternatives, here is another, using the Curl library. function getRawHtml($webpage){ $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $webpage); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); $stuff = curl_exec($curl); return $stuff; } by the way, you can't get the PHP when doing either of these. You only get the HTML that the PHP (or other server side language) generates. You can't get the PHP, and frankly, thats theft. If people could just steal other sites PHP (basically the stuff that makes the site a good site) dont you think we'd be seeing a lot of facebook /google clones out there?
-
Checking 2 variables and entering only one in to database
mikesta707 replied to bullbreed's topic in PHP Coding Help
that doesn't make any sense. are you sure you are getting 2 new rows from that insert code that yoz gave you? doesn't seem possible to me. perhaps you should post the rest of your code -
not many sites that list all the information in one place. A google search turned up a few websites that were slightly related. the second link in my first post gives a very indepth look at most security threats though. beyond that, what i said in my previous post should set you on the right path. Also, if you have shared hosting, remember that if one person has a vulnerable site, it can make everyone else that shares that server's site vulnerable also, so if you are really concerned about security, you may also consider not using shared hosting
-
Using loop to output a set of functions
mikesta707 replied to nicholas.alipaz's topic in PHP Coding Help
not quite true. you can use eval if you wanted to, or, probably the better choice, create_function() anonymous functions would probably also work for you -
Help the newbie? Can't get my MySQL_query right.
mikesta707 replied to Bikkebakke's topic in PHP Coding Help
no problem. if your topic is solved you can click the mark solved button at the bottom of the thread -
Help the newbie? Can't get my MySQL_query right.
mikesta707 replied to Bikkebakke's topic in PHP Coding Help
for one, the monster that one player fights isn't the same as another. that simply isn't how objects work. Not to mention that the script running for one player won't be using the information from another. creating a new instance of an object is one line (ex. $monster = new Monster()) I can't really give a concrete answer without seeing the class though. as far as one way being harder than the other, the differences in code is rather negligible. One way isn't any harder from another, semantically, but if you want to do it the OOP way, than you should create a monster with stats from the DB rather than just comparing the amount of damage that a player does to the amount of damage a monster can take. What if you want to update the battle function to take other things into account (like armor value?) . the turns of the battle would be pretty easy. something like while(..){ $monster->health -= $player->atk; //or $plyDmg += $player->atk; $player->health -= $monster->atk; } if you wanted to take advantage of encapsulation and other OOP principles (basically do OOP) then something like $player->fight($monster); may be what your after the way I personally would do it, is after I created the fight method (which does one round of fighting, not the whole battle) have 2 methods called dead (which return whether or not the player/monster has 0 health) and have my loop logic be something like while(!$player->dead() && !$monster->dead()) -
the simplest way would be to simply have two seperate columns for first name and last name. that will be much more efficient than any algorithm you would have to create to sort it
-
Was Working, But now it is returning a blank display?
mikesta707 replied to Modernvox's topic in PHP Coding Help
its $urls in your code... -
Was Working, But now it is returning a blank display?
mikesta707 replied to Modernvox's topic in PHP Coding Help
either your regex became outdated, your urls are wrong, or craigslist banned you. i'd guess that your urls are wrong. when you print_r $urls, try going to one of the links, and see if it exists (Dont forget to add the /muc/ part of the url you seem to be adding in the for loop) -
Returning an array in a specific format from mysql request
mikesta707 replied to spenceddd's topic in PHP Coding Help
instead of order by, try using group by portfolioItem -
Was Working, But now it is returning a blank display?
mikesta707 replied to Modernvox's topic in PHP Coding Help
are both of them empty? which one is empty? if its $posts, then your regex isn't finding any matches -
Help the newbie? Can't get my MySQL_query right.
mikesta707 replied to Bikkebakke's topic in PHP Coding Help
well, i don't see why simply subtracting from a monster objects health would be bad. monsters are fairly static, but each seperate monster object is just as dynamic as the player (well not quite as dynamic, but their health would go down) If the player wants to fight another monster, you can just instantiate a new monster object. however, what you proposed wouldn't be bad. but displaying the monsters remaining health would involve an extra calculation (which isn't bad, just relatively unnecessary). As far as updating the db table with the players health, I personally would only update the db after a battle is finished, to reduce the amount of queries that are run in a players game session, but that is more of a stylistic choice. it may benefit your server if you do it this way if you get a lot of traffic however. -
Was Working, But now it is returning a blank display?
mikesta707 replied to Modernvox's topic in PHP Coding Help
ok, try doing print_r on yoru $urls and $posts array and see what their structure is -
if you use cookies, make sure you always sanitize cookies values. as yozyk said, watch out for remote file inclusions, and of course xss and sql injections. do you use a database? do you hash/salt your passwords? do you verify that your inputs always get the right information (IE not just "safe", but for numeric inputs do you test that the value is a number? stuff like that
-
last month and next month echo $nextMonth = date("F", strtotime("last month")); echo "<br />"; echo $prevMonth = date("F", strtotime("next month")); outputs: January March if you want years, just do echo $nextMonth = date("Y", strtotime("last year")); echo "<br />"; echo $prevMonth = date("Y", strtotime("next year")); which outputs 2009 2011 check out the manual page for the date for different formats of the date, and strtotime for more info on strtotime function[/code]
-
Was Working, But now it is returning a blank display?
mikesta707 replied to Modernvox's topic in PHP Coding Help
im assuming thats the $st = ...... : $_POST['state']; line? that means that $_POST['state'] doesn't exist, so you probably have the name of the key wrong. Can you post your form? have you verified that there is indeed an input named 'state' -
No problem, if your topic is solved, you can click the mark solved button at the bottom of the thread
-
Is there a way to access session variables from another website?
mikesta707 replied to adambedford's topic in PHP Coding Help
i'm not familiar with the paypal API, so I can't tell you exactly what to do, but the paypal api documentation will surely have the answer