-
Posts
2,134 -
Joined
-
Last visited
-
Days Won
42
Everything posted by benanamen
-
How to get difference between two or more arrays in PHP?
benanamen replied to grabbitmedia's topic in PHP Coding Help
You want the function array_diff http://php.net/manual/en/function.array-diff.php -
That is a lot more useful info than how to handle your attempt at it. Not sure if it is, but it was smelling of an XY Problem to me. Are you able to provide details on the "Certain Data" and exactly what it means regarding more or less data? Any other details may also be helpful. Are you in control of the source data? If not, what are your options in retrieving it? Are we talking about a third party API? Edit* Is this a third thread regarding the same project as your other two threads? https://forums.phpfreaks.com/topic/302727-multiple-updates/page-2 https://forums.phpfreaks.com/topic/302752-insert-on-duplicate-key-update-with-composite-key/
-
INSERT ON DUPLICATE KEY UPDATE with Composite key
benanamen replied to NotionCommotion's topic in MySQL Help
What is it that you are actually working on, meaning, the overall task, not your attempted solution to it? -
Where is the data coming from?
-
Search working on live website but not on WPEngine
benanamen replied to walleyeguy13's topic in PHP Coding Help
Here you go! -
Your methods are just ridiculous. Stop creating a bunch of variables for nothing. The whole Class_info.php need to be thrown in the trash. It is just a container for a bunch of variables for nothing. You have an HTML5 document yet you are using XHTML tags.
-
I have a lot of respect for @requinix for that approach.
-
Thumbs up to you @dudleylearning. It says a lot about you as a coder. Many posters just want someone to spit some code out to them and don't care if it is correct as long as it 'works'.
-
Search working on live website but not on WPEngine
benanamen replied to walleyeguy13's topic in PHP Coding Help
Now you need to update your code to use prepared statements. You NEVER EVER send user supplied data directly to the database. Your code is vulnerable to an SQL Injection Attack. -
how to create Searchable dropdown that echeos data from a database
benanamen replied to morena's topic in PHP Coding Help
What you are looking for is called "Auto Complete". It is the same thing google does. It uses AJAX. Google is your friend. I easily found numerous examples. There is no need split the data unless you want to get results by category like @Barand said. The only thing with categories is a medicine can fall into numerous categories. If you do not have that all mapped the user may have trouble drilling down to a specific medicine. A single autocomplete is best if they already know the name of the medicine. You may actually want both options, one if you know the name, the chained select if you are trying to find a type of medicine. https://www.google.com/search?q=php+autocomplete+dropdown+from+database -
INSERT ON DUPLICATE KEY UPDATE with Composite key
benanamen replied to NotionCommotion's topic in MySQL Help
You have name set to not allow nulls and there is no default value set for that column. In your query you do nothing with the name column. As you have it, you can think of 'name' as a required field. -
No it won't. To answer your question, yes, there is a problem with the way you wrote it.
-
And there's your "problem". Wordpress is not going to run code in a post. That would be a MAJOR security problem if it did.
-
Introduce our new application builder software for MySQL
benanamen replied to jsding's topic in Beta Test Your Stuff!
I personally am not comfortable running an encoded app from a source with no reputation of trustworthiness. There could be anything in that code. The app does look interesting though.- 1 reply
-
- 1
-
@requinix, nice job with the trial and error approach with the OP. That is my prefered method of teaching rather than spoon feeding answers. He will learn better this way IMHO.
-
HELP! I can't figure what the syntax error is!
benanamen replied to cldepo's topic in PHP Coding Help
You have all kinds of problems. 1. Stop using Dream Weaver and use a proper IDE 2. Stop needlessly mixing all your html with php 3. Learn how to properly use heredoc 4. Don't post code with all the line numbers. Our own proper IDE's will give us the line numbers if we need it. 5. Basically your Php processing should be at the top of the page and the HTML at the bottom, although you should be at least separating the HTML from the page with an include or ideally use a proper template engine like TWIG. 6. You can't be mixing quote types. 7. Your missing brackets 8. Your missing parenthesis 9. Your missing quotes. If you used a proper ide you would have seen all those careless mistakes. The code is full of it from top to bottom. -
Same here. Are you talking about something like this? https://forums.phpfreaks.com/topic/302370-router-any-issues-comments/
-
I agree with @Barand on the single table. Whenever I see UNION being used on a forum the DB design is always not properly normalized.
-
You don't need all that flag stuff and a "working solution" doesn't make it right. Of course you will want to use htmlentities on the output. It also looks like you should be using a WHERE clause since you are only looking for a particular result that matches $_GET. <?php $sql = "SELECT column_name FROM table"; $stmt = $pdo->prepare($sql); $stmt->execute(); $result = $stmt->fetchAll(); if ($result) { foreach ($result as $row) { echo "{$row['column_name']}<br>"; } } else { echo 'No Results'; } ?>
-
That is still wrong. $_GET can have numerous parameters. You are missing a name such as id=1. In your case it is name=1. You should probably be using POST instead of GET. <?php if (isset($_GET['name'])) { if ($_GET['name'] == 1) { //do something } if ($_GET['name'] == 2) { //do something } if ($_GET['name'] == 3) { //do something } } ?>
-
You are not doing any checks to see if the form has been submitted so the entire code runs before you doing anything. Look up and learn about isset. There are other problems I am sure others will tell you about.
-
In a nutshell, using tables for page layout went out in the 90's. This is almost 2017, use CSS like you're supposed to.
-
Ok, So it is a Mysql Keyword. Nevermind on the back ticks OP. name is still not a good column name anyways. What kind of name is name? Who knows? It is not descriptive enough. Thanks @Barand. I missed the line "Reserved keywords are marked with ®. ". Per the manual: