Jump to content

All Activity

This stream auto-updates

  1. Past hour
  2. Hi.. Thanks for your reply... The to part of the script is login info with passwords, etc. I get this error...... [06-May-2024 15:31:52 America/New_York] PHP Warning: mysqli::query(): Couldn't fetch mysqli in /home/rgxb6tc5wk5q/public_html/golf/login/upload.php on line 68 [06-May-2024 15:31:52 America/New_York] PHP Warning: mysqli_query(): Couldn't fetch mysqli in /home/rgxb6tc5wk5q/public_html/golf/login/upload.php on line 73 [06-May-2024 15:31:52 America/New_York] PHP Warning: mysqli::query(): Couldn't fetch mysqli in /home/rgxb6tc5wk5q/public_html/golf/login/upload.php on line 76 I believe line 68 is the while... //code while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { if ($i > -1) { $import = "INSERT into users(id,lname,fname,email,password,indx,hdcp,red,phone,hide) values('$data[0]','$data[1]','$data[2]','$data[3]','".md5($data[4])."','$data[5]','$data[6]','$data[7]','$data[8]','$data[9]')"; $connect->query($import); //code Could this have something to do with the csv file?
  3. Today
  4. Hi All Currently i am using $_SERVER['DOCUMENT_ROOT'], Its working fine in localhost. But when i move to web its not taking actual files instead its accessing private_html folder. If my folder structure is like below assets includes module1 module1 sub folder 1 module1 sub folder 2 module1 sub folder 3 module2 module2 sub folder 1 module2 sub folder 2 module2 sub folder 3 What would be the best way to access the assets & includes folder files inside sub folders ?
  5. Are you tired of your 9-to-5 job? It might be you are looking for long-term flexibility and autonomy in your life! So, if you have decided to set yourself free from the confines of the office and want to embrace the freedom of remote work, welcome to the blog! Job markets nowadays are very dynamic, and increasingly a lot more people are opting for the gig economy as a means of sharpness and work satisfaction.
  6. I thought I submitted my code before I headed out to work, but apparently I never hit the submit button. Because it is really irrelevant at this point, I did not mean to submit but I guess I did. That being said, thank you all for some GREAT ADVICE. Thank you mac_gyver AND Psycho, you have given me multiple solutions. Much appreciated
  7. <form action="" method="post" name="election" id="election"> <? $db = mysqli_connect($db_hostname,$db_username,$db_password,"ptb_members") or die ("Cannot connect to MySQL"); $result = mysqli_query($db,"SELECT * FROM NewBoard"); while ($row = mysqli_fetch_array($result)) { extract($row); echo "<div class=\"flex-container\"> <div> <input type=\"checkbox\" name=\"vote\" value=\"$lname\"> - $fname $lname <br><hr><br> <div style=\"text-align:center\">$country</div> </div> <div> <img src=\"./images/$photo\" alt=\"$fname $lname\" style=\"width:100%;max-width:200px;\"> </div> <div class=\"valign\"> <a href=\"$url\">Personal Profile & Statement</a> </div> </div> <br>"; } ?> <div style="text-align:center;"> <br> <input type="submit" name="submit" value="Vote" class="formbutton"> </div> </form>
  8. while your current problem has been addressed above, you should not write out code for every possible data value. this is an error prone waste of your time typing. if you had 30 or a 100 of these, does it seem like it would be a good idea to sit at a computer creating 9, 30, or 100 sets of code that only differs in the value they use? you need to use a data driven design instead, where you have a data structure (array, database table) that defines the expected values. you would then loop over this defining data to produce the html makeup, validate the input data, and perform the processing, letting the computer do this repetitive work for you. because your database table already defines the choices, you should just query it to get the choices to use in the code. here are some other points for the posted code - you should actually be using ids for the submitted values, rather than the actual name. don't use or die() for error handling, ever. as of php8, the msyqli extension uses exceptions for errors and any existing conditional logic in your code testing for errors won't get executed upon an error since execution transfers elsewhere. so, remove any existing database statement error handling logic. the only time you should catch and handle database exceptions in your code are for duplicate or out of range user entered data. for this assignment, this is not user entered data, simply do nothing in your code for database error handling. you need to use a prepared query. don't put quotes around numbers. here's example code showing how to dynamically do this using a data driven design - // since i don't have your database, this example uses an array to define the choices // you would query the database table instead $choices = ['Juste','Chavez-Gris']; // examine the submitted data echo '<pre>'; print_r($_POST); echo '</pre>'; // post method form procesing if($_SERVER['REQUEST_METHOD'] == 'POST') { foreach($choices as $choice) { if(in_array($choice,$_POST['vote']??[])) { $sql = "UPDATE NewBoard SET votes=votes+1 WHERE lname = '$choice'"; mysqli_query($db,$sql); } } } // html document ?> <form method='post'> <?php foreach($choices as $choice) { // pre-check any existing choices $chk = in_array($choice,$_POST['vote']??[]) ? 'checked' : ''; ?> <label><input type="checkbox" name="vote[]" value="<?=$choice?>" <?=$chk?>> <?=$choice?></label><br> <?php } ?> <input type='submit'> </form>
  9. Yesterday
  10. As @dodgeitorelse3 asks, please show your form code. It is impossible for a single variable (e.g. $_POST['vote']) to have multiple values. I am assuming you have nine checkboxes all with the same name, but different values. That won't work. You need to either create them with different names OR create them as an array. Also, checkboxes are unique in that if they are not checked they are not included in the POST data, so you would want to check that they are set and not just check for the values. If you name each checkbox differently (the value would be unnecessary in this context) <input type="checkbox" name="Juste" value="1"> Juste <input type="checkbox" name="Chavez-Gris" value="1"> Chavez-Gris Then your processing code might look like this if (isset($_POST['Juste'])) { $result = mysqli_query($db,"UPDATE NewBoard SET votes=votes+'1' WHERE lname = 'Juste'")or die ("Fatal Query Error: " . mysqli_error($db)); } if (isset($_POST['Chavez-Gris'])) { $result = mysqli_query($db,"UPDATE NewBoard SET votes=votes+'1' WHERE lname = 'Chavez-Gris'")or die ("Fatal Query Error: " . mysqli_error($db)); } Or you could create your checkboxes as an array (this would be my approach) <input type="checkbox" name="votes[]" value="Juste"> Juste <input type="checkbox" name="votes[]" value="Chavez-Gris"> Chavez-Gris In which case the processing code might look like this //Set variable based on POST value or empty array if none selected $votesArray = isset($_POST['votes']) ? $_POST['votes'] : array(); //Check for each value in the $votesArray if (in_array('Juste', $votesArray)) { $result = mysqli_query($db,"UPDATE NewBoard SET votes=votes+'1' WHERE lname = 'Juste'")or die ("Fatal Query Error: " . mysqli_error($db)); } if (in_array('Chavez-Gris', $votesArray)) { $result = mysqli_query($db,"UPDATE NewBoard SET votes=votes+'1' WHERE lname = 'Chavez-Gris'")or die ("Fatal Query Error: " . mysqli_error($db)); }
  11. I have a form with several (9) checkboxes that are part of a association vote. The user can vote (select) up to 4 checkboxes of which the results (votes) are then recorded in database. The form is processed as: if ($_POST['vote'] == 'Juste'){ $result = mysqli_query($db,"UPDATE NewBoard SET votes=votes+'1' WHERE lname = 'Juste'")or die ("Fatal Query Error: " . mysqli_error($db)); } if ($_POST['vote'] == 'Chavez-Gris'){ $result = mysqli_query($db,"UPDATE NewBoard SET votes=votes+'1' WHERE lname = 'Chavez-Gris'")or die ("Fatal Query Error: " . mysqli_error($db)); } etc (for all 9 entries) My problem is that only the last checked box gets recorded. If I check both the checkboxes above (both if statements would be true), only the Chavez-Gris is recorded. Need all checked checkboxes recorded not just the last one. Any help and wisdom would be greatly appreciated. Thanx
  12. No, but you also didn't post the full code. Most likely culprit is going to be a change in the PHP configuration. Have you checked your server error logs yet?
  13. Dear Mr.Barand, Thanks for your suggestion. I found the mistake in line number 21376 column M, the value entered with \ (Bend DN125 5 1/2" 32,5° S2000\). Because of that the data is not imported. I removed that special character and imported the data. How to avoid such type of mistakes in features
  14. At the end of March godaddy moved our site. I am now running php 5.6 on lynix. Just noticed yesterday that no data is being uploaded to the site since the end of March which is around when it was moved. Is there anything in the following code that isn't compatible with 5.6 and needs changed? I wrote this code 5 or 6 years ago and am not well versed in php. It has been runing fine until the end of March. Thanks for any help. //code // Create connection date_default_timezone_set("America/New_York"); $connect = new mysqli($servername, $username, $password, $dbname); if ($_FILES['csv']['size'] > 0) { //get the csv file mysqli_query($connect,'TRUNCATE TABLE users'); $file = $_FILES['csv']['tmp_name']; $handle = fopen($file, "r"); $i = 0; while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { if ($i > -1) { $import = "INSERT into users(id,lname,fname,email,password,indx,hdcp,red,phone,hide) values('$data[0]','$data[1]','$data[2]','$data[3]','".md5($data[4])."','$data[5]','$data[6]','$data[7]','$data[8]','$data[9]')"; $connect->query($import); } $i++; } mysqli_query($connect,'TRUNCATE TABLE control'); $date = date( "Y-m-d" ); $import="INSERT INTO control (tdate) VALUES('$date')"; $connect->query($import); fclose($handle); print "<p>File uploaded successfully!"; } } ?> </font> </center> </BODY> </HTML> //endcode
  15. I think you will find that line no 21374 in the "spare" csv has only 73 values instead of the expected 75.
  16. if the 'view details' link isn't working, there's something wrong with the 'product_url' value. what does the view source of the markup for that link show? you should be using a post method form for the add to cart operation, using a hidden field with the product id in it.
  17. / getP function Starts // function getp(){ global $db; $get_products = "select * from products order by 1 DESC LIMIT 0,8"; $run_products = mysqli_query($db,$get_products); while($row_products=mysqli_fetch_array($run_products)){ $pro_id = $row_products['product_id']; $pro_title = $row_products['product_title']; $pro_price = $row_products['product_price']; $pro_img1 = $row_products['product_img1']; $pro_label = $row_products['product_label']; $manufacturer_id = $row_products['manufacturer_id']; $get_manufacturer = "select * from manufacturers where manufacturer_id='$manufacturer_id'"; $run_manufacturer = mysqli_query($db,$get_manufacturer); $row_manufacturer = mysqli_fetch_array($run_manufacturer); $manufacturer_name = $row_manufacturer['manufacturer_title']; $pro_psp_price = $row_products['product_psp_price']; $pro_url = $row_products['product_url']; if($pro_label == "Sale" or $pro_label == "Gift"){ $product_price = "<del> &#8377; $pro_price </del>"; $product_psp_price = "| &#8377; $pro_psp_price"; } else{ $product_psp_price = ""; $product_price = "&#8377; $pro_price"; } if($pro_label == ""){ } else{ $product_label = " <a class='label sale' href='#' style='color:black;'> <div class='thelabel'>$pro_label</div> <div class='label-background'> </div> </a> "; } echo " <div class='col-md-4 col-sm-6 single' > <div class='product' > <a href='$pro_url' > <img src='admin_area/product_images/$pro_img1' class='img-responsive' > </a> <div class='text' > <center> <p class='btn btn-primary'> $manufacturer_name </p> </center> <hr> <h3><a href='$pro_url' >$pro_title</a></h3> <p class='price' > $product_price $product_psp_price </p> <p class='buttons' > <a href='$pro_url' class='btn btn-default' >View details</a> <a href='details.php?action=$pro_url' class='btn btn-primary'> <i class='fa fa-shopping-cart'></i> Add to cart </a> </p> </div> $product_label </div> </div> "; } } // getPro function Ends // ?> <?php getP();?> </div> <!--Container Main end-->
  18. Dear Team, I have PHP code which is used to upload the data from CSV files to the database. My code is <?php // Load the database configuration file define("HOST", 'localhost'); define("USERNAME", 'root'); define("PASSWORD", '123456'); define("DATABASE", 'sbms'); // default database name function pdoConnect($dbname = DATABASE) { $db = new PDO("mysql:host=" . HOST . ";dbname=$dbname;charset=utf8", USERNAME, PASSWORD); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC); $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); return $db; } $pdo = pdoConnect(); if (isset($_POST['importsubmit'])) { $file = $_FILES['file']['tmp_name']; $fp = fopen($file, 'r'); $req_cols = [ 0 => 'sales_doc_type', 2 => 'billing_date', 11 => 'material', 12 => 'description', 14 => 'billed_quantity', 25 => 'gross_amount', 38 => 'sold_party', 39 => 'customername', 45 => 'sales_office', 46 => 'plant', 63 => 'dchannel', 64 => 'distribution_channel_description', 73 => 'division', 74 => 'division_header' ]; $import_data = []; fgetcsv($fp); // discard the header row while ($allrow = fgetcsv($fp)) { $row = array_intersect_key($allrow, $req_cols); if (empty($row[0])) continue; // skip rows where no value in first col $randdays = rand(5, 30); $row[2] = date('Y-m-d', strtotime($row[2])); $row[25] = str_replace(',', '', $row[25]); $row[39] = str_replace("'", "", $row[39]); $row[12] = str_replace("'", "", $row[12]); $import_data[] = vsprintf("('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s')", $row); } fclose($fp); $chunks = array_chunk($import_data, 3000); foreach ($chunks as $ch) { $sql = "INSERT IGNORE INTO billing (sales_doc_type, billing_date, material, description, billed_quantity,gross_amount, sold_party, customername, sales_office, plant, dchannel, distribution_channel_description, division, division_header) VALUES " . join(',', $ch); $pdo->exec($sql); } } // Redirect to the listing page header("Location: Billing.php"); ?> I am using two CSV files (April Service.csv and APRIL SPARE.csv). When I am importing April Service.csv, it is updating properly. But when I am importing APRIL SPARE.csv file I get the following error Fatal error: Uncaught ValueError: The arguments array must contain 14 items, 12 given in C:\Users\senthilkumar.rp\OneDrive - SCHWING Stetter (India) Private Limited\SBMS\sbms\sbms\SuperAdmin\Sales_Import.php:55 Stack trace: #0 C:\Users\senthilkumar.rp\OneDrive - SCHWING Stetter (India) Private Limited\SBMS\sbms\sbms\SuperAdmin\Sales_Import.php(55): vsprintf() #1 {main} thrown in C:\Users\senthilkumar.rp\OneDrive - SCHWING Stetter (India) Private Limited\SBMS\sbms\sbms\SuperAdmin\Sales_Import.php on line 55 I uploaded the CSV files and table here for your reference on the below link. https://drive.google.com/drive/folders/1UIVW6Ya5D2shwwvxEK6WiyBYSVCdNTtX?usp=sharing I think there is some mistake on the csv file. I am not able to identify that problem. Can any one help me solve this problem.
  19. Last week
  20. i/we don't understand abbreviations like tpu, pu, n, n 2, r, r 2 that would give meaning to the posted information. can you provide some context, in English, for the two examples you have posted? are these different categories of items? ultimately, your task boils down to database normalization. you can search on the web to find out what this means. to start with, you need an item table that holds the unique information about the items, one row per item. at a minimum, this table would have columns for - id (autoincrement primary index), and name. this will establish the item ids that will get used when storing data related to the items. if these various wookbooks are for different categories of items, you also need a category table that holds the unique information about the categories, one row per category. at a minimum, this table would have columns for - id (autoincrement primary index), and name. this will establish the category ids that will get used when storing data related to the categories. if this is the case, the above item table would also have a category_id column that will hold the corresponding category id for each item. since i/we don't know if pricing is per category, per item, or per list of items. i.e. what the extent and scope of the data is, i cannot offer any specific suggestions beyond the above.
  21. Hello everyone, at the beginning - I'M LEARNING - maybe I'll ask questions wrong - so I'm asking for your understanding. I need to create a price list - or, in fact, several price lists in one application based on the sheet provided by the boss. It looks something like this: one sheet, several dozen workbooks, various table formats. Could someone guide me on how to design the base to achieve a similar effect?
  22. Hi, attaching all the files, please check <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Countdown Timer</title> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous"> <link rel="preconnect" href="https://fonts.googleapis.com"> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400&display=swap" rel="stylesheet"> <link href="/style.css" rel="stylesheet"> </head> <body> <div class="container my-5"> <h1>Countdown Timer</h1> <br> <br> <h4 class="text-success">Contest Ends on 31st May 2024 GMT at 11:59:59 PM</h4> <br> <p>Time Now in GMT :</p> <p class="text-success" id="nowtimeutc"></p> <br> <p>Contest Ends on (your date)</p> <br> <div id="yourdate"></div> <br> <div class="text-danger fs-1" id="expired"></div> <br> <p>Time left, the contest ends in</p> <br> <!-- <h2 class="text-danger fs-1" id="countdown"></h2> --> <br> <div class="container text-center"> <div class="row"> <div class="col"> <div class="fs-1" id="daysleft"></div>days </div> <div class="col"> <div class="fs-1" id="hoursleft"></div>hours </div> <div class="col"> <div class="fs-1" id="minutesleft"></div>minutes </div> <div class="col"> <div class="fs-1" id="secondsleft"></div>seconds </div> </div> </div> </div> <script src="/script2.js"></script> </body> </html> let endingDate = new Date(Date.UTC(2024, 4, 31, 23,59,59)); // Enter the date in UTC console.log(endingDate); let yourDate = document.getElementById("yourdate"); // Get te date in your time zone yourDate.textContent = endingDate; let now = new Date(); // time now console.log(now); let difference = endingDate.getTime() - now.getTime(); // Difference between target time and time now, in milliseconds console.log(difference); // Time now in UTC timeNow = new Date().toUTCString(); //timeNow = Math.floor((new Date()).getTime() / 1000); let nowTime = document.getElementById("nowtimeutc"); nowTime.textContent = timeNow; // Main function function displayCountdown(){ // input area start let endingDate = new Date(Date.UTC(2024, 4, 31, 23,59,59)); // Enter the date in UTC console.log(endingDate); let yourDate = document.getElementById("yourdate"); // Get te date in your time zone yourDate.textContent = endingDate; let now = new Date(); // time now console.log(now); let difference = endingDate.getTime() - now.getTime(); // Difference between target time and time now, in milliseconds console.log(difference); // input area ends let days = Math.floor(difference / 86400000); // divide Difference in milliseconds by no. of millisecond in a day to get days left console.log(days); let hours = Math.floor((difference % 86400000) / (1000 * 60 * 60)); // To get hours use modulus, get the time remaining after "days" and find how many hours in it console.log(hours); let minutes = Math.floor(((difference % 86400000) % (1000 * 60 * 60)) / (1000 * 60)); // finding minutes left - in effect hours - minutes in milliseconds console.log(minutes); let seconds = Math.floor((((difference % 86400000) % (1000 * 60 * 60)) % (1000 * 60)) / 1000); console.log(seconds); //let displayCount = `${days} days ${hours} hours ${minutes} minutes ${seconds} seconds`; //document.getElementById("countdown").innerHTML = displayCount; //setTimeout(displayCountdown, 1000); // Refreshes every 1 seconds //console.log("refreshed"); //Handling values individually // days const element = document.getElementById("daysleft"); element.textContent = days; document.getElementById("daysleft").innerHTML = myDays; setTimeout(myDays, 1000); // Refreshes every 1 seconds const element2 = document.getElementById("hoursleft"); element2.textContent = hours; document.getElementById("hoursleft").innerHTML = myHours; setTimeout(myHours, 1000); // Refreshes every 1 seconds const element3 = document.getElementById("minutesleft"); element3.textContent = minutes; document.getElementById("minutesleft").innerHTML = myMinutes; setTimeout(myMinutes, 1000); // Refreshes every 1 seconds const element4 = document.getElementById("secondsleft"); element4.textContent = seconds; document.getElementById("secondsleft").innerHTML = mySeconds; setTimeout(mySeconds, 1000); // Refreshes every 1 seconds }; // check if the time difference is valid if (difference <= 0) { console.log("Contest Finished, time expired"); let expiredContest = "Contest Finished, entry time expired"; document.getElementById("expired").innerHTML = expiredContest; } else { //setTimeout(displayCountdown, 500); // Call updateCountdown again every second } // setInterval(displayCountdown, 100); // Refreshes every 5 seconds // To stop the automatic execution: //clearInterval(intervalId); //setTimeout(displayCountdown, 1000); // Refreshes every 1 seconds displayCountdown(); console.log("printed"); }; //displayCountdown();
  23. How do you "call" them? What's the rest of the code? Is script.js meant to directly manipulate index.html or is it a utility thing and index.html has its own Javascript code? Is your question about how to get those values into index.html or is it how to get those values into the HTML itself?
  24. Hi, this is a beginner-level question. Please don't mind I have an index.html and script.js. I have included script.js in index.html. I am building a countdown timer. The script.js has values like const days = Math.floor(timeDifference / (1000 * 60 * 60 * 24)); const hours = Math.floor((timeDifference % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); const minutes = Math.floor((timeDifference % (1000 * 60 * 60)) / (1000 * 60)); const seconds = Math.floor((timeDifference % (1000 * 60)) / 1000); How do I call days, hours, minutes etc to the index.html separately so that I can style the countdown timer? Say <div class="red">days</div> <div class="green">hours</div> ... etc Thanks
  25. nope. the t2 alias name is for the - JOIN user_pokemon t2 table, because that's what the code you posted is getting the original $user data elements from. we only see the information you supply and the answers cannot be any better than the posted information. the only query for the trade table in your original posted code is for the trade 'for' data.
  26. ive edited my post $sql = "SELECT t1.oid, t1.offer_from, t2.name, t2.type, t2.level, t2.exp, t2.move1, t2.move2, t2.move3, t2.move4, t3.id FROM trade_offers t1 JOIN user_pokemon t2 ON t1.pokemon_id = t2.id JOIN pokemon t3 ON t2.name = t3.name WHERE t1.offer_on = ? ORDER BY t1.oid DESC LIMIT ?,?"; it looks like your trying to grab the level exp and moves from the offer table when these are stored in the trade table
  27. the sql query error is because the LIMIT x,y values must be numeric. they are strings in your case because you are using emulated prepared queries and are suppling an array of values to the ->execute([...]) call. you need to use true prepared queries, which properly carries the datatype through to the database server when suppling the values to the ->execute([...]) call. when you make the database connection, you need to - set the character set to match your database tables (so that no character conversion occurs over the connection and in the case of emulated prepared queries, so that php can properly escape string data so that any sql special characters in a value cannot break the sql query syntax.) set the error mode to exceptions (this is the default setting now in php8+, but it doesn't hurt to set it.) set the emulated prepared query setting to false (you want to run true/real prepared queries.) set the default fetch mode to assoc (so that you don't need to specify the fetch mode in each fetch statement.)
  1. Load more activity
×
×
  • 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.