-
Posts
16,734 -
Joined
-
Last visited
-
Days Won
9
Everything posted by PFMaBiSmAd
-
There's a table in the documentation that shows what is considered to be 'empty' - http://php.net/manual/en/types.comparisons.php You could also just test each of those values using some code to see for yourself.
-
The number in a comparison takes priority. The string is converted to a number and any non-numeric string is a zero. See the loose type comparison at this link - http://php.net/manual/en/types.comparisons.php
-
Problem with classes on different pc's but not webhoster
PFMaBiSmAd replied to kbloem's topic in PHP Coding Help
Either your include is failing due to the path or you are using short open tags in your included file. Are you developing and debugging your code on a system with error_reporting set to E_ALL and display_errors set to ON so that all the php detected errors, such as a failed include statement, will be reported and displayed? Also, don't ever use short open tags, they just waste time, every time you move code to a server that has them turned off. -
Based on the URL's you posted (one with www. and one without), you are switching the hostname/subdomain name and I don't see anywhere in your code where you are setting the session.cookie_domain setting to match all variations of your domain name. Ref: http://www.php.net/manual/en/session.configuration.php#ini.session.cookie-domain
-
greater than and less than problems php
PFMaBiSmAd replied to hellrisisng's topic in PHP Coding Help
Ummm. What arrays? You have got to checkout all the things that you could be doing wrong BEFORE you run to a programming help forum, especially if you are not going to post the actual code responsible for the symptoms. -
Best guess is that you are probably outputting some content to the browser on your log out page and none of the setcookie() functions are doing anything. Are you developing and debugging your code on a system with error_reporting set to E_ALL and display_errors set to ON so that all the php detected errors will be reported and displayed? You will save a ton of time. Also, setting a cookie with a user id to indicate someone is logged in, is insecure. All I would need to do is create a cookie with your user_id and I could visit your site as YOU. You should create a random unique ID (see uniqid) and store that in the cookie and store that in your user table for that particular user. You should also only rely on a value kept on the server to indicate that someone is logged in, not on the existence of a cookie or of the existence of a session. Once you do this, you won't need to delete the cookie because the cookie will only identify the visitor, its existence alone won't mean that the visitor is logged in.
-
greater than and less than problems php
PFMaBiSmAd replied to hellrisisng's topic in PHP Coding Help
You would need to post your actual code. The only way you could be getting the stated results are if you were comparing the values as strings instead of numbers. -
practicing with temp tables - is this written right?
PFMaBiSmAd replied to turpentyne's topic in PHP Coding Help
Temporary tables are per-connection. They don't persist between page visits, so they would not be usable for pagination. -
problems with post.php submitting mysql query
PFMaBiSmAd replied to WatsonN's topic in PHP Coding Help
That's not the syntax for an UPDATE query - -
You cannot 'get' the next available auto-increment value and use it, because between the point where you get it and the point where you use it, another query could be executed that uses that value and the value you 'got' is is no longer the next available value.
-
I would get rid of the nasty @ - if(isset($subip_count[$ip])) {
-
Warning with MySQLi prepared statement
PFMaBiSmAd replied to pahunrepublic's topic in PHP Coding Help
You removed the 's' (first parameter) that was originally in your code - $stmt->bind_param('s', $username); -
Warning with MySQLi prepared statement
PFMaBiSmAd replied to pahunrepublic's topic in PHP Coding Help
bind_param() deals with the replaceable parameters in the query. It would be a little hard to tell you what is wrong with your code without seeing the code that is responsible for the error. -
array_count_values would directly get a count of each existing ip address. You can then simply test if the ip address has an entry (or not) in the resulting array and get that count.
-
mysql_fetch_row() won't return an associative array. You would need to use mysql_fetch_assoc() Are you developing and debugging your code on a system with error_reporting set to E_ALL and display_errors set to ON so that all the errors php detects will be reported and displayed? You will save a ton of time.
-
See - http://php.net/sprintf Use a format specifier of %03d
-
session variable - strange thing happening
PFMaBiSmAd replied to scmeeker's topic in PHP Coding Help
This problem smells of register_globals being on (your $_GET['username'] sets your $_SESSION['usrename'] variable.) What does a phpinfo(); statement show for the register_globals setting? -
Rookie question regarding include files with PHP..???
PFMaBiSmAd replied to angelleye's topic in PHP Coding Help
I edited my post above with information about $_SERVER['DOCUMENT_ROOT'] that addresses that question. -
Rookie question regarding include files with PHP..???
PFMaBiSmAd replied to angelleye's topic in PHP Coding Help
HTML paths are URL's, because it is the browser that is requesting the page being specified. By default, include statements are file system paths, because it is the web server/php is that reading the file being specified. URL's !== file system paths. $_SERVER['DOCUMENT_ROOT'] will hold the file system path to your document root folder (assuming your web server is set up correctly.) You can prepend $_SERVER['DOCUMENT_ROOT'] to your file_path/file_name to supply an absolute file system path to an include statement. Echo $_SERVER['DOCUMENT_ROOT'] to find out what it actually contains. It may or may not have the trailing slash /, depending on who setup your server. -
make additional upload form fields appear
PFMaBiSmAd replied to Mr.Canuck's topic in PHP Coding Help
Integrating that dynamic "add an upload field" code (http://www.maheshchari.com/multifile-upload/) does not involve submitting two different forms or having more than one submit button... The action="..." attribute is simply the page that the form submits to and you would use your page name, not the arbitrary name that was used in the demo code. Whatever method you end up using, please use an array as the name="..." attribute (like the multifile-upload code is doing, i.e. name="images[]") so that you can simply loop over the uploaded files to process them. -
It would take seeing what line was is to narrow down the possibilities, but you either have - 1) Some characters in your file before the first opening <?php tag that is on line one, 2) Some code on line one that is sending output or is the output, 3) A file that has been saved with the BOM (Byte Order Mark) characters at the start of the file.
-
session_start() has go to go on a page before any characters are output to the browser. In your first code you have about 11 lines of html being output before the session start_statement(). Are you developing and debugging this code on a system with error_reporting set to E_ALL and display_errors set to ON so that all the php detected errors will be reported and displayed? You will save a ton of time. All that means is that you set a variable and echoed it. That does not mean it is actually a session variable that will carry over between pages.
-
The \ characters are NOT inserted into the database. They only exist in the query string so that special sql characters can be put in as data rather than being operated on as part of the sql syntax.
-
You are retrieving everything with a SELECT query, looping through that data, deleting all the matching name= values, so, of course it is deleting everything... Remove the SELECT query and all the logic related to it. Why are you doing that in code that presumably is for deleting data from a table? Your code would need to receive a piece of unique data that identifies the row(s) that you do want to delete. Nothing in your posted code either makes a link/form that would provide that unique identifying data or makes use of that data if it was supplied.