Jump to content

justsomeguy

Moderator
  • Posts

    31,575
  • Joined

  • Last visited

  • Days Won

    77

Everything posted by justsomeguy

  1. Wait, no, you've added $user_id to your function definition (which actually does give the function a purpose), but for some reason you've also decided to pass $user_id to mysqli_query, even though the third parameter to mysqli_query should be the result mode: https://www.php.net/manual/en/mysqli.query.php
  2. Yeah, that's literally the same code you posted 5 hours ago.
  3. Damn, did I call that, or what? You have decided that the problem with your code, after all of the questions that I asked, is that your code was missing curly brackets around the function call for some reason, even though you've never seen any other code that just has an arbitrary pair of curly brackets that are not associated with any control structure or anything else. I don't know what to say. Well done. The funny thing is that it's not actually a syntax error. It serves absolutely zero purpose at all, but yeah, if you want to just group arbitrary code in a set of brackets I suppose PHP won't stop you.
  4. OK, a few new questions: 1. Why are you defining the function with required parameters, and then not passing any parameters when you call it? 2. Since I already asked that, why didn't you address it? Did you not see the question? Did you ignore it? Do you not know what I'm talking about at all? 3. Why are those 2 lines of code in a function at all? What is the purpose of putting those 2 lines of code into a function? 4. Are you ever going to address the SQL syntax error? I've mentioned it multiple times and, again, it appears that you're just ignoring me when I point it out. 5. Why are you using a variable called $user_id that you haven't defined? 6. Why am I still bothering to point out errors if you just ignore my questions? When I ask a question, I expect an answer, these questions are not rhetorical. I don't expect you to just post a slightly-altered piece of code with different problems but not answer any of the questions that I'm asking you.
  5. Seriously. And why is the same character missing after the function definition line? There is a major lack of attention to detail going on, and that is a really bad sign for anyone who wants to program. This is the format of a function definition: function function_name (parameter list) { function body } You have this: { function function_name (parameter list) function body } And you don't seem to notice, or have any idea. That's worrisome.
  6. Well, I don't know what to tell you. Some books don't have enough information, other books have too much. I don't think the problem is the books. Of course not, now in addition to your SQL syntax errors, you have PHP syntax errors also.
  7. I wouldn't count on the filesystem returning data the way you want, I would get the list of all of the files and folders, sort them however you want to sort them, and print the sorted list.
  8. The example code isn't what you need, you need to start at the beginning. You need to understand variables, functions, constants, objects with methods and properties. You need to understand data types, string syntax, control structures, scope, and how to look up information in the manual. Any amount of looking at example code or Youtube videos will fail to give you that knowledge. That's just a fact. I would never expect a publishing company to provide technical support for their books. The people you are emailing are in the book publishing business, they don't have technical support staff on hand for any subject that they might publish a book for. That's not what they do, they publish books. 100% of lessons involving databases will cover delete operations. They are one of the 4 fundamental data manipulation operations along with select, insert, and update. Your book covers using delete queries, what it probably doesn't do is have an example that you can immediately apply to your specific situation since you don't understand the basics. Deleting is every bit as simple as selecting data, it's actually more simple. With selecting data, you have to tell it which table or tables, which fields, and which records. With deleting you only tell it which single table and which record or records. Deleting is easier and more basic than selecting data. It's also more basic than inserting or updating with all of the possible functions and default values and triggers and other things that you don't worry about with deleting. So I really doubt that the problem is that your book didn't include a section on using delete queries, I bet the problem is that you didn't understand it because you skipped everything before it, and you couldn't find an example that directly applied to your specific situation. You don't think a book like this is going to have anything useful to you? Really? There's over 800 pages there, you think you would read through 800+ pages and still have no idea? Man, I read a book about PHP 15 years ago that only had 500 pages, and it gave me everything I needed. Surely those 800+ pages have some basic information about PHP, right? I mean, considering that your existing knowledge of PHP is essentially zero, any information at all is something you don't have, right? Well, the SQL checker in my head shows that you have a syntax error. That query won't run, because you haven't learned how to write the most basic query in SQL. You're not even going to execute the function to delete the record at all, because the logic in that codes makes absolutely no sense. If your delete query returns at least one row (why would a delete query return rows at all? That's not what a delete does. That doesn't make any sense) then you want to run the deleterecord function. So you ONLY want to run the deleterecord function if your delete query that doesn't return any records actually did return a record, and you don't want to call your function in any other situation? Why do you even have a function at all, what's the purpose of putting your code in a function here? And if you're going to define your function to require that 3 parameters are passed to it, then why are you trying to call it with no parameters? Isn't that a fatal runtime error? And, speaking of parameters, why are you trying to require 2 parameters in the function that you never even use? See the problem? You really think your issue is that you haven't found the right example code? That's not your problem.
  9. If you want to query multiple databases and group the results into a single result set, you need to use unions or subqueries to get the various results into a single set.
  10. The WHERE clause isn't the problem. You have both PHP syntax errors, and also SQL syntax errors, all in a single line of code. And those errors are there, and you don't see them, because you never bothered to understand the basics of what you're trying to use. I don't know if you've done much with electrical engineering, but I'll try to use an analogy. Imagine you're an electrical engineer, you've been designing circuits all of your life. You know how resistors, capacitors, etc work. You know the fundamentals, like the fact that a circuit has to be complete for any electricity to flow at all. Now, someone comes to you and they're trying to design a circuit, and they show you a circuit diagram. They have a 5v power source, and a switch, and a 5v light, and they're trying to make a circuit where you flick the switch, and the light turns on. For anyone calling themselves an electrical engineer, this is just about the most basic circuit imaginable. But this person shows their circuit diagram to you, and they have a bunch of resistors and capacitors in there for some reason, so you ask them why. "Well, because every other circuit diagram I looked at had those, so I figured I needed them, so I put them in mine." OK, but where you put them doesn't make sense. In fact, they don't need to be there at all. Why do you think they need to be there? "I don't know, the ones I looked at had them." OK, but what does a resistor actually do? "I don't know." OK, well just remove the resistors, remove the capacitors, and hook the wires up. "OK, I hooked up the wires, what about now?" Well, now the diagram only shows one wire from each part connected. The circuit isn't complete. How is electricity going to flow through an incomplete circuit? "I don't know." And for some reason you just moved the resistor to the negative terminal of the light bulb, why did you do that? "Other circuits had resistors." But what does a resistor actually do, do you need it here? "I don't know." Now a year passes, and this person comes back with the same diagram, with the same problems. Aren't you going to get just a little bit frustrated that the person is still trying to design the most basic circuit imaginable and has STILL never bothered to learn the basics about what they're using? That's what's going on here. You've been at this for well over a year, and for some reason you absolutely refuse to learn the basics. You pick up a book, skip all of the opening chapters, flip through the one chapter that's remotely similar to the thing you're trying to make, don't understand it, and conclude the book is useless. It would make perfect sense if you bothered to read the basics, but for some reason you think you don't need to. Every person trying to help you knows the basics. Every person who has ever written any non-trivial functional program understands the basics. You don't think you need to understand the basics, for some reason that I cannot comprehend. It doesn't matter what trade or skill you're trying to learn, if you don't learn the basics you're not going to understand anything. You can't expect to pick up a book about how engines work, skip to the chapter about spark plugs without reading anything else, and expect to be able to diagnose and fix any problem with spark plugs. You don't know how the entire system works together. This is no different. This entire thread has been trying to call your attention to the smallest, most basic of errors, and you remain completely incapable of detecting them because you never learned the basics. Nothing else matters if you're not going to learn the basics. Fixing this code for you will not teach you a single thing, because you will not even be able to detect all of the changes in the first place, and you will have absolutely zero idea why those changes were necessary to fix the code.
  11. I don't know what you're asking. No code is "needed," it's up to you to decide what you want your program to do. Whether you put code in a function or not really only matters for reuse. And if you want to refer to a specific record in the database, you just need to know how to uniquely identify it. Most often that means passing an ID. If you're asking about mysqli_num_rows, if you read the description in the manual it says that it returns the number of rows in the result set. So if you're asking if you need to use that function, then I guess that depends whether you care how many rows are in the result set. If you care, then yeah, that's how you find out.
  12. I'm not sure how to do it with one pattern, I don't use lookahead or lookbehind very often. I would use multiple patterns, but there's probably a way to do it with one.
  13. Every time you click search, you add a CSS file to the head. Get rid of that and see if it changes.
  14. You're telling it that you both need 2 digits and also that there can't be any digits. For your other pattern, I do get matches for those 2 strings.
  15. Use ^ at the start a character class to negate it. [^0-9] means any character other than a digit.
  16. Yeah if there's a lot of processing that needs to be done then it might be best to get all of the records and then process them with another language before outputting everything.
  17. I suppose you could write a query that would work by concatenating multiple rows, but that's only going to work if each row only has data in a single column. Otherwise, it's not the best design to store data like that.
  18. I'm not sure what you're describing, but of course you can only run code on your own server. No other site is going to allow you to run arbitrary server-side code on a server or site that isn't yours.
  19. Not that I can think of, in fact it won't even work to add more than one pattern when you're using positive lookahead, it will still only require 1 digit. You would need to test it with multiple expressions.
  20. Everything inside the else block there is what you want to happen on your site, so you would change that to match whatever your site is doing. That code shows adding everything to a table called mediumpathipn, and then updating the members table. You can replace that with whatever makes sense for your site. If the user ID that they pass you doesn't match the user IDs on your site then you need to have a way to map their user ID to your users.
  21. Make 2 patterns for 1 digit each instead of 1 pattern for 2 digits.
  22. If you want to save the data on the server then you need to use PHP to save it. If you want to count any arbitrary existing links then you could have Javascript send an ajax request to a PHP script with the URL that was clicked on, the URL of the current page, etc.
  23. I assume you just call getCurrentPosition again.
×
×
  • Create New...