-
Posts
5,717 -
Joined
-
Last visited
-
Days Won
6
Everything posted by Adam
-
I didn't mean to confuse you bringing that subject back up, just sounded like you might have been wanting to do an insert before. You should be able to decide for yourself though; if you're updating an existing row that's an UPDATE. If you're inserting a new row, that's an INSERT. Can you post the query as it is now?
-
problem in displaying progress bar with percentage while uploading.
Adam replied to sanjay_zed's topic in PHP Coding Help
Is it PHP5.4? Ah sorry, I thought it was 5.3. -
problem in displaying progress bar with percentage while uploading.
Adam replied to sanjay_zed's topic in PHP Coding Help
It's a combination of both. PHP allows you to track uploads, but you need sufficient permission on your server to be able to change a config directive (either with ini_set at run time or in the php.ini file). Essentially all you do is trigger the upload through a hidden iframe, and then fire off periodic AJAX requests with JavaScript to read the session state to get the current percentage. Have a read: http://www.php.net/manual/en/session.upload-progress.php -
Not quite true. You can also use a pair of matching bracket-type characters such as <> and {}. I'm not sure why the regex you posted originally didn't work for you Chud37, it worked for me. Although there's really no need to use regex for simple string replacing. This would be much quicker: $str = str_replace('(Click to Enlarge)', '', $str);
-
No, I'm saying that you're trying to UPDATE an existing row where the `review_id` column matches NULL. You need to provide the ID of the row you want to update, or you should be using INSERT to insert a new row where the new ID is generated for you.
-
Yeah I meant to put "===", the 'identical' comparison operator. It isn't strictly needed here given you will always have a number returned, but identical comparison is good habit to get into. That explains it then. Looking at the form mark-up Muddy_Funster posted, you don't have a "review_id" field? Where is the ID supposed to come from?
-
Your code only checks for errors, it doesn't verify that the row was updated. A query can be successful even if it doesn't actually affect any rows. To ensure it was updated, you should check that mysql_affected_rows returns 1 (or > 1 in the right situation): if (mysql_affected_rows() === 1) { echo 'Row was updated.'; } The reason it's not updating is because the where condition isn't matching anything. Try var_dumping $post['review_id'] to ensure the value is what you expect.
-
array_map takes an array, as the error suggests, and you're trying to pass each item in the $_POST array separately as a string. One solution would be to pass the $_POST array itself, which I'm not keen on because it assumes all data should be sanitised the same. Sanitisation should be done input by input to ensure you're sanitising the data correctly. For example if it's numeric data and you're just escaping quotes, that doesn't necessarily prevent SQL injection. The other option would be to pass each item separately as you're doing, but dropping array_map() and directly invoking trim, strip_tags, etc. The problem here, and this applies to the other solution, is that you're not sanitising the data correctly. You should aim to keep the data as close as possible to what the user entered when inserting into the database, and apply your escaping functions (htmlspecialchars namely) when outputting.
-
It actually stands for "Structured"
-
Have you read the documentation? What have you tried so far? We appreciate you're new to this, but the manual has a lot of examples.
-
Before the curl_init() call, add: $emsg = urlencode($emsg);
-
You may want to run the message through urlencode, but failing that it's something to raise with 'sms fun'.
-
Can a server answer a GET request with a POST response?
Adam replied to jhsachs's topic in PHP Coding Help
I answered that question at the start. You have a very specific problem that we can't just give you some generic answer for. In order for us to help and suggest solutions, we need to know specifics about your application. If you're unable to disclose that on a public forum, or unwilling, here really isn't the best place to be seeking help. Edit: In response to DavidAM's post, while they're viable solutions I wouldn't ever implement them myself. We can't suggest anything better though with the information we have. It just seems like you want to fudge together a fix instead of fixing the problem at the source. -
Can a server answer a GET request with a POST response?
Adam replied to jhsachs's topic in PHP Coding Help
Sadly I'm not Ronnie Wood -
Can a server answer a GET request with a POST response?
Adam replied to jhsachs's topic in PHP Coding Help
They can still edit the value whether it's a POST or a GET, it's just not immediately visible. Anybody with a bit of knowledge that wants to "cause trouble" could still easily do so. HTTP responses aren't GET or POST; they're simply a response. You can include a location header as part of it, which the browser can use to construct a new request, but you can't send back the next request. (Which is a good thing.) Looking at your other post I understand why you want to do this, but you're trying to force the browser to behave in a way it's not meant to. What about "auto saving" work? Or just extending the session expiry? Using different tabs shouldn't create a new session, so a long life session should prevent any issues. -
Edit - nevermind!
-
Having keywords in the URL does have a positive impact on SEO, but don't expect it to work miracles. It's perfectly possible to have a high ranking page without doing it, it's just one of the many minor changes you can make to improve your chances. First and foremost should be the quality of your code and content.
-
Can't see anything wrong with the sortable() call, except for indentation. Replace it with this: $(document).ready(function() { $("#sortme").sortable({ update: function () { serial = $('#sortme').sortable('serialize'); $.ajax({ url: "sort-events.php", type: "post", data: serial, error: function() { alert("theres an error with AJAX"); } }); } }); }); It's the exact same code, just indented properly to make reading easy. It can put people off replying if they see unindented code, and maintaining it is a nightmare for your self. It's hard to say where the problem is, and jQuery is a bit of a bugger when it comes to hiding errors. Are there any syntax errors reported? Do all the scripts exists at the paths you're expecting? Is there any HTML syntax errors that could mean jQuery is unable to find the UL? You have jQuery itself included twice by the way, though that shouldn't actually cause any problems, there's just no need. You could also combine a lot of the UI wigets into one file to save some HTTP requests.
-
How many rows are we talking? It's sounds like PHP is running out of memory and throwing the generic server error. If you have access to the error logs you should be able to get the error message, but increasing the memory limit should be enough - see here for directive and use ini_set to change it per request. Don't just whack it up for every request, there's some serious security concerns with increasing the memory. Of course sometimes when dealing with large sets of data it's just not avoidable.
-
Is defered JavaScript still cachable in a browser?
Adam replied to random1's topic in Javascript Help
402? You mean 304? You can check using the "Network" and "Net" tabs of Chrome Developer Tools and Firebug, respectively. They report the status code returned for each request. There shouldn't be any reason why caching wouldn't work though; the script tags may be dynamically built but the browser will still make a normal HTTP request for them. -
Oh no, don't make the tree smaller. I think it's a good feature, and on a normal desktop it's not a problem. On a laptop / smaller resolution though, there's a block of white-space to the right of it which is a large part of what you first see. I think just spacing out the logo and buttons around it a bit more would do the trick.
-
On my 1680 resolution monitor, everything is in view and looks really good. On my laptop however, the bottom 3 blurbs are cut off and the header just seems to consume the page. I don't think that would bother me ordinarily, but there's a huge amount of grey-space above the logo which seems a waste. I would consider repositioning/restructuring the logo and buttons to fill the void and make the page look more "whole". Apart from that though, I like the design. Couple of very minor usability issues I noticed: the blurbs on the homepage don't link through to the relevant documentation (where possible), and the "Proem Framework" text in the top bar doesn't link to the homepage, which isn't required but is kind of expected.
-
How Does PHPFreaks Feel About the Hate PHP Often Gets as a Language?
Adam replied to Masna's topic in Miscellaneous
I took a quick look at some of the posts on there, and I think every one of the posts I read was either shown to be correct or someone effectively said "RTFM". -
Why does it not load? Do you have 184 images named "[16-200].png"?
-
That doesn't matter in JavaScript (or PHP for that matter) as the code is parsed before it's executed. Will work: <script> hello(); function hello() { alert('Hello, World!'); } </script> Will work: <?php hello(); function hello() { echo 'Hello, World!'; }