Jump to content

EarthDay

Members
  • Posts

    41
  • Joined

  • Last visited

Everything posted by EarthDay

  1. Hi there The outputs are string(3) "252" string(3) "151" which are correct. I thought it was an issue with the client_id and put in there for testing purposes. Will be removed when fixed.
  2. Hi there, I have full error reporting on in my test environment but is not producing any error reports. I've tried a VARDUMP and comes back with; array(34) { ["id"]=> string(3) "151" ["learning_opportunities"]=> string(2) "No" ["contact_for_other_purposes"]=> string(5) "Phone" ["empowering_communities"]=> string(2) "No" ["empowering_communities_name"]=> string(22) "David Testffffffffffff" ["empowering_communities_sign"]=> string(9) "Dave Test" ["empowering_communities_date"]=> string(10) "2023-10-10" ["participant_enrolled_onto"]=> string(2) "No" ["participant_moved_another_provider"]=> string(2) "No" ["participant_eligible_free_school"]=> string(2) "No" ["british_passport"]=> string(3) "Yes" ["eec_passport"]=> string(2) "No" ["euss_via_home"]=> string(2) "No" ["preferred_evidence"]=> string(3) "Yes" ["provide_preferred_evidence"]=> string(9) "345345353" ["option_adoption_vertificate"]=> string(0) "" ["option_driving_licence"]=> string(0) "" ["option_non_eu_passport"]=> string(0) "" ["option_biometric_immigration"]=> string(0) "" ["option_current_immigration"]=> string(0) "" ["option_marriage_civil_partnership"]=> string(0) "" ["option_other_evidence"]=> string(0) "" ["option_nine"]=> string(35) "Utility Bill/Phone Bill/Council Tax" ["details_evidence_provided"]=> string(7) "sdghsdf" ["dwp_job_centre_letter"]=> string(0) "" ["confirmation_relevant_organisation"]=> string(0) "" ["self_certification_evidence"]=> string(3) "fff" ["partcipant_told_support"]=> string(3) "Yes" ["participant_file_completed_remotly"]=> string(2) "No" ["declaration_name_please_print"]=> string(7) "gdfgsdg" ["declaration_job_title"]=> string(8) "sdfgsdfg" ["declaration_organisation"]=> string(8) "sdfgsdfg" ["declaration_signature_date"]=> string(10) "2023-10-10" ["declaration_signature"]=> string(6) "dfgshf" } string(69) "No rows updated. Possible reasons: No changes detected or invalid ID." Cheers, ED.
  3. Hi there, I am trying to get an update form to work and it does not save the information to the database. My link to update a record is forms/decs-update.php?id=<?=$contact['id']?>&decs_id=<?=$decs['id']?> The information loads on the page from the diabase but does not save the information to the database and give me an error message; No rows updated. Possible reasons: No changes detected or invalid ID. <?php include '../../main.php'; check_loggedin($pdo); $msg = ''; ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); if (!isset($_GET['id'])) { exit('No ID parameter provided!'); } $stmt = $pdo->prepare('SELECT username,email,role FROM accounts WHERE id = ?'); $stmt->execute([ $_SESSION['id'] ]); $account = $stmt->fetch(PDO::FETCH_ASSOC); $stmt = $pdo->prepare('SELECT id,username FROM accounts'); $stmt->execute(); $all_account_info = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt = $pdo->prepare('SELECT * FROM contacts WHERE id = ?'); $stmt->execute([$_GET['id']]); $contact = $stmt->fetch(PDO::FETCH_ASSOC); $Rstmt = $pdo->prepare('SELECT * FROM esf_decs WHERE id = ?'); $Rstmt->execute([$_GET['decs_id']]); $decs = $Rstmt->fetch(PDO::FETCH_ASSOC); if (!$contact) { exit('Contact doesn\'t exist with that ID!'); } if ($_SERVER['REQUEST_METHOD'] === 'POST') { try { $client_id = trim($_POST["client_id"]); $learning_opportunities = trim($_POST["learning_opportunities"]); $learning_opportunities = trim($_POST["learning_opportunities"]); $contact_for_other_purposes = trim($_POST["contact_for_other_purposes"]); $empowering_communities = trim($_POST["empowering_communities"]); $empowering_communities_name = trim($_POST["empowering_communities_name"]); $empowering_communities_sign = trim($_POST["empowering_communities_sign"]); $empowering_communities_date = trim($_POST["empowering_communities_date"]); $participant_enrolled_onto = trim($_POST["participant_enrolled_onto"]); $participant_moved_another_provider = trim($_POST["participant_moved_another_provider"]); $participant_eligible_free_school = trim($_POST["participant_eligible_free_school"]); $british_passport = trim($_POST["british_passport"]); $eec_passport = trim($_POST["eec_passport"]); $euss_via_home = trim($_POST["euss_via_home"]); $preferred_evidence = trim($_POST["preferred_evidence"]); $provide_preferred_evidence = trim($_POST["provide_preferred_evidence"]); $option_adoption_vertificate = trim($_POST["option_adoption_vertificate"]); $option_driving_licence = trim($_POST["option_driving_licence"]); $option_non_eu_passport = trim($_POST["option_non_eu_passport"]); $option_biometric_immigration = trim($_POST["option_biometric_immigration"]); $option_current_immigration = trim($_POST["option_current_immigration"]); $option_marriage_civil_partnership = trim($_POST["option_marriage_civil_partnership"]); $option_other_evidence = trim($_POST["option_other_evidence"]); $option_nine = trim($_POST["option_nine"]); $details_evidence_provided = trim($_POST["details_evidence_provided"]); $dwp_job_centre_letter = trim($_POST["dwp_job_centre_letter"]); $confirmation_relevant_organisation = trim($_POST["confirmation_relevant_organisation"]); $self_certification_evidence = trim($_POST["self_certification_evidence"]); $partcipant_told_support = trim($_POST["partcipant_told_support"]); $participant_file_completed_remotly = trim($_POST["participant_file_completed_remotly"]); $declaration_name_please_print = trim($_POST["declaration_name_please_print"]); $declaration_job_title = trim($_POST["declaration_job_title"]); $declaration_organisation = trim($_POST["declaration_organisation"]); $declaration_signature_date = trim($_POST["declaration_signature_date"]); $declaration_signature = trim($_POST["declaration_signature"]); $stmt = $pdo->prepare('UPDATE esf_decs SET client_id=?,learning_opportunities=?,contact_for_other_purposes=?,empowering_communities=?,empowering_communities_name=?,empowering_communities_sign=?,empowering_communities_date=?,participant_enrolled_onto=?,participant_moved_another_provider=?,participant_eligible_free_school=?,british_passport=?,eec_passport=?,euss_via_home=?,preferred_evidence=?,provide_preferred_evidence=?,option_adoption_vertificate=?,option_driving_licence=?,option_non_eu_passport=?,option_biometric_immigration=?,option_current_immigration=?,option_marriage_civil_partnership=?,option_other_evidence=?,option_nine=?,details_evidence_provided=?,dwp_job_centre_letter=?,confirmation_relevant_organisation=?,self_certification_evidence=?,partcipant_told_support=?,participant_file_completed_remotly=?,declaration_name_please_print=?,declaration_job_title=?,declaration_organisation=?,declaration_signature_date=?,declaration_signature=? WHERE id=?'); $stmt->execute([$client_id,$learning_opportunities,$contact_for_other_purposes,$empowering_communities,$empowering_communities_name,$empowering_communities_sign,$empowering_communities_date,$participant_enrolled_onto,$participant_moved_another_provider,$participant_eligible_free_school,$british_passport,$eec_passport,$euss_via_home,$preferred_evidence,$provide_preferred_evidence,$option_adoption_vertificate,$option_driving_licence,$option_non_eu_passport,$option_biometric_immigration,$option_current_immigration,$option_marriage_civil_partnership,$option_other_evidence,$option_nine,$details_evidence_provided,$dwp_job_centre_letter,$confirmation_relevant_organisation,$self_certification_evidence,$partcipant_told_support,$participant_file_completed_remotly,$declaration_name_please_print,$declaration_job_title,$declaration_organisation,$declaration_signature_date,$declaration_signature,$_GET['id']]); if($stmt->rowCount()) { $_SESSION['status'] = "The asset information has been successfully updated."; header('Location: ../display.php?id=' . $_GET['id']); exit; } else { $msg = "No rows updated. Possible reasons: No changes detected or invalid ID."; } } catch (PDOException $e) { $msg = "Error: " . $e->getMessage(); } } ?> <form action="decs-update.php?id=<?=$decs['id']?>" method="post" enctype="multipart/form-data"> Database structure `id` int(11) NOT NULL, `client_id` int(11) DEFAULT NULL, `learning_opportunities` varchar(225) DEFAULT NULL, `contact_for_other_purposes` varchar(100) DEFAULT NULL, `empowering_communities` varchar(50) DEFAULT NULL, `empowering_communities_name` text DEFAULT NULL, `empowering_communities_sign` text DEFAULT NULL, `empowering_communities_date` date DEFAULT NULL, `participant_enrolled_onto` varchar(50) DEFAULT NULL, `participant_moved_another_provider` varchar(50) DEFAULT NULL, `participant_eligible_free_school` varchar(50) DEFAULT NULL, `british_passport` varchar(225) DEFAULT NULL, `eec_passport` varchar(225) DEFAULT NULL, `euss_via_home` varchar(225) DEFAULT NULL, `preferred_evidence` varchar(225) DEFAULT NULL, `provide_preferred_evidence` varchar(225) DEFAULT NULL, `option_adoption_vertificate` varchar(225) DEFAULT NULL, `option_driving_licence` varchar(225) DEFAULT NULL, `option_non_eu_passport` varchar(225) DEFAULT NULL, `option_biometric_immigration` varchar(225) DEFAULT NULL, `option_current_immigration` varchar(225) DEFAULT NULL, `option_marriage_civil_partnership` varchar(225) DEFAULT NULL, `option_other_evidence` varchar(225) DEFAULT NULL, `option_nine` text DEFAULT NULL, `details_evidence_provided` varchar(225) DEFAULT NULL, `dwp_job_centre_letter` varchar(225) DEFAULT NULL, `confirmation_relevant_organisation` varchar(225) DEFAULT NULL, `self_certification_evidence` varchar(225) DEFAULT NULL, `partcipant_told_support` varchar(225) DEFAULT NULL, `participant_file_completed_remotly` varchar(225) DEFAULT NULL, `declaration_name_please_print` varchar(225) DEFAULT NULL, `declaration_job_title` varchar(225) DEFAULT NULL, `declaration_organisation` varchar(225) DEFAULT NULL, `declaration_signature_date` date DEFAULT NULL, `declaration_signature` varchar(225) DEFAULT NULL I can't see the issue anywhere Cheers, ED.
  4. Thanks for the advise @maxxd I have resolved this by adding the amending the code to the following; <?php require_once __DIR__ . "/DataSource.php"; $database = new DataSource(); $rowCount = count($_POST["contacts"]); for ($i = 0; $i < $rowCount; $i ++) { $query = "UPDATE `contacts` SET `status` = 'NoShow' WHERE id=?"; $paramType = "i"; $paramValue = array( $_POST["contacts"][$i] ); $isUpdated = $database->update($query, $paramType, $paramValue); } header("Location:index.php"); exit(); ?> The issue that I am having now is that the I have 3 buttons on the bottom of the page that link to different update options and only 2 of them are working, the 3rd one does nothing; Code on JS Fiddle As far as I know, everything looks right and can't see any reason why it would stop working on the 3rd button. Cheers, ED.
  5. Hi there, I am trying to update a multiple rows for a single column and the code that I have wrote runs through fine and does not show any error messages but does not update the rows or column. <?php require_once __DIR__ . "/DataSource.php"; $database = new DataSource(); $sql = "SELECT * FROM contacts"; $result = $database->select($sql); ?> <html> <head> <title>Users List</title> <link rel="stylesheet" type="text/css" href="css/style.css" /> <link rel="stylesheet" type="text/css" href="css/table.css" /> <script language="javascript" src="function.js" type="text/javascript"></script> </head> <body> <div class="phppot-container"> <h1>Users List</h1> <form name="frmUser" method="post" action=""> <div id="message"><?php if(isset($message)) { echo $message; } ?></div> <table class="striped"> <thead> <tr class="listheader"> <th></th> <th>Username</th> <th>Status</th> </tr> </thead> <?php if (is_array($result) || is_object($result)) { foreach ($result as $i => $value) { if ($i % 2 == 0) $classname = "evenRow"; else $classname = "oddRow"; ?> <tr class="<?php if(isset($classname)) echo $classname;?>"> <td><input type="checkbox" name="contacts[]" value="<?php echo $result[$i]["id"]; ?>"></td> <td><?php echo $result[$i]["name"]; ?></td> <td><?php echo $result[$i]["status"]; ?></td> </tr> <?php $i ++; } } ?> <tr> <td colspan="4"><input type="button" name="update" value="Update" onClick="setUpdateAction();" /> <input type="button" name="delete" value="Delete" onClick="setDeleteAction();" /></td> </tr> </table> </form> </div> </body> </html> update.php <?php require_once __DIR__ . "/DataSource.php"; require_once __DIR__ . "/DataSource.php"; $database = new DataSource(); $rowCount = count($_POST["contacts"]); for ($i = 0; $i < $rowCount; $i ++) { $query = "UPDATE contacts SET status = InProgress WHERE id=?"; $paramType = "i"; $paramValue = array( $_POST["users"][$i] ); } header("Location:index.php"); exit(); ?> Any help would greatly be apprciated. Cheers, ED.
  6. Hi there, I was wondering if someone could point me in the right direction please? I am trying to alter my CRUD view table by adding a check box to the row and using a drop down menu to update a field in the database for multiple records. Say that a client has a status of referral and I want to change multiple clients to In Progress, I want to be able to select the clients and use the drop down menu to update the status. Any help would greatly be appreciated. Thanks, ED.
  7. So if the ID exists in the new database, it does not get overwritten.
  8. Hi Kicken, Thank you for your reply, I have just edited my post Cheers, ED.
  9. Hi there, I have wrote a script to copy client data over from our old system to the new system and it's giving me the above error message. I know the script is not very secure but it's located on the internal network and is not open to the internet via firewall rules. I am monitoring use of the script very closely (When I get it working lol) Full error message I have gone through the code and everything appears to be correct and can't seem to see what the problem is. Both tables are the same and using the same version of PHP 8.2 and are located on the same server. I know that I can just export and import but we are manually reviewing what information goes over and this is the easiest way for us to do it. Code; <?php $databaseHost = 'localhost'; $databaseName = ''; $databaseUsername = ''; $databasePassword = ''; $mysqli = mysqli_connect($databaseHost, $databaseUsername, $databasePassword, $databaseName); $id = $_GET['id']; $sql="select from cic_remus.contacts where (id='$id');"; $res=mysqli_query($mysqli,$sql); if (mysqli_num_rows($res) > 0) { // output data of each row $row = mysqli_fetch_assoc($res); if($id==$row['id']) { echo "Already copied"; } } else{ $query=mysqli_query($mysqli,"INSERT INTO cic_kenobi.contacts (status, image, datemovedin, learner_id, title, name, last_name, sex, dob, house_number, address_line_one, address_line_two, city_town, country, postcode, postcode_enrolment, phone, mobile_number, email_address, ethnic_origin, ethnicitys, health_problem, health_disability_problem_if_yes, lldd, education_health_care_plan, health_problem_start_date, education_entry, emergency_contact_details, employment_paid_status, employment_date, unemployed_month, education_training_prior, education_claiming, claiming_if_yes, household_situation, mentor, intext) SELECT status, image, datemovedin, learner_id, title, name, last_name, sex, dob, house_number, address_line_one, address_line_two, city_town, country, postcode, postcode_enrolment, phone, mobile_number, email_address, ethnic_origin, ethnicitys, health_problem, health_disability_problem_if_yes, lldd, education_health_care_plan, health_problem_start_date, education_entry, emergency_contact_details, employment_paid_status, employment_date, unemployed_month, education_training_prior, education_claiming, claiming_if_yes, household_situation, mentor, intext FROM cic_remus.contacts WHERE id =$id"); echo "Successfully copied"; } ?> If I change the below code to $sql="select from cic_remus.contacts where (id='$id');"; to $sql="select `id` from cic_remus.contacts where (id='$id');"; It gives me the error message that the contact already exists with the same ID and does not create a new ID. Cheers, ED.
  10. Hi Berand, I know it's old code, it's part of a system that is getting upgraded later this year. Thank you for this. It's still showing the the week as w8 and not w08 when trying to go to the previous page. Cheers, ED.
  11. H Barand, I have changed the code slightly to match my older script; if(isset($_GET['selectWeek'])){ $week = $_GET['selectWeek']; $num_week = ltrim($week, 'w0')?? 1; $prev = $num_week - 1; $next = $num_week + 1; if ($prev < 1) $prev = 1; if ($next > 53) $next = 53; The issue that I am having now is giving the below error message; week in database is VARCHAR(50) And the link is showing as The error message is caused by line 18 $prev = $num_week - 1; Links <a class='button' href='?selectWeek=<?=$prev?>'>&lt;</a> <input class='weekno' type='text' name='selectWeek' value='<?=$num_week?>'> Cheers, ED.
  12. Hi Barand, Thank you so much for this, it's awesome and worked on the page. I have also have an older script that uses w01 for the week (index.php?selectWeek=w27) - will this also work with the W in the week number? Database id - 1 base_charge - 44.25 week - w08 year - 2023 Cheers, ED.
  13. Hi Barand, Thanks for your reply, I only ever store 1 years worth of data in and remove the old. So there is only one week 1. But will go back to week 52 at the beginning of January / end of December. Cheers, ED
  14. Hi there, I am not sure where to start here so was wondering if someone could point me in the right direction please? I've had a look on Google and can't find anything that works. I have an expense system that shows data by week (index.php?wk=1 for example) and I would like to create a button called Next and Previous to show the previous and next weeks. Database example ID - 1 Week - 1 issue_date - 02/02/2023 money_in money_out initials Many thanks, ED.
  15. Solution SELECT contacts.id as cid,
  16. Hi there, I have setup a join query to show the username from the accounts table when displaying information from my contacts table because it was only showing the user For example, say the contacts ID is 125, the link below will show ID 3 from the accounts table. Should be update.php?id=125 Actually showing update.php?id=3 (There are actually only ID's 2,3 & 4 in the accounts table) $stmt = $pdo->prepare('SELECT contacts.id, contacts.name, contacts.last_name, contacts.dob, contacts.mobile_number, contacts.status, contacts.mentor, contacts.image, accounts.username, accounts.id FROM contacts INNER JOIN accounts ON contacts.mentor=accounts.id'); $stmt->execute([]); $contact = $stmt->fetchAll(PDO::FETCH_ASSOC); The issue that I am having is when I click the Update button to update the client, the page is trying to look for the ID of the account from the accounts table and not the contacts table. = <?php if($contact == null){ echo "<tr><td>No Record Found!</td></tr>"; }else{ foreach($contact as $info){ ?> <tr> <td><?php echo $info['name']; ?> <?php echo $info['last_name']; ?></td> <td><?php echo $info['mobile_number']; ?></td> <td><?php echo $info['status']; ?></td> <td><?php echo $info['dob']; ?></td> <td><?php echo $info['username']; ?></td> <td><img src="<?php echo $info['image']; ?>" alt="" style="height: 30px; width:30px;"></td> <td> --> <a href="display.php?id=<?=$info['id']?>"><i class="fa fa-eye" aria-hidden="true"></i></a> --> <a href="update.php?id=<?=$info['id']?>"><i class="fas fa-pencil-alt"></i></a> --> <?php if ($_SESSION['role'] == 'Admin'): ?><a href="del.php?id=<?=$info['id']?>"><i class="fas fa-trash fa-xs"></i></a><?php endif; ?> </td> </tr> Any help would be greatly appreciated. Cheers, ED.
  17. The working code for the original code I posted; SELECT company.compname, company.compcontact, company.assignedto, accounts.username, accounts.id FROM company INNER JOIN accounts ON company.assignedto=accounts.id where assignedto = ? <td><?= $info['username']; ?></td>
  18. Sorry, I was working on another page that had the same issue.
  19. Firstly, sorry for the late reply. Thank you for the advise mac_gyver I've built my query as; SELECT contacts.name, contacts.last_name, contacts.dob, contacts.mobile_number, contacts.status, contacts.mentor, contacts.image, accounts.username, accounts.id FROM contacts INNER JOIN accounts ON contacts.mentor=accounts.id But it's still showing as a number and not the username. If change the accounts.id to .username - it shows nothing. Any advise please? UPDATE - My fail - Changed the table view from mentor to username and works fine. Thanks again for your help
  20. Firstly, sorry for the late reply. Thank you for the advise mac_gyver I've built my query as; SELECT contacts.name, contacts.last_name, contacts.dob, contacts.mobile_number, contacts.status, contacts.mentor, contacts.image, accounts.username, accounts.id FROM contacts INNER JOIN accounts ON contacts.mentor=accounts.id But it's still showing as a number and not the username. If change the accounts.id to .username - it shows nothing. Any advise please?
  21. Hi there, I am trying to display the username from another table and links by the ID in a table list but is giving me multiple error messages. Code $stmt = $pdo->prepare('SELECT * FROM company'); $stmt->execute([]); $fullContactInfo = $stmt->fetchAll(PDO::FETCH_ASSOC); if($fullContactInfo == true){ $stmt = $pdo->prepare('SELECT * FROM accounts WHERE id = ?'); $stmt->execute([ $fullContactInfo['assignedto'] ]); $memberInfo = $stmt->fetch(PDO::FETCH_ASSOC); } Display code in Table <td><?= $memberInfo['username']; ?></td> Database example Accounts (Example) ID - 1 Username - jbloggs Company assignedto - 1 I have got the code working on another page where it only displays the company information on one page by ?id=1 Any advice please? :) Cheers, ED.
  22. Hi All, Thank you all for your help on this I have figured this out by using the below code $stmt = $pdo->query("SELECT * FROM care_plan_review WHERE reminder_date between now() and now() + INTERVAL 7 DAY"); Cheers, ED.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.