-
Posts
16,734 -
Joined
-
Last visited
-
Days Won
9
Everything posted by PFMaBiSmAd
-
My form processes, but none of the information comes thru?
PFMaBiSmAd replied to Lori De's topic in PHP Coding Help
!= means not equal/not the same as, so $name != $name2 means $name is not the same as $name2 -
My form processes, but none of the information comes thru?
PFMaBiSmAd replied to Lori De's topic in PHP Coding Help
Remove the following line of code - global $_POST; A) Never use the global keyword, ever. B) Php has got a built-in 'got ya' for you when you use global with one of the super global arrays ($_POST, $_GET, $_SESSION, ...). It creates a whole new array that is empty because it is not tied to the actual super global array. -
@ym_chaitu and Bottyz, please read the problem. He is typing a literal string in the code. It is a fatal php parse error to put a single-quote inside of an overall single-quoted string because the syntax is broken. No amount of code to replace anything in the string will solve the problem because the code is never executed due to the fatal parse error. The solution, as already given, is to properly form the string, either by escaping the single quote in it or by changing the initial/final quotes around the string to double-quotes.
-
LOL, I see two problems in your code. 1) You are using a while(){} loop to retrieve 'one' expected record. 2) Your WHERE term in the query has some problem.
-
Warning: mysqli_stmt_bind_param() expects parameter 1
PFMaBiSmAd replied to doubledee's topic in PHP Coding Help
Your prepare is failing due to an error of some kind. A) You always need to use error checking/error reporting logic in your code so that you don't trigger follow-on errors when something fails. B) If you echo mysqli_error($dbc) as part of your error reporting logic, it will tell you why the prepare statement failed. -
A simple way writing to a specific line
PFMaBiSmAd replied to Freedom-n-Democrazy's topic in PHP Coding Help
Not unless all the lines are the same length or you have an index with the length of each line so that you can fseek to the proper point in the file. Then you will have a problem of writing something new to the file if the length is greater than the line that was already stored there. You will typically need to read/write the file up to the point where you want to store the new information, write the new information, than read/write the remainder of the file. If the file is small enough to fit entirely in available memory, it is easiest to use file to read the lines into an array, replace the line you are interested in, then write the array back to the file. -
Your form does not have a field with a name='submit' attribute, so your form processing code, which tests if (isset($_POST['submit'])) will never execute. You need to have a form field with name='submit'. I recommend a hidden field with that name so that all browsers will send the value regardless of how the form gets submitted.
-
I would echo the $update variable so that you can proofread it to make sure it contains what you think, such as a valid id value in the where clause. You can also get php/mysql to tell you if/why a query is failing by using mysql_error() - mysql_query($update) or die(mysql_error());
-
Table and column names do not get enclosed by single-quotes as that would make them literal string data, not table and column names.
-
$user_array['rank'] (an associative index named 'rank') is not the same as $row["$rank"] (a php variable named $rank inside of a double-quoted string.) You now have two queries instead of one. I hope you are not trying to make a real application that must perform well with a lot of concurrent visitors. <?php $result = mysql_query("SELECT rank,balance FROM user_info WHERE id='$id'"); $user_array = mysql_fetch_assoc($result); $real_rank = $user_array['rank']; $real_balance = $user_array['balance']; Edit: Or even simpler - <?php $result = mysql_query("SELECT rank,balance FROM user_info WHERE id='$id'"); list($real_rank,$real_balance) = mysql_fetch_row($result);
-
how to set up the table structure to do date ranges searches?
PFMaBiSmAd replied to GridCube's topic in MySQL Help
UPDATE your_table SET date_column = STR_TO_DATE(CONCAT(YEAR,MONTH,DAY),'%Y%M%d') -
@Drummin, for what you are suggesting, the actual error messages you were getting would have indicated that the source file did not exist. Not that the destination folder did not exist. Not the exact same error messages, so not the exact same problem. You cannot generalize that an error message that contains "failed to open stream" always means the same thing.
-
how to set up the table structure to do date ranges searches?
PFMaBiSmAd replied to GridCube's topic in MySQL Help
You would use a DATE (YYYY-MM-DD format) data type. There are several reasons - 1) It is optimized to use the least amount of storage. 2) It results in the fastest queries involving dates and manipulation of dates. 3) It allows dates to be compared and sorted using greater-than/less-than comparisons. 4) It allows the few dozen mysql data/time functions to work on the value in a query (which will solve your interval problem.) You can create a new date column and populate it from your existing data using a single UPDATE query (a query without a WHERE clause will update all the rows at one time) and the mysql STR_TO_DATE() function to produce a DATE (YYYY-MM-DD) value from your existing three column values. -
Either your code is setting the value (probably with an if($_SESSION['user'] = 'root'){ (one = sign instead of two)) or register_globals are on and you have a $_POST['user'], $_GET['user'], or $_COOKIE['user'] variable that has the value 'root' in it and register_globals is setting the $_SESSION['root'] variable to that value. What does a phpinfo(); statement show for the register_globals setting and do have any code with an = 'root' in it or a post/get/cookie value like I mentioned?
-
Bull shit unexpected T_ENCAPSED_AND_WHITESPACE
PFMaBiSmAd replied to Freedom-n-Democrazy's topic in PHP Coding Help
Choice #3 would tend to confuse a noob into thinking that he should not put quotes around associative array names at all, thereby causing problems with undefined constant errors, and introducing inconstant use of php variable syntax. -
You need to set the destination path to an actual folder that exists in the following statement -
-
Do you actually have variables $balance and $rank that contain column names in your table so that $row["$balance"] and $row["$rank"], reference actual columns in your database table - $real_balance = $row["$balance"]; $real_rank = $row["$rank"];
-
What does the following show - var_dump($real_rank); var_dump($real_balance);
-
Should work - SELECT SUM(field9) as total9, SUM(field10) as total10 FROM your_table .... GROUP BY field5 ^^^ That's generally a bad idea and takes a lot more server resources. If you are doing something like looping over each company name or looping over dates or ranges of dates, you can generally do this all in 1 (one) query and then simply display the results the way you want. What's your overall code from the first query statement to end of the main while loop?
-
If you look at those two numbers, you will see that the next week one is less-than the today one. mktime() does not take the string output of a data() function as a parameter. It takes up to six comma separated parameters. Your code is supplying the output from the date() function as the first (hour) parameter to the mktime() function. All you need to use are the two strtotime() statements (to get the correct result) - $unixtimestamp = strtotime("today"); echo "Unix Timestamp : " . $unixtimestamp . "<br /><br />"; $unixtimestamp2 = strtotime("+1 week"); echo "Unix Timestamp (nxt week): " . $unixtimestamp2 . "<br /><br />";
-
An example showing what you want would help.
-
Assuming you have the leading zero's stored with the month - AND CONCAT(year,month) BETWEEN '$startyear$startmonth' AND '$endyear$endmonth'
-
The variable you are forming the query in and the variable you are putting into the mysql_query() statement are not the same. What trigger_error() reports and displays/logs is dependent on the error_reporting and display_errors/log_errors settings. When developing and debugging php code, you should always have error_reporting set to E_ALL and display_errors set to ON. You would have been (likely) getting an undefined variable error on the variable being put in the mysql_query() statement and an 'empty query' error from the trigger_error statement.
-
I'm going to guess that in your actual code, you are overwriting the result resource that is in $query, inside of the loop. Is that the actual complete code that is inside the while(){} loop?
-
Double rows? (two rows for every individual value.)
PFMaBiSmAd replied to Caliber Mengsk's topic in MySQL Help
By default, mysql_fetch_array returns an array with both numerical and associative indexes. Use mysql_fetch_assoc instead.