-
Posts
16,734 -
Joined
-
Last visited
-
Days Won
9
Everything posted by PFMaBiSmAd
-
Do you have error_reporting set to E_ALL and display_errors set to ON so that all the php errors your code produces will be reported and displayed?
-
Your code is not checking for any of the possible upload errors before attempting to move the uploaded file, so it is not able to tell you why the upload is failing and neither can we. You should both be doing this 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 AND you need error checking and error reporting logic in your code to test if the upload was successful before attempting to access any for the uploaded file information. Doing the above would tell you that none of your $_FILES['fileupload'][...] variables are set. When you backtrack this problem to your form, you will find that the <form> tag is missing the enctype= attribute necessary to upload files.
-
Page doesn't show any html after a PHP script.
PFMaBiSmAd replied to membot's topic in PHP Coding Help
You should be able to turn on error_reporting/display_errors in your script. You should also be developing and debugging php code on a local development system, not your school's server. -
You should always have error checking and error reporting logic in your php code so that you will get an indication of when queries fail and you can use msyql_error() to find out why they are failing. Once you check if a query executed without any errors, you should check if a query matched any rows before attempting to fetch any data from those rows.
-
What is killing your code is the use of individual tables AND the select query to find if a table exists and waiting for the query to produce an error when the table does not exist. You also have redundant data. $values[0] is apparently a name and $d_userinformation['username'] is apparently a username. You are creating a name and a username table for each member and you are storing many of the same data values in each table and you are storing the username in the name table and the name in the username table. 50K rows is nothing. I use 5Million rows for testing database applications. Once you get a single row for each user in a COMMON user table, you can then do things like use an INSERT ... ON DUPLICATE KEY UPDATE ... query to either INSERT a new row or UPDATE an existing row for a user, all using just one query. After your $average = line of code, you can probably reduce everything you have shown into just a single query.
-
You can probably make your existing code 2x faster by eliminating all the unnecessary and redundant mysql_real_escape_string() function calls. Using mysql_real_escape_string() on values that your script produces, such as data('Y-m-d') or $average is not necessary because those values can never have characters in them that need escaping. You are also using the same value several different times, such as $values[0] and $_GET['type']. You should escape them once and then just use the escaped value every place.
-
LOL, no wonder it takes your code so long to execute. My first reply was incorrect, your first goal here would not be to make what you are currently doing as efficient as possible, your first goal would be to have an efficient database design. What you showed is not.
-
To get any help, you would need to post an example of the data and the code you are using now. The first goal would be to make what you are currently doing as efficient as possible and 5 queries per line does not sound like an efficient design.
-
Without using extract function,how can this be possible ?
PFMaBiSmAd replied to Rommeo's topic in PHP Coding Help
Yes. With register_globals ON, I can set any of your program or session variables to any value I want. -
PHP not able to render generated images
PFMaBiSmAd replied to compgeek83's topic in PHP Installation and Configuration
Here's another question that someone already had asked - -
Also, back-ticks are mysql specific and should be avoided whenever possible.
-
PHP not able to render generated images
PFMaBiSmAd replied to compgeek83's topic in PHP Installation and Configuration
I don't think your statement of what you did and what the result was is clear to anyone. What is the file name of the code you posted? What URL are you entering into your browser? What is the result you get in the browser window? What does a 'view source' in your browser show? -
The $end error means that php reached the end of your file while it was still expecting a php element. This is usually due to a missing closing } but it can also be due to a missing closing-quote or just about any php syntax with a missing closing element. Once you fix all of the syntax problems in that code, you will find that $HTTP_POST_VARS probably does not work. They were depreciated a really long time ago (php4.1 in Dec 2001), turned off by default in php5, finally throw a depreciated error in php5.3, and scheduled to be completely removed in the next major release of php (should that occur in any of our lifetimes.) You need to use $_POST instead of $HTTP_POST_VARS.
-
The ONLY thing the code in your download file can do is output the headers() followed by the file data. Anything else it does will become part of the downloaded data. Anything else you want to do must be accomplished on the page where the link to the download was located.
-
^^^ Don't use a series of numbered variables. Use an array, then the $_SESSION['number'] variable can simply be used as the array index - $serv[$_SESSION['number']] =
-
access an object created in one page in another page
PFMaBiSmAd replied to babaz's topic in PHP Coding Help
You need to use a session variable, either directly - // class definition here ... session_start(); $_SESSION['viewcart'] = new Cart(); $_SESSION['viewcart']->GetProductCart($user); Or copy to/from a session variable - // class definition here... session_start(); // need for any session variable reference $viewcart = new Cart(); $viewcart->GetProductCart($user); ... $_SESSION['viewcart'] = $viewcart; // copy the object to a session variable in code or use a class destructor // second page // class definition here... session_start(); $viewcart = $_SESSION['viewcart']; // copy back on the second page The class definition must exist before the session_start() statement so that the object can be recreated from the session data. -
^^^ Wow, how did I post that in this thread? Especially since I saw it posted in the correct thread. Edit: I smell a bug in the recently turned on SEO friendly URLs.
-
Missing something obvious with headers being sent
PFMaBiSmAd replied to damianjames's topic in PHP Coding Help
If you have nothing in the es.php file on line one that produces output, then the problem is likely the BOM (Byte Order Mark) characters that your editor places at the start of a UTF-8/16 encoded file when it saves your work. If you must save your file as UTF-8/16 encoded, save it without the BOM or save it as an ANSI encoded file. -
Should work (however as mentioned, the year() function is probably a lot faster) -
-
Upon further review, the first position for substr() is 1.
-
What you posted should work. However YEAR() would be clearer and probably faster - SELECT * FROM Sold WHERE YEAR(sold_date) = 2010
-
Where are the actual To: and From: email address you are trying hosted at? Are they hosted at the sending mail server or at some other ISP?
-
Given that the opening php tag is not in the left-most column, I'm going to guess you have 5 lines of HTML tags at the start of the file, that you did not post, plus the white-space we see before the opening php tag. All of that is output that cannot occur before any setcookie/header/session_start... statement.
-
Does webmail exist and work on the domain where your php script does not work at? The latest version of exim apparently uses an access control list to determine who/what can send emails through it. Normally, a MTA is setup to TRUST the IP address of the web server/php. This satisfies the relaying restrictions and the MTA will accept an email from the php mail() function (which looks like an unauthenticated mail client) and if your script previously worked as written this is(was) likely the case. Given that your php script does not generate any php errors at the mail() function (though it would require that the MTA be configured to give error back to php) it is likely that the MTA is accepting the emails and it is just a matter of finding out where they are or are not going to.
-
Probably NOT. (Only if you have ALL the current settings recorded.) Is this mail server used for any other thing, such as email clients/web based mail interface connecting to it and using it to send/receive email and it works?