-
Posts
6,027 -
Joined
-
Last visited
-
Days Won
152
gizmola last won the day on February 25
gizmola had the most liked content!
About gizmola

Contact Methods
-
Website URL
http://www.gizmola.com/
Profile Information
-
Gender
Male
-
Location
Los Angeles, CA USA
Recent Profile Visitors
The recent visitors block is disabled and is not being shown to other users.
gizmola's Achievements
-
I do like the site, mainly for the Tests Tab. It allows you to create a number of test cases, which is invaluable when you're designing a new regex. Another site I also use is: https://regex101.com/ I think the help is a little bit better on this site, as it has a built in cheat sheet to the right of the site.
-
php mysql statement not working on decimal value
gizmola replied to garyed's topic in PHP Coding Help
To clarify, for DECIMAL(M, D) the M is maximum number of digits, less the reserved decimal places. So with your example the max number would be: 99,999,999.99 -
php mysql statement not working on decimal value
gizmola replied to garyed's topic in PHP Coding Help
Yes, set your definition as required for the maximum size of the number you need to handle. The M precision can be as large as 64 digits, but you should always try and size it to maximum size you need. If you truly need 10 digits to the left of the decimal point, then you should define the number as decimal(12, 2) -
php mysql statement not working on decimal value
gizmola replied to garyed's topic in PHP Coding Help
Using the right data type for the right job is just part of the learning curve for any relational database. The mysql manual is not the easiest manual to read, but there is this general page: https://dev.mysql.com/doc/refman/8.4/en/precision-math-numbers.html -
php mysql statement not working on decimal value
gizmola replied to garyed's topic in PHP Coding Help
Yes, float is not the right data type to use for storing monetary values. Use a decimal. Here's an example: CREATE TABLE Product ( ProductID INT AUTO_INCREMENT KEY, item varchar(20), cost decimal(6,2) ); INSERT INTO Product (item, cost) values ('shoe', 27.55); INSERT INTO Product (item, cost) values ('hat', 27.89); UPDATE Product set item = 'sneaker' where cost = 27.55; You can see this example in action at db-fiddle: https://www.db-fiddle.com/f/veSL2xerpodFq79N2e4rUi/0 As an editorial comment, why are you interpolating the name of the table from a variable into a string? Use the table name. Your queries should also be using bind variables. -
To add to Barand's comment, your use statements need to be at the top of the file. This is literally the instructions from the project github page at https://github.com/PHPMailer/PHPMailer <?php //Import PHPMailer classes into the global namespace //These must be at the top of your script, not inside a function use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\SMTP; use PHPMailer\PHPMailer\Exception; //Load Composer's autoloader require 'vendor/autoload.php'; We do not know if this will actually work because we don't have any idea what your project layout is. For example, if your project webroot is /public, then these instructions won't work, because your path to the vendor/autoload.php would need to be: require '../vendor/autoload.php'; Using require will generate an error if the required file can not be located.
-
That is a description of a problem. Do you have some code to look at? Debugging or error information? Without that, we can't help.
-
Stuck in the procedure of dropping database in progeSQ....
gizmola replied to MeghaPatil's topic in PostgreSQL
When you connect to postgresql you specify a database. If you are connecting to the database you are trying to drop, you will be blocking your ability to drop it. Make sure you connect to the postgres database. If that is not the issue, and you are not connecting to mydb, you should be able to drop the database regardless of any other existing connections to it, using: drop database mydb with (force) -
The two ways are significantly different. The first way is the way you should do this. It uses the curl extension that is built into PHP. The 2nd way is creating a system shell and then executing a shell command that in your case happens to be the curl command. Many things could go wrong, and you will not have visibility into those issues. It is a less direct method, and doesn't have the same level of access to curl options and results.
-
Struggling with a complex Regex pattern for email validation
gizmola replied to ellenssim7's topic in Regex Help
If this is for validation of emails, then a simple and effective solution would be to utilize filter_var. $email = '[email protected]'; function validEmail($email) { return filter_var($email, FILTER_VALIDATE_EMAIL); } if (!validEmail($email)) { echo "The email address provided is not valid"; } -
Someone told you? Who was that exactly? This behavior is caused by settings in the PHP.ini. See this page: https://www.php.net/manual/en/mail.configuration.php#ini.mail.add-x-header. You are able to disable these variables in the PHP.in configuration. The mail() function drops mail off for the system Mail Transfer Agent. In many cases, hosting companies utilize those variables to insure that outbound mail is authorized, and this may end up stopping mail delivery. You should contact your hosting provider to inquire about disabling the settings.
-
Not much we can do to help you with this little information. It sounds like you have a hosting company, and it sounds like the hosting company tools have limits or don't work very well. You should seek support from them.
-
VS Code ask for a connection.
gizmola replied to PeterBubresko's topic in Editor Help (PhpStorm, VS Code, etc)
Debugging a web application is a non-trivial exercise in most situations. VSCode is not a web server, so if you're developing a web application, you are not going to have much luck without a good understanding of both xdebug and the vscode debugging extension. You will need both. To try and simplify it, xdebug is a php extension that needs to run where your PHP code is running. Again as a web application, that is likely to be either within a local webserver + php environment, or possibly within a docker container (that has the PHP server), or even on a "remote" server. The point is, that there are many different ways to run "serverside" PHP, and for that reason, there isn't a simple answer. What I can say, is that xdebug is actually a multi function extension that provides a step debugger a profiler (for timing) a code coverage analyzer a function tracer So there are a myriad of different switches and options it allows for. Purely from the step debugging point of view you have to understand a couple of things: XDebug implements a debugging protocol called DBGP Any editor that can talk DBGP will work with xdebug. The actual "debugging" you think of, is really more of a trick, whereby xdebug accepts information about source files and line numbers for things like breakpoints, and the editor can then use this to synchronize your view of things, provide information about variables and functions, the stack etc, but in reality it's sort of an illusion, in that the code is not ever running within VSCode. So you have to realize that XDebug is in charge of debugging. It does this by connecting to VSCode and at that point, will allow for communication. So when you saw the message about a connection, it was because the editor can't do anything since there is no configuration setup to allow the INCOMING connection from the server where xdebug is installed back to VSCode. The problem with any how-to for setting up xdebug with vscode, is that it entirely depends on where the server with xcode installed is running. With that said, at this point, most people using vscode are using this extension to facilitate the configuration you need. Another thing to understand, is that with a web application, you typically need a way to initialize the debugging conversation, and start the debugging session from the web application. In most cases, people will use a cookie addon that sets a special cookie in your browser, which the server will see. There have been a number of these browser extensions over the years, but luckily at this point there is one that Jetbrains has backed here: https://github.com/JetBrains/xdebug-extension There are versions for different browsers. You will use this browser extension to setup the cookie needed to tell xdebug to start a debugging session in your VSCode. Once started xdebug will try and connect back to your IDE on the port you configure. So this means that port based networking is involved. By default (assuming step debugging is enabled) that port is 9003. See xdebug.client_port in the manual. So your IDE needs to be configured to open up port 9003, which is what the vscode extension helps you do. I recommend you try and read through this: https://xdebug.org/docs/step_debug There are many links in there to information about particular environments and videos to help you try and get it working. -
Connect via WordPress "wpdb" to another database vs "mysqli_connect"
gizmola replied to dbareis's topic in PHP Coding Help
A singleton is an OOP design pattern. The design of a singleton is such that there will only be ONE (a single) object of the singleton class. Objects of a singleton class are made using a static method. The wordpress wpdb class source code is here. It does NOT implement a singleton pattern. The $wpdb global object however, is intended to be used throughout Wordpress and by any plugins. So you CAN create new objects of class wpdb, so long as you understand what that requires. It is not clear from your question why you need a 2nd database connection. As for your shared host, you should investigate the # of database connections they have configured. In phpMyAdmin you can use a query like this to see how many connections your hosting company has configured. SHOW VARIABLES LIKE 'max_connections'; The default value is 151. I have heard of certain shared hosting companies setting this value arbitrarily low. If you want to report back to us what you find, we can weigh in on the reasonableness of the limit. In many cases you can open a ticket with the hosting company to have them increase the mysql parameter that controls this limit. As for closing a database connection, no you don't need to worry about closing it. PHP has page/script scope, so as soon as the page is complete, PHP already disposes of all variables and releases any resources. If you have a small amount of code that makes a few queries and you are absolutely sure that you are done with the connection you made, then it doesn't hurt to do something like this: $my_wpdb = new wpdb(....); // make queries etc. $my_wpdb->close(); unset($my_wpdb); But it really is a micro-optimization that is not worth doing. -
I feel like I have advised this before, but change all your include_once() calls to require_once(). Is the code you provided above the code for the DataInput.php script? As @mac_gyver stated: you have assumptions as to what loads or doesn't, that we have no way of validating.