Jump to content

jodunno

Members
  • Posts

    262
  • Joined

  • Last visited

  • Days Won

    4

Everything posted by jodunno

  1. I have one thousand one hundred species documented (photos, genitalia, confirmation from experts, data and measurements). Building my site prevents me from working on nature. Anyway, i don't use a database for retrieving species. I use alphabetic functions which return arrays to load each rank. I don't have actual php files per species. I use one file to load all species based upon the flat file functions. I avoid using a database for every little aspect of the site to avoid locking and overruse. My alphabetic/targeted approach is working faster than a db. I use the db to verify that you are a logged in user and match your db session id with your session id instead. In order to use a search, i'll have to build a search table. I actually narrow the alphabetic approach to the first three letters of the target. So Aves will be found in function file A under function Ave. Lightning fast retrieval and better than a db. Best wishes.
  2. Hi Barand, I don't think it is exaggeration since we are talking about internet usage. People/website users think a second too long is a second too long. I was just confused because my queries were working fast on xampp. Anyway, i've removed this code and started over. the taxonomy table is very small for search testing. I now only have Cyanistes caeruleus in the table. I've started over. I will build a bigger table for experimentation and send it to you. Meantime, my website started out as static html/css. I decided to take it to the server side using php. I started studying php two years ago in my spare time. I have acquired alot of knowledge since then but i am still a novice. I just don't know how certain tasks are accomplished in this industry. Anyway, i have a species list for each major class. I use it on my publicly non-logged in pages for prospective members to see which species i have documented. I can also send a copy of these lists to you. I mean, if there is any significance in doing so. Otherwise, please allow me to build a bigger table. I will send the code and also a dump of the database for you. You would probably shriek if you saw my entire website code. LOL I use my own router based upon post methods. I do alot of things that coders hate. For example, i use the session to store image names for loading on a page so that images cannot be viewed unless the variable is set. You'd probably lay an egg looking at that code alone. I also keep my taxonomical navigator private with prg posts instead of uris with get requests. You'd probably faint if you saw it. So i will stick to the relevant code for critique. I will build my table tommorrow. I am very tired today and i will go to bed soon. Thank you for guiding me in the right direction. As a wanna-be coder, it is very nice to have a master coder offer advice and guidance. Really, i appreciate every word that you type to me. Best wishes. Stay healthy and happy.
  3. Hi Barand, your opinion is trusted, naturally, i just wonder what you mean by finish by breakfast since my results are instantaneous on xampp. I assume that you mean lots of users? anyway, i heed your advice and remove the current code. I have started over with full text and match against, like so: CREATE TABLE taxonomy (id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, title VARCHAR(128), link VARCHAR(128), keywords TEXT, FULLTEXT (keywords)) ENGINE=InnoDB; INSERT INTO taxonomy SET title = 'Cyanistes caeruleus', link = 'path/to/sp', keywords = CONCAT ('Cyanistes caeruleus blau meise meisen blaumeise blaumeisen blue tit tits bluetits bluechickadees chickadee chickadees',' ',soundex('Cyanistes'),' ',soundex('caeruleus'),' ',soundex('blau'),' ',soundex('meise'),' ',soundex('meisen'),' ',soundex('blaumeise'),' ',soundex('blaumeisen'),' ',soundex('blue'),' ',soundex('tit'),' ',soundex('tits'),' ',soundex('bluetits'),' ',soundex('bluechickadees'),' ',soundex('chickadee'),' ',soundex('chickadees')); $keyword = (string) $_POST['suchworte']; $skeyword = (string) soundex($_POST['suchworte']); $searchQuery = 'SELECT title, link FROM taxonomy WHERE match(keywords) against(:keyword) or match(keywords) against(:skeyword)'; it is working but i have to add all of the keywords and soundex values. is this method better? ps: i romanize German, id est, u with umlaut is ue. Thus, soundex is working just fine for me. I really have no complaints. I suppose that they mean non romanized languages? Best wishes.
  4. Hello again, I've had an exhausting, stressful week but i managed to tinker with my simple name search feature. For some reason, MATCH AGAINST full-text searches failed me. So i redesigned my table with id, title, link, keywords. keywords is varchar(255), which contains a small list of names for a species in plural form as one word (no spaces). I also discovered the soundex() method of searching for misspelled word matches. I combined like and soundex to get the results that i was seeking. so as an example of my current test code: $title = (string) '%' . $_POST['search'] . '%'; $keyword = (string) '%' . str_replace(' ', '', $_POST['search']) . '%'; $stitle = $skeyword = (string) '%' . soundex($_POST['search']) . '%'; $Query = 'SELECT title, link FROM taxonomy WHERE title LIKE :title or title LIKE :stitle or keywords LIKE :keyword or keywords LIKE :skeyword'; and an example of my table data: title: Parus major link: path/to/Parus/major keywords: Parus major Kohlmeisen Coaltits soundex('Parus') soundex('major') soundex('Kohlmeisen') soundex('Coaltits') soundex('Kohl') soundex('meisen') soundex('coal') now i wonder if this is too complicated and searches will slow down my website? i just want to add a very basic/primitive/simple search feature. i really don't like java and i am not interested in using the free java based search engines like Lucene, Solr etc. besides, i am not indexing pages. I all ready maintain a manually edited.controlled species list. i just want the species list to be searchable. is this new code okay? any suggestions? any criticism? call me a stupid loser for all i care, just please explain why this method is bad/negative and how could i make it better? so far it is working well for me. I can type meisen and all entries appear. I can also type maisen and get the same results via soundex. I like it but i am nescient about this subject. Thank you.
  5. Hi requinix, I'm actually happy that I can offer a basic search for taxonomy using a database. I am not an advanced programmer yet so building an indexer is not my goal. I simply desire a list of all of the species that i have photographed and identified via genitalia. I currently have over 1,100 species. Thus, i think that a simple keyword list with a link is good. I don't understand why you object to using a database for such a simple search other than because of memory consumption(?). I use Latin (scientific nomenclature), English and German languages. My reason for posting is because plural searches yield no results. Other than that, i am happy that i am getting results at all. I entered a few examples into a table for testing: Turdus merula link/to/file, Turdus philomelos link/to/file, Blaumeise link/to/file, Kohlmeise link/to/file etc. typing turdus brings up both merula and philomelos which is good. typing meise brings up both Blaumeise and Kohlmeise. However, typing meisen yields my no results catch (if empty($results))). I just wanted to be able to support plural forms. I'm definitely interested in learning how to build a search engine and also in becoming an advanced coder. Such desires could become a reality one day but definitely not anytime so soon. Best wishes, requinix. Hi Barand, That is great! Thank you for adding this data. I will recode my simple search query and enjoy the new results. I was wondering if building a separate database for searches is a good idea or not. I say this because i think that i could make searching faster by adding a table for all letters of the alphabet. Then, take first letter of search term and narrow the field to a single table. Like a dictionary with lettered thumb indexes. Go right to the relevant letter and spare the database resource consumption. yes? no? just an idea. I have to go now. Best wishes to all!
  6. Hello everyone, I am wondering if anyone can offer tips for dealing with plural forms of words in searches? l was wondering if boolean mode is simply the answer or if i should implement a keywords column which contains a list of keywords including plurals to be searched with like? I simply wish to find the database entry (which is in singular form) when a user searches for a plural form (user searches for meisen but title column houses meise). Best wishes
  7. Dear Barand, Brilliant! Thank you for the design model and the user id tip to avoid display name issues. I will work on a test mail system and see how it goes as a rough draft. I think that maybe i should call this messaging system notes instead of mail to avoid confusion with real email systems. Private Notes with individual/self, friends or group settings. File upload is easy enough (although security is complicate and delicate.) I will also implement soft deletions and copyright infringement blocks. File uploading will have to deal with all of the legal issues that accompany the process for sure. I will start working on this design sometime today. I'm currently adjusting my bookmark system because i use a one hit history for taxonomical browsing. bookmarks overwrite the history and i want to avoid this overwriting. Thus, i am setting a variable to detect that a bookmark was used to access the rank which in turn avoids rewriting history. I guess a good name for it is paradox variable. if paradox then do not log history. The onetime history is to make it easy to return to your last view in the taxonomical browser. Anyway, I will adjust this bookmark problem, then start working on the Note system. Thank you and Best wishes. ps you are so Brilliant with databases. You make it seem so simple.
  8. Hello to all, I have an idea for my website but i am hoping to have some design tips from experienced members. I am not a programmer or a database designer. I am not asking for code as i am capable of coding with pseudocode guides. I am not sure how to properly implement my ideas. here is my idea and necessary site data: i have a member application for taxonomy (nature, meaning that i identify animals by keys or dissection and i am providing my own biological research material for all of the ranks that i have documented to date.) I ask for application login name and password, then a separate display name (i don't want your login name used anywhere on my site. it is only for application access.) The screen name can be changed (poses a problem with my idea, so i need a solution for handling the problem, which i will mention below). I want to add a mail box which is not public like an email provider. This is more like a private messaging system. I will call it post and your messages will be displayed as sticky notes with titles that are clickable to the full message/note. The only way to use this private mail system is to manually add display names that you trust to a friend list. Once a friend is added by screen name, then you can accept and send messages to this person. Some messages can be notes for your own viewing (not available to friends, thus i suppose a db column flag is appropriate, such as column named privatenote- = yes/no, 1/0 etc). then i would like to add a "group" feature where the messages are visible in a group page/tab. The site is private but these notes are visible to all in the group like a public gathering/meeting. then i would like to allow file uploads for sharing data. For example, a scientist may join my site and offer a research paper for download to anyone in his/her friend list. a problem with adding friends to a list is that i use the display name which can be changed. so i need to be able to update all friend lists if a member changes his/her display name. so i am wondering how to design such a database or do i just make tables in my current members database which also holds a bookmarks table. anyone willing to offer advice for such a feature? Best wishes.
  9. Hi gizmola, I typically do not understand certain mysqli code and i usually ignore it. I am happy with pdo and pdo is usually suggested by experts, like you, anyway. Meantime, i should also explain my code and repost it. You may notice a break(2) and wonder why it exists, for example. My code acually contains a switch based upon a form post. I keep all of my bookmark db code in one file (bookmarksdb). I have a page to display all bookmarks (case 'select'), a page method to add a bookmark on bookmarkable pages (case 'insert') and a page to delete bookmarks from your bookmarks list (case 'delete'). I also use a counter case which simply returns the count ($result['total']). The counter (case 'count') is used as a small circle that holds the count of bookmarks to be displayed at the top right div of the bookmarks page icon. I use it like a phone apps new messages bubble beside app icons. Thus, the icon count bubble will inform you how many bookmarks you have to avoid a need to view the bookmarks page just for this info. <?php declare (strict_types = 1); $dbhost = '127.0.0.1'; $dbname = 'test'; $dbuser = 'root'; $dbpass = ''; $dbattr = array(PDO::ATTR_EMULATE_PREPARES => false,PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC); try { $connection = new PDO("mysql:host=$dbhost; dbname=$dbname; charset=utf8mb4", $dbuser, $dbpass, $dbattr); } catch (PDOException $e) { error_log($e->getMessage()); } $query = 'SELECT count(*) as total FROM bookmarks WHERE uid = :uid'; $stmt = $connection->prepare($query); $stmt->execute(array(':uid' => $uid)); $result = $stmt->fetch(); switch ($action) { //$action is known by session array key which holds the csrf token of the form field posted case 'delete': //code to delete a bookmark, which relies upon !empty($result['total']) break; case 'insert': if ($result['total'] < 100) { $query = 'SELECT link FROM bookmarks WHERE uid = :uid'; $stmt = $connection->prepare($query); $stmt->execute(array(':uid' => $uid)); while ($column = $stmt->fetch()) { if ($column['link'] === $link) { $duplicate = true; break(2); } } $query = 'INSERT into bookmarks (uid, type, link, icon, label, date) VALUES (:uid, :type, :link, :icon, :label, NOW())'; $stmt = $connection->prepare($query); $stmt->execute(array(':uid' => $uid, et cetera...)); } break; } I still don't know how to handle errors from the other queries. I don't want my site to break and a white page to be shown with error data. I prefer that my site remain visible and i display the error and not the software. I have no idea how to do this yet. anyway, Thank you for the info in this thread. I appreciate everyone taking time to help me. Like i said before, i am not delusional about my status here. I am not a programmer at all. I am street smart for sure and able to code despite no education in this field. I sometimes do things correctly and many times just get something to work. No matter what, i always appreciate professionals offering inside advice. I sometimes wish hackers would dump source code to big tech company websites so i can truly learn how the pros do it. I enjoy coding when i can do it correctly but i lack so much info about this industry. I often have to employ street smarts to bring a concept to life. I have no programming friends so i never receive inside intel about 'how the pros code common ideas'. ok, too much babbling and i far too much work to do today. Off i go... Best wishes.
  10. Hello gizmola and benanamen, Thank you for the informative replies. I did not know that one can "enforce uniqueness on a user/link basis". I am nescient about sql. I will have to drop my table and rebuild it now. I don't mind an extra query if there is no other way but clearly you know of a better way. I will drop the table and add the new unique constraint. Thank you for this valuable info!!! I should've expressed my desires clearly. My apologies for any vagueness in this thread. Your assumptions are correct about unique links per user. I just want to allow bookmarks but not duplicate entries for each user. I am excited to learn how to do this properly. I doff my hat to you! Thank you. I use pdo. I just started studying php two years ago in my spare time. I never learned mysqli. I made my first login script two years ago using pdo. Thus, i only know pdo. my code is slightly different than the following but only by variable names. I clean it up for posting here because some people just insist on doing things their way. such as, naming db variable $conn, $stmt etc. I use my own names. <?php declare (strict_types = 1); $dbhost = '127.0.0.1'; $dbname = 'test'; $dbuser = 'root'; $dbpass = ''; $dbattr = array(PDO::ATTR_EMULATE_PREPARES => false,PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC); try { $connection = new PDO("mysql:host=$dbhost; dbname=$dbname; charset=utf8mb4", $dbuser, $dbpass, $dbattr); } catch (PDOException $e) { error_log($e->getMessage()); } $query = 'SELECT count(*) as total FROM bookmarks WHERE uid = :uid'; $stmt = $connection->prepare($query); $stmt->execute(array(':uid' => $uid)); $result = $stmt->fetch(); $Total = $result['total']; if ($Total < 100) { $query = 'SELECT link FROM bookmarks WHERE uid = :uid'; $stmt = $connection->prepare($query); $stmt->execute(array(':uid' => $uid)); while ($column = $stmt->fetch()) { if ($column['bm_path'] === $bmPath) { $duplicate = true; break(2); } } $query = 'INSERT into bookmarks (uid, type, link, icon, label, date) VALUES (:uid, :type, :link, :icon, :label, NOW())'; $stmt = $connection->prepare($query); $stmt->execute(array(':uid' => $uid, et cetera...)); } I wonder if you have any suggestions about making my code better. Please remember that i can now remove the SELECT link query because you showed me how to enforce a unique link per user. Honestly, i am very happy about this info. Best wishes.
  11. Hello again, I've finally added my bookmarking system and it is working! However, the unique key constraint had to be removed because it is applied to the single table. The unique constraint could only work with a table for each user. I had to add a pre-insert query to check for a duplicate entry (a loop with if column = attempted link). Other than the unique constraint error, al is good. Thanks again! edit: what i mean by unique constraint is that my site crashed with a duplicate entry error (1062) when i added the same link from a different account. I failed to realize too that the unique constraint will allow the link to be entered for only one user in the table. Best wishes.
  12. advice allready given. read entire thread b4 trolling.
  13. use css but don't ask me why the techies name it text-align instead of content-align or something more inclusive. <style>.image { text-align: center; }</style> <div class="image"> <img src="logo.jpg" alt="John Doe"/> </div>
  14. so this is not correctly formed. I wish i knew how to describe the variables accurately but i do not know how to do so. let's try it this way and see if it makes sense: you need to define a way to connect to the database using pdo. thus $bdd = new PDO (); you can name this variable whatever you want to name it. $80s_rocker_still_rockin_but_missing_me_long_hair = new PDO(). get it? then you need a query, which can be called whatever you want it to be called. such as $qry, $query, $scorpions_bad_boys_running_wild. who cares about the name. The concept is important here: $jodunno_nuthin = 'SELECT * FROM convoy_part WHERE user_convoy= :I"; you are actually going to 'prepare' this query for execution. then you use another variable named anything that you want to represent the database actions being performed. $s2, $start, $kix_blow_my_fuse or whatever. $gnr_nighttrain = new PDO("bla blah", more-blah , blah); $jodunno_nuthin = 'SELECT * FROM convoy_part WHERE user_convoy= :I"; $load_the_cannons = $gnr_nighttrain->prepare($jodunno_nuthin); $load_the_cannons->execute(array(':I' => $_GET['id'])); $db_is_shooting_back = $load_the_cannons->fetch(); put it all together in one sensical operation. so let's light the cannons and fire: $query = "SELECT * FROM convoy_part WHERE user_convoy= :I'; $start = $bdd->prepare($query); $start->execute(array(':I' => $_GET['id'])); then perform your fetch. think of a dog chasin' a stick: fetch boy! $result = $start->fetch(); naming variables really doesn't matter when you are practicing code. understanding variables is 'sehr wichtig'. keep it all sensical, logical and easy to understand when you look at the code 5 years from now. The idea is to understand what $bdd represents and what $query represents, etc. you are often times getting lost and mixing variable names as if you don't understand what is happening. stay focused! Best wishes.
  15. oh, yay! i am happy for you! good work! Thank you for putting forth the effort. Best wishes.
  16. hello, i really have no time to code it for you. i need to mention that my last post needs to be adjusted by you. the query needs to be changed from columns to all if you wish to fill the variables correctly. so $query = 'SELECT convoy_name, convoy_organizer FROM convoys where id = :getId'; needs to be $query = 'SELECT * FROM convoys where id = :getId'; you take things to literally and i have no time to be perfect. i need to go for now.
  17. we also have to deal with the missing code because php will not function correctly when it comes across an undefined variable or many undefined variables. I mentioned $convoy_kilometer not being set in an earlier post but today i see the code. I didn't see that code yesterday, so my apologies for missing this code. now that you have the data from the database, you need to integrate it into your code. You will use only this working code to retrieve the data. So your old attempts must not be included in the file anymore. replace your content with the working code then slowly rebuild the page to work with this code. a few working changes means you can speed up the process and finish the page. so if the code works, then start your new document like so: <?php session_start(); if (!isset($_SESSION['username'])) { die('<meta http-equiv="refresh" content="1; URL=">'); } ?> <!DOCTYPE html> <html> <head> <title></title> <meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="description" content=""> <meta name="viewport" content="width=device-width, initial-scale=1"><meta name="robots" content="all,follow"> <link rel="stylesheet" href="vendor/bootstrap/css/bootstrap.min.css"> <link rel="stylesheet" href="vendor/font-awesome/css/font-awesome.min.css"><link rel="stylesheet" href="css/font.css"> <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Muli:300,400,700"> <link rel="stylesheet" href="css/style.default.css" id="theme-stylesheet"> <link rel="stylesheet" href="css/custom.css"><link rel="shortcut icon" href="img/favicon.ico"> </head> <body> <?php require('connection/db1.php'); //db1.php should contain your db connection material. i've included it here to remind you that it is needed for db connection //remove this code if you have it set in db1.php. notice that we set PDO::FETCH_ASSOC so you don't need to do this in the fetch statement //start of removable code if it exists in db1.php $your_db_username = 'root'; $your_db_password = ''; $attributes = array( PDO::ATTR_EMULATE_PREPARES => false, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC ); //end of removable code if it exists in db1.php $connection = new PDO("mysql:host=$host; dbname=$yourdbnamevar; charset=utf8mb4", $your_db_username, $your_db_password, $attributes); $query = 'SELECT convoy_name, convoy_organizer FROM convoys where id = :getId'; $start = $connection->prepare($query); $start->execute(array(':getId' => $_GET['id'])); //are you sure that $_GET['id'] is set and not empty/contains valid data? //$count = $start->rowCount(); //i think that count should still work correctly but i've commented it out to avoid problems. $result = $start->fetch(); foreach ($result as $results) { $convoy_veranstalter = $result['convoy_veranstalter']; $convoy_server = $result['convoy_server']; $convoy_date = $result['convoy_date']; $convoy_adddate = $result['convoy_adddate']; $convoy_language = $result['convoy_language']; $convoy_participants = $result['convoy_participants']; $convoy_route = $result['convoy_route']; $convoy_description = $result['convoy_description']; $convoy_kilometer = $result['convoy_kilometer']; $convoy_web_social = $result['convoy_web_social']; } ?> <?php include 'includes/inc.navbar.php';?> <!-- Sidebar Navigation end--> <div class="page-content"> <div class="page-header"> <div class="container-fluid"> <h2 class="h5 no-margin-bottom">Dashboard</h2> </div> </div> <section class="no-padding-top no-padding-bottom"> <div class="container-fluid"> <div class="row"> <div class="col-md-3 col-sm-6"> <div class="statistic-block block"> <div class="progress-details d-flex align-items-end justify-content-between"> <div class="title"> <div class="icon"><i class="icon-user-1"></i></div><strong>Veranstalter:</strong> </div> <div class="dashtext-3"><?php if (isset($convoy_veranstalter)) { echo $convoy_veranstalter; } ?></div> </div> <div class="progress progress-template"> <div role="progressbar" style="width: 100%" aria-valuenow="30" aria-valuemin="0" aria-valuemax="100" class="progress-bar progress-bar-template dashbg-3"></div> </div> </div> </div> <div class="col-md-3 col-sm-6"> <div class="statistic-block block"> <div class="progress-details d-flex align-items-end justify-content-between"> <div class="title"> <div class="icon"><i class="icon-contract"></i></div><strong>Teilnehmer:</strong> </div> <div class="dashtext-3"><?php if (isset($count)) { echo $count; } ?></div> </div> <div class="progress progress-template"> <div role="progressbar" style="width: 100%" aria-valuenow="70" aria-valuemin="0" aria-valuemax="100" class="progress-bar progress-bar-template dashbg-3"></div> </div> </div> </div> <div class="col-md-3 col-sm-6"> <div class="statistic-block block"> <div class="progress-details d-flex align-items-end justify-content-between"> <div class="title"> <div class="icon"><i class="icon-paper-and-pencil"></i></div><strong>Kilometer</strong> </div> <div class="dashtext-3"><?php if (isset($convoy_kilometer)) { echo $convoy_kilometer; } ?></div> </div> <div class="progress progress-template"> <div role="progressbar" style="width: 100%" aria-valuenow="55" aria-valuemin="0" aria-valuemax="100" class="progress-bar progress-bar-template dashbg-3"></div> </div> </div> </div> <div class="col-md-3 col-sm-6"> <div class="statistic-block block"> <div class="progress-details d-flex align-items-end justify-content-between"> <div class="title"> <div class="icon"><i class="icon-writing-whiteboard"></i></div><strong>Server</strong> </div> <div class="dashtext-3"><?php if (isset($convoy_server)) { echo $convoy_server; } ?></div> </div> <div class="progress progress-template"> <div role="progressbar" style="width: 100%" aria-valuenow="35" aria-valuemin="0" aria-valuemax="100" class="progress-bar progress-bar-template dashbg-3"></div> </div> </div> </div> </div> </div> </section> <section class="no-padding-top"> <div class="container-fluid"> <div class="row"> <div class="col-lg-9"> <div class="block margin-bottom-sm"> <div class="title"><strong>Event Description:</strong></div> <?php echo $convoy_description;?> </div> </div> </div> <footer class="footer"> <div class="footer__block block no-margin-bottom"> <div class="container-fluid text-center"> <p class="no-margin-bottom">2020 &copy; Your company. Design by <a href="https://bootstrapious.com/p/bootstrap-4-dark-admin">Bootstrapious</a>.</p> </div> </div> </footer> </div> </div> <!-- JavaScript files--> <script src="vendor/jquery/jquery.min.js"></script> <script src="vendor/popper.js/umd/popper.min.js"> </script> <script src="vendor/bootstrap/js/bootstrap.min.js"></script> <script src="vendor/jquery.cookie/jquery.cookie.js"> </script> <script src="vendor/chart.js/Chart.min.js"></script> <script src="vendor/jquery-validation/jquery.validate.min.js"></script> <script src="js/charts-home.js"></script> <script src="js/front.js"></script> </body> </html> replace echo variables with an if isset to avoid errors if a problem exists. let us know how it goes...
  18. jodunno

    json, ajax help

    Hello everyone, i do not know how to use json or ajax to accomplish anything in code. However, i have read many times about the benefits of json/ajax, which sound lovely to me. For example, i have a background settings page on my website where a user can turn on/off bg photos, select a bg color instead of photo, apply a tint color to a bg photo, select a tint color or apply a css bg pattern to the whole bg. I currently do all of this via form post, write to db, set in session, read from session, display selection accordingly. I am now wondering how i could do this using json or ajax so that the user remains on the page and json or ajax communicates with php to make the changes. Anyone know of a simple tutorial for this process? anyone willing to offer sample code or pseudo code? i have no idea how this works. Thank you.
  19. so you are saying that it works? you see the data pulled from the database?
  20. it seems to me that you are copying and pasting code from this thread without trying to understand the code. for example, you have the following code in your file: $query = "SELECT * FROM convoy_part WHERE us_convoy=:get_id"; $stmt = $pdo->prepare($query); $start->execute(array(':getId' => $_GET['id'])); $result = $stmt->fetchALL(PDO::FETCH_ASSOC); you don't even notice the difference between :get_id and :getId. (the underscore naming convention, by the way, is just more useless bytes added to the file) once again, remove the following code block from your file: <?php include 'connection/sql1.php'; // Abrufen der ID für Teilnehmerknopf if (isset($_GET['id'])) { $user2 = mysqli_real_escape_string($conn , $_GET['id']); $query = "SELECT * FROM convoy_part WHERE id= '$user2' "; $run_query = mysqli_query($conn, $query) or die(mysqli_error($conn)) ; } ?> do you not notice that the aforementioned codeblock contains mysqli code? in your code you echo $convoy_kilometer but where is this data coming from? where do you set a variable named $convoy_kilometer? last time i mention a practice file. I recommend that you make a new blank php file specifically for learning pdo. use your current file as a basis. Actually, just start frsh from the html body tag with a proper pdo code block. simply echo results to see it working, then build the rest of your page. you have enough pdo ammo to clean up your document. the rest is up to you. let us know when you get it working...
  21. I strongly urge you to create a practice file. You have to integrate your code to the pdo format. You implemented pdo but you still have old mysqli statements left in the code which need to be removed. I wouldn't loop at all if you are only fetching all columns in one row. a loop is necessary if you need all columns from many rows. xampp is nice and easy to install. set up a simple database and create a php file to practice pdo. like so: database name: mytestdb table name: convoys columns: id, user_id, convoy_name, convoy_organizer $host = 'localhost'; $yourdbnamevar = 'mytestdb'; $your_db_username = 'root'; $your_db_password = ''; $attributes = array( PDO::ATTR_EMULATE_PREPARES => false, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC ); $fake_id = 1; $connection = new PDO("mysql:host=$host; dbname=$yourdbnamevar; charset=utf8mb4", $your_db_username, $your_db_password, $attributes); $query = 'SELECT convoy_name, convoy_organizer FROM convoys where id = :id'; $start = $connection->prepare($query); $start->execute(array(':id' => $fake_id)); $result = $start->fetch(); echo $result['convoy_name'] . '<br>' . $result['convoy_organizer']; Best wishes.
  22. his code is missing the closing bracket: $stmt->execute([':get_id' => $ _GET ['id']]); which is why i use array (so that brackets are easy to see): $start->execute(array(':getId' => $_GET['id'])); really, you should use a practice file and select names that are consistent. either $start, $s2, $stmt or some other name but mixing names even in this thread is confusing.
  23. so you just want the filename (optional extension) from a uri? <?php declare (strict_types = 1); $uri = 'http://my-site.com/gifts/images/my-image.jpg'; echo $uri . '<br>'; $ext = pathinfo($uri, PATHINFO_EXTENSION); $uri = pathinfo($uri, PATHINFO_FILENAME); echo 'filename is: ' . $uri . '<br>voila!<br>'; echo '<br>looking for extension?<br>'; echo 'filename and extension: ' . $uri . '.' . $ext; echo '<br>and once again, voila!'; exit; ?>
  24. you have the following code: <?php // Abrufen der ID für Teilnehmerknopf if (isset($_GET['id'])) { $user2 = mysqli_real_escape_string($conn , $_GET['id']); $query = "SELECT * FROM convoy_part WHERE id= '$user2' "; $run_query = mysqli_query($conn, $query) or die(mysqli_error($conn)) ; } ?> you should practice pdo in a new php file. write it out according to my example and examples on internet pages about pdo. when you see the expected results printed on the screen of your new php practice file, then you can begin integrating your webpage to the new pdo method of retrieving data from a db.
  25. Hello Endrick, please slow down and be certain that you are maintaining consistency in your variable names. you are using $s2 in place of $start. let's agree on names: $bdd, $query, $s2, $results. Then try the following code: <?php require('connection/db1.php'); // Abfragen der Daten z.B. für <?php echo $convoy_description; ... $bdd = new PDO("", ,); //fill in connection data and be sure that this data is available in db1.php $query = 'SELECT * FROM convoy_part WHERE user_convoy = :getID'; $s2 = $bdd->prepare($query); $s2->execute(array(':getID' => $_GET['id'])); //if you do not set fetch association in the attributes, then you must set it in your while loop while ($result = $s2->fetch(PDO::FETCH_ASSOC)) { $convoy_name = $result['convoy_name']; $convoy_veranstalter = $result['convoy_veranstalter']; $convoy_server = $result['convoy_server']; $convoy_date = $result['convoy_date']; $convoy_adddate = $result['convoy_adddate']; $convoy_language = $result['convoy_language']; $convoy_participants = $result['convoy_participants']; } ?>
×
×
  • 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.