-
Posts
16,734 -
Joined
-
Last visited
-
Days Won
9
Everything posted by PFMaBiSmAd
-
Assuming you are on a shared web server and only have client/connection access to the mysql server, see the Per-connection time zones section at this link - http://dev.mysql.com/doc/refman/5.0/en/time-zone-support.html
-
Sessions are per visitor. Each visitor gets a separate session id and a corresponding session data file on the server where the session variables are saved when your script ends. When that visitor requests a page, the session id is set from the browser to the server and the server reloads the correct session data into the $_SESSION variables for that visitor.
-
Actually, that reminds me, the flash player is its own client and maintains a separate cookie store, so if you are getting one request from the flash client and one from the browser, you won't be able to directly us a session to ignore the second request. You should however be able to detect something different between the two requests and ignore the one you don't want.
-
Using mysqli_real_escape_string() procedurally, requires the connection link as a parameter. If you were developing and debugging your code on a system with error_reporting set to E_ALL (or a -1) and display_errors set to ON, php would help you by reporting and displaying all the errors it detects. You will save a TON of time. There would be error(s) when you called mysqli_real_escape_string() because of the incorrect parameters.
-
-
If your page is being requested twice by the client and there is nothing you can do about what is going on in the client, you would need to add code on your page to detect and ignore any page request after the first one. You can use a session variable to serve as a flag that is set on the first request so that you only execute the code to increment the timesplayed column once.
-
If you do a search for that error message, you will find that it generally means that your query failed due to an error, which is probably the reason Pikachu2000 asked this - Make sure your query executes correctly in phpMyAdmin first.
-
The code you posted won't work because you are using the $query variable to make the query, but putting a non-existent $sql variable into the mysql_query() function. Are you developing and debugging your code on a system with error_reporting set to E_ALL (or a -1) and display_errors set to ON so that php would help you by reporting and displaying all the errors it detects? You would save a TON of time on simple mistakes in your code.
-
You have three choices for doing this in your query - 1) Alter your saved values by removing the leading 'd' character and then alter the table to make that column an INT data type. You can simply concatenate the 'd' character when you retrieve and display the values. This would result in both the most efficient storage and fastest queries. 2) Alter your values by adding leading zero's to the numeric part so that the length of all the values is the same and they can be compared/ordered correctly as strings. d100-d199 would become d0100-d0199. 3) Form a slightly more complicated query that gets just the numeric part of the values as a number and uses that in the ORDER BY term. This of course would be the slowest of these three methods.
-
Just use the mysql DATE_FORMAT() function in your query when you retrieve the value. No slow parsed, tokenized, interpreted php code is needed. You are already executing a query to retrieve the data. Adding a mysql DATE_FORMAT() function in the query adds a minuscule amount of time to the query, whereas doing this in php code takes a minimum of 8 times longer then it takes to execute the entire query.
-
A session consists of two parts, the session id cookie from the browser and the corresponding session data file on the server. The first parameter in session_set_cookie_params() ONLY sets the session cookie lifetime, which only means that the cookie will last for that amount of time AFTER you close the browser. This has nothing to do with the problem of the session ending while the browser is still open. A zero session cookie lifetime means that the cookie is deleted when the browser is closed. Your session data files are being deleted on the server. If you do a search on the forum, using my username and the search term session.gc_maxlifetime you will find numerous discussions about making a session last longer when there is no activity from the browser.
-
So, you have code that reproduces the problem, but you aren't, can't, or won't post it? Just exactly what were you expecting a programming help forum to be able to do for you? Edit to your edit and added post: Someone already suggested a likely cause - Does your FULL actual code check that the form was submitted and that the $_POST['name'] is not empty, or does it blindly form and execute the query every time the page is requested? I recommend logging the $sql string to a file on every page request so that you can see what it really is. That would help you determine if the page is being requested more than once.
-
A) Posting all the code (form and form processing) that reproduces the symptom would be the quickest way of starting the process of getting help. That would allow someone to reproduce the problem and/or see what the relevant code is doing to either confirm or eliminate the code as the cause of the problem. B) You are apparently NOT validating the form data in your php code or possibly not even checking that a form was submitted. C) If the symptom just started and it is not due to A) or B), then it is likely that your browser is requesting the page twice and doing B) would detect that and prevent the query from being executed when the page is requested without any form submission or form data values.
-
more complicated "select from where and or" statement
PFMaBiSmAd replied to pioneerx01's topic in PHP Coding Help
Speaking of greatly simplified sql, the following should (untested) work (assuming your table/columns names are correct, you are escaping data, your data has expected values...) - $names = "'{$_POST['name_1']}','{$_POST['name_2']}'"; $query = "SELECT * FROM Project_Registrations WHERE Teacher = '{$_POST['teacher']}' AND School = '{$_POST['school']}' AND (First_Name IN($names) OR Second_Name IN($names))"; -
more complicated "select from where and or" statement
PFMaBiSmAd replied to pioneerx01's topic in PHP Coding Help
Concatenation with that many variables also results in a huge number of typos and the resulting php syntax errors. @pioneerx01 your query is LOGICALLY correct SQL, though it can be greatly simplified. If it's not working, then either your variables don't have the values you expect (as already suggested) or your query is producing an error of some kind (I'm not going to bother to list all of the possibilities because your error checking and error reporting logic in your code should be telling you if a query error occurred) or you aren't executing the query (we see that a lot) or you aren't fetching the results correctly from the query (we see that a lot too)... -
You'll want to give your form field an array name - http://us3.php.net/manual/en/faq.html.php#faq.html.arrays so that you can use php's array functions to process the data.
-
So, what exactly is your application dong that would require this and where is the data being inserted from that you want to retrieve in the way? You would generally use a shared memory/disk cache system when you need frequent polling to get current data.
-
Slight correction to the above post. The WHERE clause will use your date column (after removing the single-quotes.) The ORDER BY will use the date_format() value through the alias date, which won't give the desired results.
-
Search for 'alias' on this page - http://dev.mysql.com/doc/refman/5.1/en/select.html When someone mentions a basic technical term related to programming that you don't understand, it is always best if you consult the original documentation that defines what was mentioned. You will get a more complete and concise explanation, often with examples, compared to just a portion of the information in a brief and quickly typed reply.
-
^^^ That's testing if the string 'date' (not your date column) is greater than the curdate(). Remove the single-quotes from that. Also, by using date as the alias name for the date_format() term, your WHERE and ORDER BY terms will use the formatted value. Pick a different alias name for the date_format() term.
-
You aren't selecting the sold_date column, so $row['sold_date'] doesn't exist. Use an alias for the YEAR(sold_date) term in your query and reference that alias name in your php code.
-
Attributes are accessed using [] (everything that simplexml can do can be found in the php.net documentation.) Should work - $docResults = $doc->results->ship['cruiseline'];
-
Define: change the mysqli to mysql? You cannot just change the name because the parameter list is different. If the error message is exactly the same, then you didn't save the change or you didn't put the new file onto your server.
-
You are using mysql_ functions in your connection code and mysqli_ functions in your main code. You cannot mix mysql_ and mysqli_ on the same connection.
-
It would help if you posted an example showing what the part of your array looks like that should be matched and what your $this->word looks like, and have you actually echoed or used var_dump() on the values so that you know that they actually do match (in_array requires an exact match.)