-
Posts
16,734 -
Joined
-
Last visited
-
Days Won
9
Everything posted by PFMaBiSmAd
-
It sounds like your web server is behind a caching proxy server. It would certainly help if you provided some information about where your web server is hosted at relative to where the server with the xml document is hosted at and where the browser you are using is at relative to both of those. Edit: To see if there is some cache between your web server and the offending site, add a random dummy GET parameter onto the end of the URL (making each request look like it is for a different URI) - <?php $ran = rand(); $url = "http://xboxapi.duncanmackenzie.net/gamertag.ashx?GamerTag=cerebal%20asassin&dummy=$ran"; ?>
-
NEWBI PLEASE HELP ME WITH THIS MYSQL / FORMS / ADDING TO DATABASE
PFMaBiSmAd replied to mrcoda's topic in MySQL Help
Your form fields don't have any name="..." attributes, so the $_POST['...'] variables don't exist. -
Please don't put queries inside of loops. Take a look at the $last_tab logic in this thread (you would change it to store the last continent value) - http://www.phpfreaks.com/forums/index.php/topic,296615.msg1405059.html#msg1405059 Simply use one query to retrieve the data you want in the order that you want it. Then in your presentation code, detect when the continent value changes to output a new heading and remember the new continent value.
-
It is mostly personal preference. However, the first method generally results in more typing errors (we see the resulting syntax errors posted on the Forum) because there are more transitions between the different syntax usage when switching into/out of a quoted string. The second method is actually a little faster executing (if you have 10's of thousands of strings in a benchmark loop you will see a few milliseconds time difference.) I personally use the second method most of the time (fewer typing errors, fewer characters to type as well.) However if I am typing something simple, I will also use echo $variable . '<br />'; If you put array variables inside of a double-quoted string or have text adjacent to a variable name where php cannot determine where the text/variable name starts and ends, you need to put {} around the variable.
-
Database connection script and other questions
PFMaBiSmAd replied to Hioushi's topic in PHP Coding Help
What other scripts? You would include the config.php file at the start of any web page that needs to use the configuration settings. Including a .php file is similar to including a .h file in C. You are including variables, defined constants, function definitions, and class definitions that are needed by the rest of the code on the page. A php include statement is essentially the same as copy/pasting the contents of the file being included into the source where the include statement is at and the contents exist in the same scope where the include statement is at. -
Database connection script and other questions
PFMaBiSmAd replied to Hioushi's topic in PHP Coding Help
It would be customary to put all application configuration settings in to a config.php (or similar name) file and include that at the beginning of an application. By putting php code (variables or defined constants) into a .php file, it is automatically protected against revealing the values should someone discover or guess the file name and request the file. If you use a .xml or .ini file, you must take additional steps to protect the contents. Once the variables or defined constants have been included, you just use them in the $db = new Database($server,$db,$user,$psswd) function call. Also, keep the class general purpose (pass the values in as parameters) so that it would be possible to create multiple instances of the class should you need to access more than one database in an application. -
this form validation is not doing anything
PFMaBiSmAd replied to TeddyKiller's topic in PHP Coding Help
I don't know why you are a using a form, using javascript, or even have a title that contains 'form validation' (there's no form data, so there is nothing to validate.) You are just checking if a link has been clicked - <?php if(isset($_GET['submit'])) { if($user->credits < '1000') { echo '<span style="color:#e11919;>Not enough credits!</span>'; } else { $time = time(); $query = mysql_query("INSERT INTO `featured_member` (user_id, views, date) VALUES ('$user->id', '0', '$time')"); if($query) { $credits = $user->credits - 1000; $query = mysql_query("UPDATE `users` SET credits = '$credits' WHERE `id` = '$user->id'"); } } } ?> <div style="text-align:left;"> <a href="?submit">Feature Me!</a> (1000 Credits!) </div> -
this form validation is not doing anything
PFMaBiSmAd replied to TeddyKiller's topic in PHP Coding Help
If that's the whole form and there is no actual form data being submitted, there is no point in using a form. Just use a href link by itself. -
Why is the following line of code (right after the line with the mysql_query() statement) in your program - $row = mysql_fetch_array($res); Each call to mysql_fetch_array() fetches a row from the result set and advances the row pointer to the next row.
-
To insure that only a visitor that requested the index.php page can make a request to the update.php page, you would need to set a session variable on index.php and check the that the session variable exists in update.php.
-
I suggest you re-read the thread. It is the browser that is making the request for update.php - The A in AJAX stands for an Asynchronous HTTP request.
-
If you know what the concern is, why did you post something that has nothing to do with preventing it?
-
We only see the information you supply in your posts. If you post code that shows you are setting a value right before you use it, we must assume that is your actual code or you would not have posted it together - $expire = time() + 60*60*24*31*5; setcookie('TOS', 'Yes', $expire);
-
LOL, topflight, you introduced a typo in the last_report (last_pirep) source field name in the code you posted in Reply #13. That error has carried through to this point in the thread. It is kind of your responsibly to LOOK at the code you post and to look at the code someone else posts in response to make sure it applies to what you are doing. How are we supposed to know that you did not actually have a column by that name or renamed your original column to that name? We only have access to and see the information that you post and have to assume that what you post is accurate, even if it changes during the life of a thread. We are not psychic after all If you correct the last query posted so that it has the correct field name, it will work. And frankly, just posting that something does not work is not helpful. If is also your responsibly to investigate why something is not working on your server with your data. At least look at the code (and queries) you are using that are not working and attempt to find why they are not working.
-
Redirecting all over the place, regardless of the method used to perform the redirect, just to handle form processing and user error display, wastes time and server resources. Form processing, forms, and display of user error messages should all occur on a single page.
-
phpchamps, the method you posted only works when the second file is included by the first file and the source code of the second file is essentially copy/pasted into the first file and exists in the scope of the first file (unless the include is inside of a function.) When the second file is requested separately by the browser, as is the case with an AJAX request, that is a completely separate invocation of the web server and it has a completely separate scope from the first file.
-
weird problem with two strings being equal
PFMaBiSmAd replied to jeff5656's topic in PHP Coding Help
If the data in your database was imported from a file, it probably has new-lines at the end of each value. You can confirm if it is the data in the table by removing the trim() from that side of the comparison. You should probably run an UPDATE query to TRIM() all the values in the table. -
Inserting float value of 1,226.37 into Decimal(10,2) table column
PFMaBiSmAd replied to SchweppesAle's topic in MySQL Help
That's because a 1000's comma is a human convention to make a number more human readable. It has no meaning to a computer and in fact most computer programs stop parsing numbers at the first non-number, which is why you are only getting a 1. You need to remove any commas from numbers. str_replace would probably be the quickest function to use - http://us3.php.net/manual/en/function.str-replace.php -
Does closing the browser and visiting the page again also include using a different URL from the URL that was used when the cookie was set, such as one that has a www. on it or no-www. on it or is using a different path to the file? You are not specifying the path or domain parameters in the setcookie() so the cookie will only match the exact hostname/subdomain (www. is a hostname/subdomain) and path where the cookie was set at.
-
The program that exists to find syntax errors like that is the program that is running in your brain. Because only the programmer who wrote the code or query knows the intent or goal of the code or query, there is no computer program that can specifically find what is wrong with code or a query when the programmer leaves something out. If you were using mysqli_error() it would tell you that mysql found a syntax error and where it was discovered at in the query, but that is often after the point where the programmer left out some syntax and is often a generic error message because, again, the language parser does not know what the programmer is trying to accomplish and cannot tell him specifically what he left out or what to do to fix it.
-
Help - My $_SESSION vars are being lost after a HEADER.
PFMaBiSmAd replied to cjp_24's topic in PHP Coding Help
If you read what I wrote, I stated "passing the session id using a cookie?", which is the default way that php passes the session id. That's not the same as passing actual information through a cookie. -
A web page who's origin is not the local PC cannot open links/src to local files on the PC, without turning off browser security settings or installing a java applet (also requires the java VM) or installing an IE ActiveX component.
-
You have a double - '$estate','$estate'
-
For the first syntax (without a list of columns), you must supply a value for each column. If you got an error that the column count does not match, check your query to make sure you are supplying the correct number of values. Given that '$fname','$fname' is repeated, I would guess you need to correct the actual list of values. What is the current error you are getting with the second syntax (where you supply a list of the columns you are supplying values for)?
-
Help - My $_SESSION vars are being lost after a HEADER.
PFMaBiSmAd replied to cjp_24's topic in PHP Coding Help
Edit: You did not mention that the session id IS being passed in the URL. Doing so is a problem because php will only automatically do that with relative URL's, not absolute URL's. Since your header() redirect is using an absolute URL, you must handle passing the session id in the URL yourself at that point, because php won't. Is there some reason you are not passing the session id using a cookie? Original post- So did you ever determine if you were switching back and forth between www. and no-www. hostnames/subdomains? If this is the case, you can set the session.cookie_domain to match all hostnames/subdomains of your domain. The session ID cookie is sent by the browser when the cookie matches the URL that is being requested. The symptom you are getting is that of having multiple sessions for one visitor because different pages or different visits to the same page are using different URL's. You could also have a server that is configured to add the session SID into relative URL's (but does not do so for absolute URL's.) Do any of the URL's show a value like ?PHPSESSID=82r964lhblttdauqrr9llv8575 in them? Finally, use some full php error_reporting to see if it exposes some problem. Add the following two lines of code immediately after your first opening <?php tag on the relvant pages - ini_set("display_startup_errors", "1"); ini_set("display_errors", "1"); error_reporting(E_ALL);