ManiacDan
Staff Alumni-
Posts
2,604 -
Joined
-
Last visited
-
Days Won
10
Everything posted by ManiacDan
-
Please indent your code properly and put braces on their own lines so we can see where your control structures begin and end. what does the result set look like for this sql query?
-
Ok, you seem to be steadfastly using the wrong words here, but I'm going to skip right over that to repeat my question: ARE YOU LOOKING AT THE HTML SOURCE? Also, like Pikachu said, are you doing anything aside from what you said you've done (and what I've demonstrated)? HTML entities, escaping, str_replace, anything? I copied and pasted what you gave me and it worked. I'll repeat: I took what you posted. Character for character. Exactly zero changes. It worked. Also note that your INPUT might not contain the < character. THAT may be run through htmlspecialchars or something. Note that the < is hard-coded in my string. -Dan
-
I copied and pasted your 2 lines of code (which again, is not a function) into a document and it worked. $txt = "I <3 PHP it's the best! :thumbsup: WOO!"; $smilies=array ( '#(?<!\w):thumbsup:(?!\w)#i' => '<img src=html/emoticons/thumbsup.gif alt=":thumbsup\:">', '#(?<!\w)<3(?!\w)#i' => '<img src=html/emoticons/heart2.gif alt="<3">', ); $txt=preg_replace(array_keys($smilies), array_values($smilies), $txt,5); echo $txt; This outputs: I <img src=html/emoticons/heart2.gif alt="<3"> PHP it's the best! <img src=html/emoticons/thumbsup.gif alt=":thumbsup\:"> WOO! There's not much more I can tell you. Are you looking at the HTML source?
-
The 5 in your preg_replace means "only do it 5 times." Do you have 5 :thumbsup: before the heart? Your function (which is not a function) works for me when I copy/paste it. -Dan
-
Works for me: php > $a = "I <3 PHP"; php > echo preg_replace('#(?<!\w)<3(?!\w)#i', '{{HEART}}', $a); I {{HEART}} PHP php > -Dan
-
Ah you're right, I didn't notice.
-
Wrong. Javascript is not a validation/sanitation language and cannot be used for this. You have to use PHP, and you should be using filter_var() to validate the email. Then the problem exists somewhere else and you should notify your host that there is only 1 PHP script on your whole site and it cannot create files. Change your passwords anyway. If your security is in good shape you're changing them every couple months anyway. If you honestly only have these 13 lines of executable code in your entire website, then it's either a hole in their system or your password has been compromised. There's holes in every system, especially small shared hosts. The hole could also be on someone else's site on the same host, it doesn't have to be anything related to your account. Change your password, secure your inputs with filter_var, and then tell your host that you've secured the only piece of executable code you have on your site. -Dan
-
There are 2 problems with your site: 1) This specific mail script can be abused to send spam. 2) Somewhere else on your site is another script that also doesn't properly validate inputs, this other script is capable of creating a PHP file that was then used to spam. Since you're on a shared host, it's a pretty good bet that it's another PHP script, but #2 can also be some other kind of vulnerability. A compromised FTP password perhaps?
-
The logic isn't correct either. You probably want where name = 'name1' OR name = 'name2'. A single field can never be the same as two different things.
-
Because this is wrong: while($row[] = mysql_fetch_array($query)){ foreach($row as $category){ And this is right: while ($row = mysql_fetch_assoc($result)) {
-
Ignore the specific example that you were linked to, since it's a more advanced tactic than you can handle at the moment. The example from the top of the page is easier to follow, look: while ($row = mysql_fetch_assoc($result)) { echo $row["userid"]; echo $row["fullname"]; echo $row["userstatus"]; } You don't need the $row[] syntax or your inner foreach.
-
$row[] = mysql_fetch_array($query); You need to use mysql_fetch_array IN THE LOOP. The manual page you were linked to contains examples on how to do it properly.
-
$linksArray[$key]->child_links = $whatever; That line makes $linksArray[$key]->child_links into $whatever. It does NOT append $whatever to the array of $linksArray[$key]->child_links. You want: $linksArray[$key]->child_links[] = $whatever; -Dan
-
This page refreshes itself after a few seconds. Don't do that. Either let the user refresh it manually or use ajax to refresh all the data in the chart. If you choose to use ajax, be prepared to LEARN AJAX, completely rewrite this page, and spend about 2 weeks on it at minimum. There isn't just a "put the ajax right here" we can give you. Ajax is a whole different way of thinking about content generation. -Dan
-
Talking about it takes two minutes and is fun. Doing it takes an hour and is not fun. We're more than willing to talk to you about it, because it's fun and we like helping people. You'll have to pay us to write it for you, because we don't like doing things that aren't fun. The basics have already been given: Do all your date storage and calculations in a specific time zone. I use GMT because I work at companies that span countries. You can do it in local time for the server because you only have one. Either way, do it in a specific time zone and only display the user's timezone right at the end, when you're adjusting your output for the specific user. it's like this: Do you put commas in your numbers in the database, or do you only use number_format when you print the numbers? That's the theory you need to work on. Time Zones are a display-level feature, computers do time math in GMT.
-
PHP doesn't malloc all the ram in the memory_limit all at once, it allocates as it needs to and will die if it goes over its own limit. If your scripts never run away from themselves then it doesn't really matter how big your limit is. Have you done any memory tests to see just how much RAM your scripts are using when you run them?
-
trying to access id from mysql dynamically
ManiacDan replied to rahulvicky00's topic in PHP Coding Help
You're going to have to be a lot more specific. You dropped 150 lines of code on us with one barely legible sentence, and when you were given a new line to try you just said "not working." Did it crash your computer? Start a fire? -
trying to access id from mysql dynamically
ManiacDan replied to rahulvicky00's topic in PHP Coding Help
Actually should be: $strSQL = "SELECT * FROM text WHERE id=" . intval($_GET['newsID']); Or, if your IDs are strings, you'll need to wrap it in mysql_real_escape_string. -Dan -
Your regex is malformed and will never work on any website, I don't know how it's working for sites other than facebook. It should end in a slash. You also may not be getting a well-formed document from facebook, or their title tag may be on multiple lines.
-
scootstah, that wouldn't really be helpful if some of the numbers were OVER the target number. sphinx, I'm afraid your answer is "subtraction." Loop through all the numbers, subtract from 1000, find the abs() of the result, and find the lowest difference. Same way you'd do it by hand.
-
Nothing.
-
Did you notice that requinix solved that problem on Friday?
-
Oh geeze, it's been a few days...
-
"Size" is ambiguous, you were talking about the height, and making things the same height is not what you want anyway. You need to simply alter the alignment of the cell. You're looking for the css vertical-align attribute.
-
So you're spitting HTML to a browser which is not rendering that HTML? Something else is going on. View the source of the page. Do you see valid HTML?