-
Posts
16,734 -
Joined
-
Last visited
-
Days Won
9
Everything posted by PFMaBiSmAd
-
I'll echo what Daniel0 just stated. The end of life of php4 was two years ago this month. You should be spending your time planning how you are going to upgrade to php5 and finding out the method your web host has provided for you to select php5 on their servers.
-
phpmyadmin is a php application. You can install it on any web server that has php.
-
Assuming mysql, execute this query (substituting your actual column names) to update your new column with the concatenation of - 'The ', your Sname column values, and ' Family' - UPDATE your_table SET your_new_column = CONCAT('The ', Sname, ' Family')
-
The point of asking you to post the code that is producing the error, is so that someone could tell you why your code is producing that error. Since you altered the code for the post and it no longer produces the error, something that you removed when you posted the code is what is causing the problem. Best guess is you had some un-escaped double-quotes in the part of the code you removed when you posted it.
-
Your code is producing an invalid DATETIME value, so the default is being inserted and that is what you get back when you attempt to display it. You would need to troubleshoot what your code is doing in order to find out why it is producing and tying to insert an invalid value into your table.
-
Code that demonstrates the method I suggested above - <?php // 'required' field validation - $fields = array(); // array of expected field names $fields[] = 'firstName'; $fields[] = 'lastName'; $fields[] = 'day'; $fields[] = 'month'; $fields[] = 'year'; $fields[] = 'country'; $fields[] = 'emailAddress'; $fields[] = 'username'; $fields[] = 'password'; $empty_fields = array(); // array to hold list of empty fields foreach($fields as $field){ if(empty($_POST[$field])){ $empty_fields[] = $field; } } if(empty($empty_fields)){ // all fields contained something // process the form data here... } else { // at least one field was empty // pretend this is where the form is output - echo "The following fields were empty, please enter the requested infomration -<br />"; foreach($empty_fields as $field){ echo "$field<br ?>"; } } ?> Once you have an array of the expected field names you can also use that information to use php to dynamically produce your form.
-
I would make an array that contained the expected field names. Then user a foreach loop to iterate through the array of expected field names and check if the corresponding $_POST variable is empty or not. For any that are empty, add the name of the field to an error array. You can then test if the error array is empty (no errors) or not. Since the error array contains an element with the field name for each field that was empty, you can use that information as you desire on the form to prompt for which fields must be filled in.
-
You are getting a FALSE value from your mysql_query() because the query is failing. You need single-quotes around the $username variable in the query so that it will be a string value and you need to use only one = sign for the comparison in the query.
-
Multiple Queries - Relationship Question
PFMaBiSmAd replied to EternalSorrow's topic in PHP Coding Help
The problem is the extract(). It is overwriting the $category variable being used in the presentation code by the $category variable from the query. Since you are using the correct $row['category'] variable, there is no need for the extract() (and you should not really use extract() without specifying one of the options as it happens to overwrite existing variables by default.) -
Dynamic dropdown with dynamically selected value
PFMaBiSmAd replied to jrobles's topic in PHP Coding Help
Untested, but should work - { $value = 'FL'; // get the value from the correct place while($row = mysql_fetch_object($result)){ $selected = ($value == $row->ID) ? "selected='selected'" : ""; echo"<option value='$row->ID' $selected>$row->Name</option>"; } } -
mysql_query() for a SELECT query returns either a FALSE value or a result resource. The FALSE value is returned if the query failed to execute. This is usually due to syntax errors or problems with the database. A result resource will be returned if the query executed without any errors. A query that matches zero rows in your table is a successful query and it returns a result resource. You must use mysql_num_rows to find out how many rows there are in the result set that is returned.
-
Multiple Queries - Relationship Question
PFMaBiSmAd replied to EternalSorrow's topic in PHP Coding Help
One of the great points of using a database is you can normally just retrieve the rows you want in the order that you want them, then you simply iterate over the rows in the result set in your presentation code to format the information the way you want. You can do all of your queries using a single query. Then, someone just asked and was shown how to output a new heading only when it changes value - http://www.phpfreaks.com/forums/index.php/topic,279704.msg1324897.html#msg1324897 Edit: Untested, but a single query that looks like it will retrieve the rows you want in the order that you want them - $query = "SELECT * FROM feudal WHERE `year`= '$year' AND `type` = 'Fanfiction' ORDER BY category, place, title" I'm not sure how your author information is related to how you want your output, but you should probably add it in the ORDER BY list between category and place. -
Post an example of your include statement. Best guess is that you are using a URL instead of a file system path and your server is making a HTTP request back to itself for every include statement.
-
$_SESSION variables are not depreciated and don't produce depreciated error messages, so you will need to be way more specific about what function you used that resulted in the error message. There is a list of everything the posted code should not be doing (I don't know where you found that but it is way way out of date) - 1) Don't use short open php tags <? Always use full opening php tags <?php 2) Don't use ob_start() unless you intentionally want to buffer output. If you were getting a header() error message, find and fix what is causing that error. 3) Don't use $_REQUEST variables. You don't know where the actual values comes from and they allow a hacker to easily feed your script a dictionary lookup attack of usernames and passwords by simply putting GET parameters on the end of the URL. Use the correct $_POST variables from your form. 4) You are not escaping the external user supplied values being put into the query, so a hacker can easily inject sql and dump all the usernames and passwords you have stored in your admin table. 5) You are storing the passwords in the database table as plain text, so when a hacker does get a copy of them (see item #4) he does not need to do any work to find the actual passwords. 6) $HTTP_SESSION_VARS were depreciated in php4.1, over 7 years ago, turned off by default in php5, and completely removed in upcoming php6. Use the $_SESSION superglobal array instead. 7) You would need to assign $row['level'] to a $_SESSION variable like cags showed you in his post, in order to make that value available as a session variable.
-
Just use mysql_fetch_object and specify the class_name you want to create an instance of -
-
$foo = array('[node_id]' => 684); is not the same as $foo = array('node_id' => 684); You need to post your actual code.
-
http://us2.php.net/mysql_affected_rows
-
A member system works by limiting the access to each page to only logged in members. Therefore, each page you wish to protect must check if the current visitor is a logged in member. It should not matter that someone finds a link to a protected page as the result of a search on your site (the search should filter out links that non-logged in members are not supposed to get in the search result, but even if a member posts a link to a 'secure' page that should not permit a non-logged in visitor from accessing the page just because they possess the URL of that page) because the page each link goes to should check what the current visitor is allowed to have output on that page. If you don't understand what I just wrote and how that relates to the code on your pages that is responsible for limiting access to each page, you should probably hire a programmer to do this work.
-
What does the error checking and error reporting logic in your code tell you why the INSERT query does not work? Did you echo $sql so that you know if it contains what you expect?
-
Someone just asked and was shown how to output a new heading only when it changes value - http://www.phpfreaks.com/forums/index.php/topic,279704.msg1324897.html#msg1324897
-
It's up to your presentation code to output it the way you want. The query just returns the rows you want in the order that you want them.
-
The code in the first post 'works', so best guess is either the loop that code is in (if any) is not providing expect values in $result_row or the form processing code is not processing it correctly.
-
There's a section in the php manual that lists what was changed going from php5.2 to 5.3. However, your problem is probably some old out of date code that is relying on register_globals, that were turned off by default in php4.2 in the year 2002. Where are all the variables $indate, $user_id, $user_password, ... being set at in your code? The correct way to access them would be the same as what you have for the $_POST['submit'] variable, using the $_POST superglobal array. Since register_globals have been completely removed in php6, now is the time to upgrade your code to current recommend standards. Also, you should not use the mysql PASSWORD() function in your application -
-
About the only reasonable explanation would be that the output is invalid HTML (for example, there is an opening a HTML comment <!-- tag but no closing one) or you have a form that is invalid HTML that does not submit any data in most browsers. Have you validated your resulting page(s) at the w3.org validators? Edit: Have you done a "view source" of the page(s) in the browsers where they don't seem to work so that you know what if anything is being output?