-
Posts
2,134 -
Joined
-
Last visited
-
Days Won
42
Everything posted by benanamen
-
It's a waste of time to even get into it. It is VERY bad code. Toss it and don't ever post it again. You might as well ask everyone to hack you. And that's just for starters.
-
@lovephp, No, No, and NO!
-
Determining which query caused exception in try block?
benanamen replied to NotionCommotion's topic in PHP Coding Help
set_exception_handler is your friend here. @Jaques1 schooled me on this one. http://php.net/manual/en/function.set-exception-handler.php -
back to PDO and get strange error on online host not on wamp
benanamen replied to lovephp's topic in PHP Coding Help
GoDaddy shared hosting is the worst. I double my rate when I have to work on those accounts. -
Help to get Json data to a comma delimited file
benanamen replied to techboy992's topic in PHP Coding Help
You may need to use LOAD DATA LOCAL INFILE http://dev.mysql.com/doc/refman/5.7/en/load-data.html -
@jaques1, just how many times and places do you actually need to set the character encoding? So you have header('Content-Type: text/html;charset=utf-8'); <meta charset="utf-8"> html_escape($test_input, APP_HTML_ENCODING) $dsn = "mysql:host=$dbhost;dbname=$dbname;charset=$charset"; And also have mentioned the server can set the character encoding. Seems redundant to have to explicitly set it in so many places. Not to mention Mysql as well, but I assume that is different.
-
Is a single JSON MySQL retrieval faster than individual rows?
benanamen replied to DeX's topic in MySQL Help
Your problem is your query. You need to join the tables. That is the whole reason it is so slow. The WHERE clause is killing it. This kind of thing should be done in a JOIN WHERE building_products.id = product_id Also, name is a reserved word. Change it to something like color_name. Unless height, width, length, and quantity are something other than numbers, you shouldn't be using varchar for the column type. -
Inserting Multiple Checkbox Values into a single MySQL database Column
benanamen replied to dulskel11's topic in MySQL Help
Pictures are for hanging on the wall. Post your actual code. With that said, you are using obsolete code that has been completely removed from Php. You need to use PDO. https://phpdelusions.net/pdo -
Where can this Portfolio be viewed?
-
Solidly makes the case. I personally have not done anything multi-lingual which is why I think in 100% sql and I am always the sole programmer. One point that does make Barand's answer is if you're querying from the console to get the same result. Valid point.
-
Even better.
-
@Jaques1, what about if with case? (Not considering OP's existing syntax, assuming proper join)
-
After research, there are no license issues with the aforementioned softwares as you said. I am not anyone's employee so this does not fall under the "Work For Hire" laws. As an independent contractor I automatically own the copyright to the code unless there is a written transfer of those rights. The solution that made sense is what @kicken proposed. Thanks for the feedback to both of you.
-
For starters you never insert user supplied data directly into the database. You are using PDO incorrectly. You need to use parameterized queries. Since you didn't post your form code it is impossible to tell if submit is even properly set. You should not be depending on the status of a button name to be submitted in order for your code to work. I am on my phone at the moment so I cannot post you the proper links to look at.
-
Thanks for the reply. I have concluded that licensing is the right direction as opposed to copyright transfer. Issues currently identified with copyright transfer is: A: App includes third party code and their licensing parameters may be an issue. (Jquery, bootstrap..) B: App contains often used code such as login, forgot password, and password reset. Could not transfer ownership of that code. So, question is now narrowed to compensation for a licence to sub licence and the conditions for that. I always give an "implied" unwritten license for exclusive use to the hiring company that it was developed for. To date, I would never use or need anything I have developed. Any additional feedback on this welcome.
-
I am 192 hours into a project and NOW the owner of the company (not the one who I have been working with) wants a contract signed which includes the assignment of copyright ownership. My rate was based on the exclusive use of the application as a complete work for use by this company only. They tell me now that they want to licence the app to other companies in their industry. My question is, how have any of you dealt with the assignment of copyright (Ownership of the underlying code). Do you work at an increased hourly rate?, Negotiate a flat rate for the transfer of copyright? Since there is much more they want to do it is impossible to know how much more code there will be for them to own so doing a flat rate agreement today doesn't seem wise. In all my years of coding this has never come up.
-
For me, on this forum it doesn't come across right. I personally don't get offended but it still doesn't come across right to me. It might have something to do with the more professional sense of this forum. And in a professional setting you wouldn't be calling people bro.
-
You are using obsolete Mysql_* code that has been completely removed from Php. You need to use PDO. https://phpdelusions.net/pdo
-
Toss that code in the trash. It has been obsolete for over a decade and is now completely removed from PHP. You need to use PDO.
-
Your code has been obsolete for many many years and has been completely removed from PHP. Find another tutorial to slap together your code from.
-
Perfect! That did the trick. Thanks, but I am quite aware of that. The code is just a quick example to demonstrate the specific problems mentioned. The $_GET['p'] is on the TODO LIST and relates to a previous discussion you and I had on ways to "encrypt" the url to stop id # changes. The code was cut from a page that has not been updated per your suggestions from another post. All other pages have been updated as such: <?= !empty($note) ? htmlspecialchars($note, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8') : '';?>
-
Here is a problem I have never run accross. The code will demonstrate. I have two sets of first/last name arrays to enter to DB and one non array random required field. On submit with empty random field, required error displays as should, but array fields get error: Warning: htmlspecialchars() expects parameter 1 to be string, array given. Not sure how to handle this. Google not much help. PART 2 Assuming first problem has been fixed, I want to require at least one first and last name. (Think Husband and wife, only need one minimum) How would I go about requiring just one first/last name set? <?php echo "<pre>"; print_r($_POST); echo "</pre>"; if ($_SERVER['REQUEST_METHOD'] == 'POST') { //------------------------------------------------------------------------------------ // Check Missing Fields //------------------------------------------------------------------------------------ $error = array(); if (empty($_POST['random'])) { $error['random'] = 'Random Field Required.'; } //------------------------------------------------------------------------------------ // Check for errors //------------------------------------------------------------------------------------ if ($error) { $error = implode("<br >\n", $error) . "\n"; ?> <div class="row"> <div class="col-md-offset-2 col-md-8"> <div class="error_custom"><?= $error ?></div> </div> </div> <?php } else { //Insert to DB } } // End POST ?> <!DOCTYPE html> <html> <head> <title>Hello!</title> </head> <body> <form class="form-horizontal" action="<?= $_SERVER['SCRIPT_NAME'] ?>?p=<?= $_GET['p'] ?>" method="post"> <div class="form-group <?= !empty($error['name_first'] ) ? 'has-error' : '' ?>"> <label class="col-md-4 control-label" for="name_first">First Name <span style="color: #FF0000;">*</span></label> <div class="col-md-4"> <input id="name_first" name="name_first[]" type="text" placeholder="First Name" class="form-control input-md" value="<?= !empty($_POST['name_first']) ? htmlspecialchars($_POST['name_first']) : '';?>"> </div> </div> <div class="form-group <?= !empty($error['name_last'] ) ? 'has-error' : '' ?>"> <label class="col-md-4 control-label" for="name_last">Last Name <span style="color: #FF0000;">*</span></label> <div class="col-md-4"> <input id="name_last" name="name_last[]" type="text" placeholder="Last Name" class="form-control input-md" value="<?= !empty($_POST['name_last']) ? htmlspecialchars($_POST['name_last']) : '';?>"> </div> </div> <div class="form-group <?= !empty($error['name_first'] ) ? 'has-error' : '' ?>"> <label class="col-md-4 control-label" for="name_first">First Name <span style="color: #FF0000;">*</span></label> <div class="col-md-4"> <input id="name_first" name="name_first[]" type="text" placeholder="First Name" class="form-control input-md" value="<?= !empty($_POST['name_first']) ? htmlspecialchars($_POST['name_first']) : '';?>"> </div> </div> <div class="form-group <?= !empty($error['name_last'] ) ? 'has-error' : '' ?>"> <label class="col-md-4 control-label" for="name_last">Last Name <span style="color: #FF0000;">*</span></label> <div class="col-md-4"> <input id="name_last" name="name_last[]" type="text" placeholder="Last Name" class="form-control input-md" value="<?= !empty($_POST['name_last']) ? htmlspecialchars($_POST['name_last']) : '';?>"> </div> </div> <!-- Text input--> <div class="form-group <?= !empty($error['random'] ) ? 'has-error' : '' ?>"> <label class="col-md-4 control-label" for="random">Random Required <span style="color: #FF0000;">*</span></label> <div class="col-md-4"> <input id="random" name="random" type="text" placeholder="Random" class="form-control input-md" value="<?= !empty($_POST['random']) ? htmlspecialchars($_POST['random']) : '';?>"> </div> </div> <div class="form-group"> <div class="col-md-offset-4 col-md-4"> <input type="submit" name="submit" value="Submit" class="btn btn-primary"> </div> </div> </form> </body> </html>
-
Cannot modify header information - headers already sent by
benanamen replied to Nefferson's topic in PHP Coding Help
Try posting your code. -
Are you defining $content before here? Reason is you are doing dot equals. If it is not defined change .= to just = The image doesn't help. Where is $content first defined? Meaning where is content= without the period?