-
Posts
2,134 -
Joined
-
Last visited
-
Days Won
42
Everything posted by benanamen
-
Auto generate a number based on three from an array with rules
benanamen replied to bluefrog's topic in PHP Coding Help
` -
Auto generate a number based on three from an array with rules
benanamen replied to bluefrog's topic in PHP Coding Help
To avoid the X Y Problem could you please provide an overview of the problem you are trying to solve. (I dont mean an explanation of how you think you need to do something.) -
Is the file named with a .php extension and are you running it on a web server with Php installed? The fact that the code is using MD5 tells me your code is way outdated. You shouldn't be using this.
-
*
-
After some digging I found something that works UPDATE your_table SET date_field = DATE(STR_TO_DATE(date_field, '%m/%d/%Y')) WHERE DATE(STR_TO_DATE(date_field, '%m/%d/%Y')) <> '0000-00-00';
-
On another forum I ran across someone with a problem I have never had to deal with and am interested in the solution for it. He has dates in varchar formatted as 12/25/2015 and wants to update so the date is formatted as a proper date (YYYY-MM-DD) with a date column type. Off the top of my head I was thinking, Create a new date type column Do an update on the dates to replace the slashes with dashes. UPDATE table SET baddate = REPLACE(baddate, '/', '-'); Then make a little script to query the bad dates in reverse twice and re-insert the data with a foreach to the correct date column. SELECT reverse(baddate) AS rev, (SELECT REVERSE(rev) FROM mytable) FROM mytable foreach ($result AS $row){ //Insert data to real date column } I am wondering what a 100% sql solution would be or any other ideas to deal with it.
-
Pingendo is not an editor, as it says on their site "app for Bootstrap prototyping". It is fairly new and still has code bugs that I informed them of long ago and had gotten response back that they would fix it yet they have not. It also uses some non standard Bootstrap CSS Classes, so you would have to use the modified Pingendo CSS .
-
Definitely a problem with your "editor".
-
Pictures are for hanging on the wall. Post your code.
-
Did you add the missing quote I already told you about?
-
Understanding what a EVAL and base_decoder is doing
benanamen replied to blmg2009's topic in PHP Coding Help
When someone has gone to that much trouble to hide code it is pretty much always a backdoor hacker script. -
You have numerous problems with that code. You are missing a quote here: $mail->Password = "Password"// place your smtp password here Your html is all over the place incorrectly. You have two html start tags. You have several closing tags with no opening tags. more coming.....
-
Why would you go to a host going backwards in PHP versions? The current version is PHP 7. You need to get a new host. It is ridiculous to fix code going backwards.
-
Is there some reason you are not using the password_hash function?
-
On the review side, your site/server has numerous security issues and you are vulnerable to click-jacking.
-
Flat files for content management? Really?
-
@Jaques1, Php7 has already been released on Dec 3, 2015
-
You are using deprecated code that will not work at all in the current Php release. You need to be using PDO with prepared statements. There are several other problems I am sure other posters will point out.
-
You want help, post some code.
-
clone set of form fields and append number to name based on variable
benanamen replied to SF23103's topic in PHP Coding Help
For that much html you should use heredoc or escape out of php. -
clone set of form fields and append number to name based on variable
benanamen replied to SF23103's topic in PHP Coding Help
You are going about it wrong. Use a for loop to generate the field sets. In the following example, 3 is the number passed from page 1. <?php for ($x = 0; $x <= 3; $x++) { echo "<input name="First_Name[]" type="text" value="" size="16" maxlength="35" placeholder="First"/>>"; } ?> The element names need [ ], not numbers appended. That will create an indexed array of your form fields. ie. cell_phone[] If your database "requires" the under_score_numbers you have something else wrong with your DB design. If you post a dump of your DB schema we can tell you if it needs anything. You would use a for loop to insert into your DB <?php if ($_POST) { $db = new PDO("mysql:host=localhost;dbname=phphelp_form_array", "user", "pass"); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $insertStmt = $db->prepare("INSERT INTO datatable (field1, field2) VALUES (?,?)"); for ($i = 0; $i < count($_POST['field1']); $i++) { $insertStmt->execute(array( $_POST['field1'][$i], $_POST['field2'][$i] )); } } ?> -
Column count doesn't match value count at row 1
benanamen replied to Chrisj's topic in PHP Coding Help
Stop hiding errors with all those @ signs. Errors are your friend. They tell you when something is wrong. You are also using deprecated code that will not work at all in the current Php release. You also dont need to close the connection. It closes automatically when the script is done. You should also be using the database to check for a duplicate username by setting a unique constraint. There are recent posts on this forum detailing the "race condition" that creates. Text formatting has no place in code. You need to be using CSS. I am sure there is more wrong, but I pointed out enough already that you need to do a complete re-write using PDO with prepared statements. -
Get count of 'current' associated status each month
benanamen replied to Psycho's topic in MySQL Help
Not sure if this will be helpful, but it sounds a lot like something I recently had to do. Hopefully it helps. Output was used for line chart. See attachment. This is the query I used for my purpose: SELECT C.month, sum(slab) as slab, sum(dried_in) as dried_in, sum(drywall) as drywall, sum(frame) as frame, C.year_month_number FROM ( (SELECT CASE MONTH (l.frame_date) WHEN 1 THEN CONCAT('Jan','-',Year (l.frame_date)) WHEN 2 THEN CONCAT('Feb', '-', Year (l.frame_date)) WHEN 3 THEN CONCAT('Mar','-',Year (l.frame_date)) WHEN 4 THEN CONCAT('Apr', '-', Year (l.frame_date)) WHEN 5 THEN CONCAT('May', '-', Year (l.frame_date)) WHEN 6 THEN CONCAT('Jun', '-', Year (l.frame_date)) WHEN 7 THEN CONCAT('Jul', '-', Year (l.frame_date)) WHEN 8 THEN CONCAT('Aug', '-', Year (l.frame_date)) WHEN 9 THEN CONCAT('Sep', '-', Year (l.frame_date)) WHEN 10 THEN CONCAT('Oct', '-', Year (l.frame_date)) WHEN 11 THEN CONCAT('Nov', '-', Year (l.frame_date)) WHEN 12 THEN CONCAT('Dec', '-', Year (l.frame_date)) ELSE 'Unknown' END as 'month', null as slab, null as drywall, COUNT(IF(l.frame_date is not null, 1, 0)) AS frame, null AS dried_in, CONCAT(Year (l.frame_date),LPAD(MONTH (l.frame_date),2,0)) year_month_number FROM lot as l INNER JOIN lot_type AS lt ON l.lot_type_id = lt.lot_type_id INNER JOIN block as b ON b.block_id=l.block_id INNER JOIN community as c ON c.community_id=b.community_id WHERE ( c.contract_type_id = 1 OR c.contract_type_id = $contract_type_id ) AND l.$active_column=1 AND l.lot_type_id <> 1 and l.frame_date is not null and (frame_date <= CURDATE() and frame_date >= DATE_ADD(DATE_ADD(CURDATE(),INTERVAL -11 month), interval -(day(DATE_ADD(CURDATE(),INTERVAL -11 month)) - 1) day)) GROUP by MONTH (l.frame_date) ORDER BY MONTH (l.frame_date) ASC) UNION ALL (SELECT CASE MONTH (l.drywall_date) WHEN 1 THEN CONCAT('Jan','-',Year (l.drywall_date)) WHEN 2 THEN CONCAT('Feb', '-', Year (l.drywall_date)) WHEN 3 THEN CONCAT('Mar','-',Year (l.drywall_date)) WHEN 4 THEN CONCAT('Apr', '-', Year (l.drywall_date)) WHEN 5 THEN CONCAT('May', '-', Year (l.drywall_date)) WHEN 6 THEN CONCAT('Jun', '-', Year (l.drywall_date)) WHEN 7 THEN CONCAT('Jul', '-', Year (l.drywall_date)) WHEN 8 THEN CONCAT('Aug', '-', Year (l.drywall_date)) WHEN 9 THEN CONCAT('Sep', '-', Year (l.drywall_date)) WHEN 10 THEN CONCAT('Oct', '-', Year (l.drywall_date)) WHEN 11 THEN CONCAT('Nov', '-', Year (l.drywall_date)) WHEN 12 THEN CONCAT('Dec', '-', Year (l.drywall_date)) ELSE 'Unknown' END as 'month', null as slab, COUNT(IF(l.drywall_date is not null, 1, 0)) AS drywall, null as frame, null AS dried_in, CONCAT(Year (l.drywall_date),LPAD(MONTH (l.drywall_date),2,0)) year_month_number FROM lot as l INNER JOIN lot_type AS lt ON l.lot_type_id = lt.lot_type_id INNER JOIN block as b ON b.block_id=l.block_id INNER JOIN community as c ON c.community_id=b.community_id WHERE ( c.contract_type_id = 1 OR c.contract_type_id = $contract_type_id ) AND l.$active_column=1 AND l.lot_type_id <> 1 and l.drywall_date is not null and (drywall_date <= CURDATE() and drywall_date >= DATE_ADD(DATE_ADD(CURDATE(),INTERVAL -11 month), interval -(day(DATE_ADD(CURDATE(),INTERVAL -11 month)) - 1) day)) GROUP by MONTH (l.drywall_date) ORDER BY MONTH (l.drywall_date) ASC) UNION ALL (SELECT CASE MONTH (l.slab_date) WHEN 1 THEN CONCAT('Jan','-',Year (l.slab_date)) WHEN 2 THEN CONCAT('Feb', '-', Year (l.slab_date)) WHEN 3 THEN CONCAT('Mar','-',Year (l.slab_date)) WHEN 4 THEN CONCAT('Apr', '-', Year (l.slab_date)) WHEN 5 THEN CONCAT('May', '-', Year (l.slab_date)) WHEN 6 THEN CONCAT('Jun', '-', Year (l.slab_date)) WHEN 7 THEN CONCAT('Jul', '-', Year (l.slab_date)) WHEN 8 THEN CONCAT('Aug', '-', Year (l.slab_date)) WHEN 9 THEN CONCAT('Sep', '-', Year (l.slab_date)) WHEN 10 THEN CONCAT('Oct', '-', Year (l.slab_date)) WHEN 11 THEN CONCAT('Nov', '-', Year (l.slab_date)) WHEN 12 THEN CONCAT('Dec', '-', Year (l.slab_date)) ELSE 'Unknown' END as 'month', COUNT(IF(l.slab_date is not null, 1, 0)) AS slab, null as drywall, null as frame, null AS dried_in, CONCAT(Year (l.slab_date),LPAD(MONTH (l.slab_date),2,0)) year_month_number FROM lot as l INNER JOIN lot_type AS lt ON l.lot_type_id = lt.lot_type_id INNER JOIN block as b ON b.block_id=l.block_id INNER JOIN community as c ON c.community_id=b.community_id WHERE ( c.contract_type_id = 1 OR c.contract_type_id = $contract_type_id ) AND l.$active_column=1 AND l.lot_type_id <> 1 and l.slab_date is not null and (slab_date <= CURDATE() and slab_date >= DATE_ADD(DATE_ADD(CURDATE(),INTERVAL -11 month), interval -(day(DATE_ADD(CURDATE(),INTERVAL -11 month)) - 1) day)) GROUP by MONTH (l.slab_date) ORDER BY MONTH (l.slab_date) ASC) UNION ALL (SELECT CASE MONTH (l.dried_in_date) WHEN 1 THEN CONCAT('Jan', '-', Year (l.dried_in_date)) WHEN 2 THEN CONCAT('Feb', '-', Year (l.dried_in_date)) WHEN 3 THEN CONCAT('Mar', '-', Year (l.dried_in_date)) WHEN 4 THEN CONCAT('Apr', '-', Year (l.dried_in_date)) WHEN 5 THEN CONCAT('May', '-', Year (l.dried_in_date)) WHEN 6 THEN CONCAT('Jun', '-', Year (l.dried_in_date)) WHEN 7 THEN CONCAT('Jul', '-', Year (l.dried_in_date)) WHEN 8 THEN CONCAT('Aug', '-', Year (l.dried_in_date)) WHEN 9 THEN CONCAT('Sep', '-', Year (l.dried_in_date)) WHEN 10 THEN CONCAT('Oct', '-', Year (l.dried_in_date)) WHEN 11 THEN CONCAT('Nov', '-', Year (l.dried_in_date)) WHEN 12 THEN CONCAT('Dec', '-', Year (l.dried_in_date)) ELSE 'Unknown' END as 'month', null AS slab, null as drywall, null as frame, Count(IF(l.dried_in_date is not null, 1 , 0)) AS dried_in, CONCAT(Year (l.dried_in_date), LPAD(MONTH (l.dried_in_date),2,0)) year_month_number FROM lot as l INNER JOIN lot_type AS lt ON l.lot_type_id = lt.lot_type_id INNER JOIN block as b ON b.block_id=l.block_id INNER JOIN community as c ON c.community_id=b.community_id WHERE ( c.contract_type_id = 1 OR c.contract_type_id = $contract_type_id ) AND l.$active_column=1 AND l.lot_type_id <> 1 and dried_in_date is not null and (dried_in_date <= CURDATE() and dried_in_date >= DATE_ADD(DATE_ADD(CURDATE(),INTERVAL -11 month), interval -(day(DATE_ADD(CURDATE(),INTERVAL -11 month)) - 1) day)) GROUP by MONTH (l.dried_in_date) ORDER BY MONTH (l.dried_in_date) asc) ) as C GROUP BY C.month ORDER BY C.year_month_number asc -
Dont use if(isset($_POST['submit']) There are issues with it in Internet Explorer. You can do your own research as to what the issues are.
-
You are using deprecated code that will not work at all in the latest version of Php. You need to be using PDO with prepared statements or Mysqli.