-
Posts
5,717 -
Joined
-
Last visited
-
Days Won
6
Everything posted by Adam
-
Modify MySQL tables using form back-end of CMS
Adam replied to richeyrich_86's topic in PHP Coding Help
Also while not a syntax error, you have a logic error in how you're checking the query's success. mysql_query() will return true for a statement that is executed successfully, but a successful query can affect zero rows. Instead you should use mysql_affected_rows something like: if (!$result = mysql_query($query)) { echo 'Database error: ' . mysql_error(); } else { if (mysql_affected_rows($result) > 0) { echo "Successfully edited entry"; } else { echo "There was error editing entry"; } } -
If you can name some specific errors/problems one (or even a couple) at a time, I'm happy to help. I'm not going to debug & fix the whole code for you though.
-
why my div content is not refreshing by ajax in ie
Adam replied to phpmady's topic in Javascript Help
Can you provide more information please. What is happening? What isn't happening? What syntax errors are you getting? -
Can you be more specific than "junk values"?
-
For future reference, you can check the manual for a list of reserved words: http://dev.mysql.com/doc/refman/5.5/en/reserved-words.html
-
Are you requesting a review of the code here, or have a specific problem with it?
-
Unlike you may expect, "date" isn't a reserved keyword within MySQL -- and in-fact isn't with most DB platforms. You won't need to use `back-ticks` around it to avoid any syntax errors. So yeah, it's okay to use.
-
You have the new path stored within $path and $name. You just need to concatenate them and add the file name to the end: $copy_to = $path . $name . '\zipfile.zip';
-
What do you mean? Whatever path/name/extension you provide in the second argument within the call to copy(), is what the file will be saved as.
-
You need to use a recursive function for this. Theoretically that sub-directory could contain a sub-directory, which contains a sub-directory, which contains a sub-directory, etc. You need to remove the contents of each before you can delete it. Rather than nesting loops within loops, just use a function that will repeatedly (recursively) call itself. I provided a Google link earlier that should help you.
-
Clue is in the error: You're not specifying the path to the file before you try to unlink() it.
-
Yup, using the copy() function. I'll let you have a bash at implementing that though..
-
Run the string through htmlentities() before you output it. For future reference though, you wouldn't need to use regular expressions to replace a character within a string. You can just use str_replace().
-
You need to recursively delete the contents of the directory, before you can delete it. There's plenty of functions/snippets to search for through Google that should help you there. As vicodin suggested, you may run into permission issues as well.
-
Sorry, there's a typo: if (mkdir($path . $dir)) Should be: if (mkdir($path . $name)) Although you're going to want to change the $path value to the actual path where you want the directories creating. Be sure to end it with a double backslash, otherwise the single backslash will effectively escape the single quote, and you'll have a syntax error.
-
It should already be taking the value from the form? $_POST['dirname'] is from the form's input: <input type="text" name="dirname" />
-
Okay, just you spoke about creating both a file and directory. The mkdir() function should work fine for that, assuming the directory has the correct permissions. I would also validate the file name, so that the path cannot be altered (by "../" for example), though I'm not sure how applicable that is in this situation.. if (!empty($_POST['dirname'])) { $name = $_POST['dirname']; // Check the dir name doesn't contain "..", "/" or "\" - you'll // want to build on this for more comprehensive validation if (!preg_match('/[(\.\.)\/\\\]/', $name)) { // Note the double backslash $path = 'C:\path\to\\'; // Create the dir if (mkdir($path . $dir)) { echo 'Success'; } else { echo 'Failure'; } } else { echo 'Invalid directory name'; } } As I said before though, this will only work if the user PHP is running as, has permission to write to that directory. You'll probably get an error if it can't.
-
I'm confused. Do you want to create a file or a directory? Either should be possible, with the correct permissions.
-
I'm not very keen on Chrome for front-end development. Something about the tools and context menus I just don't seem to get on with as well as Firefox, especially when Firebug, Web Developer, Live HTTP Headers, YSlow, etc are installed. Two other add-ons that I don't use a massive amount, but always prove very useful when I do, are ColorZilla and MeasureIt. I would probably use them more, if I did more design/front-end work.
-
You haven't provided any example of 'expanding and contracting tabs', you've shown us an image.
-
Can you show the context those statements are in?
-
CSS "Popup Window". How to load content after user have opened "window"?
Adam replied to Zombay's topic in Javascript Help
I'd say it depends really. Will the text be static, or is it dynamically generating from a DB / some other source? How many different instances of the pop-up will be on each page? etc. -
Who says that? Even if it were technically incorrect, I very much doubt that would trip up a web browser. If you remove the header() call, does the error still show?
-
Which database platform is this for?
-
In your opinion. I use vim, and all changes are tracked and branched through Git.