ManiacDan
Staff Alumni-
Posts
2,604 -
Joined
-
Last visited
-
Days Won
10
Everything posted by ManiacDan
-
Zane has a point about the query, the lower the level of obfuscation, the better. I didn't realize this was in the mysql section, otherwise I would have provided a MySQL response.
-
You can use regex for this: php > $ssn = '123456789'; php > echo preg_replace('/\d{5}(\d{4})/', '*****\\1', $ssn); *****6789
-
You're not understanding what I'm saying. You know what, back this up entirely. What are you GETTING and why is it wrong? What do you want to happen? We know what data is in the table, show what you want the output to be like.
-
I'm not blaming you, I'm telling you how data works. If you JOIN a table with one record to a table which has two records referencing table1's record, then the result will have two rows. That's how SQL works. You can either: 1) Do separate queries so you fetch the order in one and all the details in another. 2) Write your code so that it only prints the order once and then ignores it for the rest of the records which contain the details.
-
You don't need quotes around this variable at all. Escaped quotes are only supposed to be used inside of other quotes. They are necessary here: $string = "Dan says \"escaping your quotes is only necessary inside of strings\" because that's the kind of thing he says.";
-
Many sites don't let you edit the comments, so there's no requirement for you to do this at all. If you really believe you need to do a preview: 1) Accept the form submission. 2) If the submit button is named "submit," simply submit the form normally. 3) If the submit button is named "preview," re-draw the edit screen, 3.1) put the exact same content they posted BACK in the textarea 3.2) above the text area, draw what their comment will look like. If you must do edits, then you'll have to put an "edit" button on only the logged-in user's posts. When clicked, take them to the same page where they would post a NEW comment, except pre-fill the box with the comment they've already made. Make sure submitting this form doesn't make a NEW comment. "Preview" buttons are really only useful on sites like this with extensive markup that users might be unfamiliar with. The Patheos blogs have an in-line preview that shows you your own post in real time as you type it. Other sites like the gawker sites don't offer previews OR edit functionality. Sites like reddit and phpfreaks offer both.
-
Why was "try" and "catch" introduced into PHP?
ManiacDan replied to marcbraulio's topic in PHP Coding Help
Exception Handling is a completely different way of programming and handling errors. It's especially useful in Object Oriented programming. -
AK's code is correct. You had parens instead of brackets, which would cause PHP to attempt to execute a function named after the $_POST array, but that would throw a fatal error. You're going about this wrong btw. Name all your checkboxes "catID[]". All of them, named JUST like that. Each of their VALUES needs to be the actual catID. Then, in your code, $_POST['catID'] will be an array of all the checked catIDs.
-
So there's two orderdetails for one order? Then you're getting two results, that's just how it works. If this is a one-to-many relationship, you need to do two queries or have your code understand that some of this data will be duplicated.
-
What we're saying is: Don't write your unconvert function, ever. Store the RAW post in the database, and then only convert the BBCode on display. That way, if someone wants to edit, you just show them what they posted already.
-
This won't do 7 of each, it will do 7 total. Even if you did do 7 of each, browsers are smart enough not to download 8,000 copies of the same image, they'll use the one they downloaded for every <img> tag. You keep describing your code using functions that none of us can see. We had to ask about your custom htmlentities function, which apparently did nothing other than the built-in one, but you've now introduced escape(), parse_message(), and clean_paragraphs() Again, debug this yourself. Dump the input to a log file every step of the way, figure out when [ b ] turns into <b> and/or when it turns into <b> And Scoot is right, parsing BBcode is a display event, not a storage event.
-
The question you asked was for the mute functionality, which I've now given you. Auto-playing music does not "give life to the website," it makes users leave. I won't help any further than this. If you wanted play/pause functionality then asking for it from the beginning would have been good, since then I wouldn't have closed the documentation page that I got the answer from.
-
There's a lot of functionality missing here that we'd need to see. This is so huge and poorly organized that you're going to have to debug this yourself, step by step. Do you know where the disconnect is? Does clean_paragraphs do anything special? Why do you only replace 7 smilies?
-
it would be easier to explain to your friend that websites simply do not do this anymore. The only site that still plays embedded music is myspace, and nobody goes there. However, if you really must do this, use an <embed> tag to load the music, then to mute it you: var player = document.getElementById("theEmbedObjectId"); player.stop(); -Dan
-
Can we see all the fields in these three tables? That JOIN should work, unless there's multiple printers with the same product ID or multiple orders with the same order ID.
-
This practice died out 15 years ago, why do you want to put music on your website?
-
what does pun_htmlspecialchars do? The proper thing to do is: 1) call htmlspecialchars on the string 2) parse the BBcode to turn BBcode into HTML 3) display
-
"Undefined index" means you used syntax $like['this'] and 'this' was not a member of $like. This code contains your only reference to ['username'] $sql = mysql_query("SELECT * FROM tut_users WHERE id='{$pid}'") or die(mysql_error()); $fetch = mysql_fetch_assoc($sql) or die(mysql_error()); $username = mysql_real_escape_string(preg_replace("@[^a-z0-9]@i","",$fetch['username'])); Clearly $fetch does not contain username. are you sure table tut_users contains a column called 'username'?
-
So what makes you think you need regex for this at all? echo '<a href="' . $row['imageurl'] . '">' . $row['title'] . '</a>';
-
Show the contents of Title, Imgurl, and a final example of what you want. So far you're showing code that appears to want to take one URL out of title and replace it with another URL.
-
Is there a way to not call each file in index.php?
ManiacDan replied to Mal1's topic in PHP Coding Help
this site isn't really designed properly, the titles should come from a controller instead of the templates, it doesn't seem like you have actual templates at all, what you have are full PHP applications simply NAMED "template." But yeah, your pages won't have a title unless you put one into the template. Just go do that instead of trying to muck with default titles. -
Is there a way to not call each file in index.php?
ManiacDan replied to Mal1's topic in PHP Coding Help
No, we're saying that the standard "router" method of having a single page handle includes and template rendering is normal. it's not normal to hand-code page titles into this central router, those should be in the templates. The reason the header doesn't work in your template is probably because the header is also being set elsewhere. You'll have to find it. -
Is there a way to not call each file in index.php?
ManiacDan replied to Mal1's topic in PHP Coding Help
He said they are .tpl files, so I'm thinking he has some sort of template parser. He said that part was in index.php -
Is there a way to not call each file in index.php?
ManiacDan replied to Mal1's topic in PHP Coding Help
action=pagename is better for SEO, because you can have descriptive pagenames that are easier to read. However, I don't know why your code has this bit: case "conditions"; $title = "Terms & Conditions"; $content_for_layout = $_GET['action']; break; For one, it's not valid PHP. Is this switching on the existing $_GET['action'] variable? If so, why does it also set the title? Shouldn't that be in the template itself? This set-up looks about 80% correct, which is probably why you think it's all wrong. -
So close. echo preg_replace("/&?utm_(.*?)\=[^&]+/","","?utm_source=bottom&utm_medium=widget&test&test&utm_campaign=testcamp");