-
Posts
16,734 -
Joined
-
Last visited
-
Days Won
9
Everything posted by PFMaBiSmAd
-
creating variable names from $_POST array
PFMaBiSmAd replied to litebearer's topic in PHP Coding Help
If you are going to use extract, use the EXTR_PREFIX_ALL parameter and a unique prefix to prevent hackers from overwriting your program variables. -
This is the definition of the function you are using - This is your usage of it - Did you put your start and end element handlers in as the second and third parameters? Because the callback functions are called by the parser and cannot return values to your program, you would need to use this inside of a class/OOP where you can set class variables inside of the callback functions in order to make the parsed information available to other code in your program.
-
Since that does not show how you are including the file, it will be a little hard for anyone to help with your problem.
-
College student S.O.S. need help with some code
PFMaBiSmAd replied to jahstarr's topic in PHP Coding Help
Your query is executing but it is matching zero rows (because you have extra spaces inside of the % $email % term. Here is the minimum logic you should be using. It will tell you when something fails (the query or the Like comparison) and why - <?php include 'databaseconnect2.php'; $firstname = $_GET["firstname"]; $email=$_GET["email"]; $password=$_GET["Password"]; $sql="Select password from customer where Email Like '%$email%'"; if($result= mysql_query($sql)){ // the query executed without any error if(mysql_num_rows($result)){ // there was at least one row in the result set $row = mysql_fetch_assoc($result); $password2= $row['password']; //var_dump($password2); writeName($email,$password,$password2,$firstname); } else { // zero rows in the result set echo "The entered Email: $email, was not found."; } } else { // the query failed, do some error reporting (logging...) $user_message = "Sorry, cannot proceed due to a database error."; echo $user_message; // output the user message $system_message = "Query failed: $sql<br />Reason: ". mysql_error(); trigger_error($system_message,E_USER_NOTICE); // report/display/log... the system error message } function writeName($email,$password,$password2,$firstname) { if ($password2 == $password) echo "<h1>Welcome back " .$firstname."</h1>"; else echo "<h1>Invalid login</h1>"; } ?> I realize you want to get to the point where your code does "something." But unless your code has error checking/error reporting/error recovery logic in it to get it to tell you when it fails, why it failed, and take an appropriate action when it fails, we cannot directly tell you why it is failing either (we don't automatically have access to your database definition, your data, your database server, or your code running on your server.) -
College student S.O.S. need help with some code
PFMaBiSmAd replied to jahstarr's topic in PHP Coding Help
Try using var_dump() instead of echo. You have got something of a 'perfect storm' going on in that code. Because you don't have any logic in it to test if the query executed without error and then test how many rows were returned AND you are using mysql_fetch_row, you are getting a NULL value which when echoed results in no output. -
$HTTP_POST_VARS were depreciated in php4.1 (released 10-Dec-2001), turned off by default in php5, finally throw a depreciated error when turned on in php5.3, and have been completely removed in the next major version of php. You need to update the code to use $_POST instead.
-
Only form fields that have name="..." attributes are submitted to the server. Your submit form field does not have a name and the php code testing if (isset ($_POST['submit'])) is always false.
-
College student S.O.S. need help with some code
PFMaBiSmAd replied to jahstarr's topic in PHP Coding Help
If you were developing and debugging your code on a system with error_reporting set to E_ALL and display_errors set to ON in your master php.ini, php would help you by displaying all the errors it detects. You will save a TON of time. -
No, unless you are including a file using a URL instead of a file system path. If you post your code, someone can probably quickly tell you why it is not working.
-
If you read your previous thread on this problem, you will learn what is causing it and what to do to fix it. Starting a new thread for the same problem, throws away the history of how you go to this point.
-
GROUP is a reserved mysql keyword and an unfortunate choice for a table name.
-
The HTML specification states that only the x,y coordinates where an image has been clicked are to be submitted. Therefore, you must use either $_POST["submit_x"] or $_POST["submit_y"] in your form processing code to determine that your form was submitted. You can also use a hidden form field (with any name/value) or put a GET parameter on the end of the URL that you then use in your form processing code to detect that your form was submitted. Ref: http://us3.php.net/manual/en/faq.html.php#faq.html.form-image
-
You are getting output from line 1 of your file. Since the php code on line 1 is not producing any output, that means that either you have some characters in your file before the <?php tag or your file has been saved with UTF-8 encoding and the BOM (Byte Order Mark) characters that your editor placed at the start of the file is the output that is occurring that is preventing the header from working. Insure that there are no actual characters before the <?php tag in your file and insure that you save the file without the BOM if you are intentionally saving the file as a UTF-8 encoded file or save the file as an ANSI encoded file.
-
String data is enclosed in single-quotes, making them strings. Column names are not.
-
Make an reference array that contains all the numbers and use array_diff to find out which ones are missing in the target array - http://us.php.net/array_diff
-
Page Redirect after Error Message is Output to the Browser
PFMaBiSmAd replied to makamo66's topic in PHP Coding Help
The best solution is to put your form processing code and your form on the same page. You can output any errors when the form is displayed and repopulate the form fields with the values that were already entered. -
After you fix the errors that AlexWD pointed out in the statlist.php code, you will need to do something about the error in cider.php. That's not where the error you just posted is occurring at. Please read your error messages and the replies people post.
-
Without seeing the code for cider.php (from the start of the file through line 7) it would be a little hard for anyone to tell you what is causing that error.
-
You were already told why that does not work - There are two reasons this won't work - 1) Resources (database connections) cannot be serialized (which is how session data is stored/retreived, and 2) All resources (no matter what variable they are stored in) used on a page are destroyed when the script on that page ends. Even if you were on a server where persistent connections worked, you would still need to execute the code to create/get one of the persistent connections on every page load.
-
If you are asking about class variables other than the actual resource link to the database, the answer is yes. Just make sure that the class definition exists before the session_start() statement.
-
There are two reasons this won't work - 1) Resources (database connections) cannot be serialized (which is how session data is stored/retreived, and 2) All resources (no matter what variable they are stored in) used on a page are destroyed when the script on that page ends.
-
Periods being left from code causing layout problems
PFMaBiSmAd replied to philspliff's topic in PHP Coding Help
Php only outputs what your php code says to output or anything that is not inside of the <?php ?> tags gets automatically output. If you are getting characters output that you don't want, you would need to find out where they are coming from in your source files and remove them. -
Different browsers request pages twice for different reasons. IE generally will request an index.xxx page twice when it tries to read the favicon file. However, you are redirecting to the same page and it is likely that you don't have an exit; statement after your header() redirect to prevent the remainder of the code on the page from being executed and that code is probably clearing or setting a value that is preventing your logic from detecting if the item has already been added. It would take seeing your code to be able to determine if it is or is not responsible for the symptom.
-
MySqli changes the last column in the query to the table's name
PFMaBiSmAd replied to shedokan's topic in MySQL Help
If you seriously want someone in a forum to help find what is wrong, you need to be upfront and provide all the relevant information that you know about the problem. That includes the code that exhibits the problem, the expected results, and the actual results. Don't play around with changing names or interpreting the output you are getting. Just post actual information and actual results.