Jump to content

dil_bert

Members
  • Content Count

    542
  • Joined

  • Last visited

  • Days Won

    3

dil_bert last won the day on June 12

dil_bert had the most liked content!

Community Reputation

5 Neutral

About dil_bert

  • Rank
    Prolific Member

Profile Information

  • Interests
    used OpenSuse for more than 10 years - now stick to Manjaro; Interested in all raspi-things, Python, Perl, PHP and GIS,

Recent Profile Visitors

4,630 profile views
  1. Hello dear Barand , first of all many thanks for the reply and your ideas and the sharing of ideas and insights. well i am so thankful that you gave me the hint several days. note: at the moment i am not at home - i am just traveling - and i have no access on the server - but as soon as i am back home i will do the tests on the server and i wll check some words regarding the installation: I have Linux Server. Apache 2.4.10, PHP Version 5.6.39 and mysqlnd 5.0.11-dev - 20120503 -installed. There are several wordpress website running on server. I have checked this all one week ago, In the phpinfo(); what do you suggest - should i ask my serveradmin that he will update & upgrade the whole system - in order to have a modern system... And then i run the mysqli_error_(function)!? I love to hear from you mysqli_error() function / mysqli::$error The mysqli_error() function / mysqli::$error returns the last error description for the most recent function call, if any. Syntax: Object oriented style string $mysqli->error; Procedural style string mysqli_error ( mysqli $link ) Parameter: Name Description Required/Optional link A link identifier returned by mysqli_connect() or mysqli_init() Required for procedural style only and Optional for Object oriented style Usage: Procedural style mysqli_error(connection); the Parameter: Name Description Required/Optional connection Specifies the MySQL connection to use. Required Return value: A string that describes the error. An empty string if no error occurred. Version: PHP 5, PHP 7 Example of object oriented style: <?php $mysqli = new mysqli("localhost", "user1", "datasoft123", "hr"); /* check connection */ if ($mysqli->connect_errno) { printf("Connect failed: %s\n", $mysqli->connect_error); exit(); } if (!$mysqli->query("SET a=1")) { printf("Errormessage: %s\n", $mysqli->error); } /* close connection */ $mysqli->close(); ?> Copy Output: Errormessage: Unknown system variable 'a' Example of procedural style: <?php $link = mysqli_connect("localhost", "my_user", "my_password", "world"); /* check connection */ if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } if (!mysqli_query($link, "SET a=1")) { printf("Errormessage: %s\n", mysqli_error($link)); } /* close connection */ mysqli_close($link); ?> Copy Output: Errormessage: Unknown system variable 'a' Example: <?php $con=mysqli_connect("localhost","user1","datasoft123","hr"); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } // Perform a query, check for error if (!mysqli_query($con,"INSERT INTO employees (First_Name) VALUES ('David')")) { echo("Errorcode: " . mysqli_errno($con)); } mysqli_close($con); ?> Copy Sample Output: Errorcode: 1146 and dear Barand - i am happy bout your ideas regading the comparison - and for the sharing of the ideas: some words regarding the installation: I have Linux Server. Apache 2.4.10, PHP Version 5.6.39 and mysqlnd 5.0.11-dev - 20120503 -installed. There are several wordpress website running on server. I have checked this all one week ago, In the phpinfo(); what do you suggest - should i ask my serveradmin that he will update & upgrade the whole system - in order to have a modern system... And then i run the mysqli_error_(function)!? I love to hear from you
  2. Hello dear experts and user of PHPFreaks, first of all: i have plenty of issues - a whole bunch of issues on a Server - i need to digg deeper into all things regarding creating a healthy db-connection. Therefore i need to learn all about the script - mysql_connect_error... see below. i have gathered some information - in order to think about it - and to share the ideas ... so i hopefully will learn and solve my issues. well the mysql_connect_error-script is a great help: It returns a string description of the last connect error ( see more infos here: https://www.php.net/manual/en/mysqli.connect-error.php ). The mysqli_connect_error() function returns the error description from the last connection error, if there is any error-note. the return value are the following ones: a. A string that describes the error. b. an empty string if no error occurred. at least this goes for the Version: PHP 5, PHP 7 well - if we run the code below we can get the info bout the option to connect to the db. What if we run this as a mysql-test-script, and what if we will want to convert it to use mysqli? Can this be done by changing mysql _query($sql); to mysqli _query($sql); ? <?PHP // the test-script that we are running. $DB["dbName"] = "emails"; $DB["host"] = "localhost"; $DB["user"] = "root"; $DB["pass"] = ""; $link = mysql_connect($DB['host'], $DB['user'], $DB['pass']) or die("<center>Howdy - be aware; There a thing happenede - An Internal Error has Occured. Please report following error to the webmaster shot him a mail now.<br><br>".mysql_error()."'</center>"); mysql_select_db($DB['dbName']); // end header connection part // function from a functions file that I run a mysql query through in any page. function executeQuery($sql) { $result = mysql_query($sql); if (mysql_error()) { $error = '<BR><center><font size="+1" face="arial" color="red">An Internal Error has Occured.<BR> The error has been recorded for review</font></center><br>'; if ($_SESSION['auto_id'] == 1) { $sql_formatted = highlight_string(stripslashes($sql), true); $error .= '<b>The MySQL Syntax Used</b><br>' . $sql_formatted . '<br><br><b>The MySQL Error Returned</b><br>' . mysql_error(); } die($error); } return $result; } // example query ran on anypage of the site using executeQuery function $sql='SELECT auto_id FROM friend_reg_user WHERE auto_id=' .$info['auto_id']; $result_member=executequery($sql); if($line_member=mysql_fetch_array($result_member)){ extract($line_member); } else { header("location: index.php"); exit; } ?> If we do replace mysql_* with mysqli_* then we will have to bear in mind that a whole load of mysqli_* functions need the database link to be passed. E.g.: the following ones. mysql_query($query) becomes mysqli_query($link, $query) I.e., lots of checking required. on the other hand side: is it suffice if we replace every mysql_* function call with its equivalent mysqli_*, when we will use the procedural API (note: there is some code based on the MySQL API, which is a procedural one - at least afaik), To help with that, the The MySQLi Extension Function Summary-manual is definitely something that will prove helpful. We can do the following: we have the following options to do that: - mysql_connect will be replaced by mysqli_connect - mysql_error will be replaced by mysqli_error and/or mysqli_connect_error, depending on the context - mysql_query will be replaced by mysqli_query ,,,, and so on and so forth. Note: For some functions, we may need to check the parameters very very carefully: Maybe there are some differences here and there -- but not that many differences. Belive me. Both mysql and mysqli-codes are based on the same library ( the great and powerful libmysql ; at least for PHP-version <= 5.2) Usage - for instance: with mysql, we have to use the mysql_select_db once connected, to indicate on which database we want to do our queries mysqli, on the other side, allows us to specify that database name as the fourth parameter to mysqli_connect. what do you think bout this.. love to hear from you
  3. BY THE WAY: - My Server admin adviced me to do some extra tests; - running an installation with another script - a other than wordpress - to see if the installation probably would succeed with another script. well i am musing bout these advices - and will follow them. I must have more insights into the magic. will come back and report all findings. greetings
  4. first of all - many thanks dear Barand and Maxxd for the reply and your continued support: here some more insights and Output from SQL command SHOW GRANTS FOR 'jo'@'localhost'; .. Output from SQL command SHOW GRANTS FOR 'jo'@'localhost'; .. Grants for jo@localhost GRANT USAGE ON *.* TO 'jo'@'localhost' IDENTIFIED BY PASSWORD '*93C1B40FA5F0FED10E5A0CE946A5E71D59B00860' GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP ON `jo`.* TO 'jo'@'localhost' hmmm - running the SQL-Request works now - without any issue. but for the results : i try to figure out what these results mean. Guess that i can verify the issues.
  5. hello dear MaxxD and Barand, first of all - many many thanks for the reply with all the ideas and suggestions. many many thanks for the quick answer with all the ideas, that are very interesting. here a little update and more findings: by the way: if i do not use USE <db-name> .... then it works propperlyconclusio: if i run SHOW GLOBAL VARIABLES LIKE 'PORT';[/CODE]i get a concrete output from SQL command SHOW GLOBAL VARIABLES LIKE 'PORT'; ..or if i run [CODE] SHOW GRANTS FOR CURRENT_USER;[/CODE]i get outputs like this one[CODE] Output from SQL command SHOW GRANTS FOR CURRENT_USER; .. Grants for root@localhost GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY PASSWORD '*4444444rrrrrrwwwww222222444443660283C379783ED8EF54B6EC01DAF8374444444rrrrrrrrrrrreeeeewwwww2CeC3C474F4' WITH GRANT OPTION GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION [/CODE]and now i have to rethink what this does want to say in the context of a - error in trying to establish a db-connection - while installing a wordpress on the frontendlook forward to hear from you greetings
  6. hello dear Barand hello dear MaxDD many many thanks for the quick reply - @Barand - yo told me to do /use the following: to run the following command: mysqli_connect_error (PHP 5, PHP 7) https://www.php.net/manual/en/mysqli.connect-error.php mysqli::$connect_error -- mysqli_connect_error — Returns a string description of the last connect error Object oriented style string $mysqli->connect_error; Procedural style mysqli_connect_error ( void ) : string Returns the last error message string from the last call to mysqli_connect(). Return Values ¶ A string that describes the error. NULL is returned if no error occurred. Examples ¶ Example #1 $mysqli->connect_error example Object oriented style
  7. dil_bert

    MySQL commands on Webadmin

    hi dear all have errors like error in establishing a database-connection. @requinix i have had a talk with my serveradmin - and we do the upgrades in the near fruture--- well i try to find out more;; i need to know more about the system: i have to try the access of mysql in a console using the user name and password you set up? mysql -u <username> -p where <username> is your user name and we will be prompted for a password. well i need to try to find out more - i will do more investigations - and come back later. have a great day
  8. hello again - i try to work it out... can i run this sheme all data in two columns or should i put it in one column
  9. dil_bert

    a class for storing contact data -

    i will have a closer look at sqlalchemy which is shure a a pretty good library: https://docs.sqlalchemy.org/en/13/orm/tutorial.html and besides this i will have a closer look at peewee. have a great day
  10. hello dear Community, a class for storing contact data - Here is the code of a simple custom class which stores information about a person: import datetime # so we will use this for date objects class Person: # this is it - this is the class def __init__(self, name, surname, birthdate, address, telephone, email): self.name = name self.surname = surname self.birthdate = birthdate self.address = address self.telephone = telephone self.email = email def age(self): today = datetime.date.today() age = today.year - self.birthdate.year if today < datetime.date(today.year, self.birthdate.month, self.birthdate.day): age -= 1 return age person = Person( "Joe", "Doe", datetime.date(1952, 4, 22), # year, month, day "No. 1444 Short Street, Munich", "555 4564444444444444 0987", "joe.doe@example.com" ) print(person.name) print(person.email) print(person.age()) i want to store the data in a database. background: We start the class definition with the class keyword, followed by the class name and a colon. i think it is not bad to list any parent classes in between round brackets before the colon, but this class doesn’t have any, so i can leave them out. Inside the class body, we ve got two functions – these are our object’s methods. 1. The first method: is called __init__, which is a special method. When we call the class object, a new instance of the class is created, and the __init__ method on this new object is immediately executed with all the parameters that we passed to the class object. The purpose of this method is thus to set up a new object using data that we have provided. The second method is a custom method which calculates the age of our person using the birthdate and the current date. i want to store the data in a db or in a file
  11. on a sidenote,. ... <?php if(function_exists('mysqli_connect')){ if(!($link = mysqli_connect('localhost','user','passwd','my_db'))){ die('could not connect: ' . mysqli_error($link)); } } else { die("don't have mysqli"); } echo 'connect successfully'; mysqli_close($link); [/CODE] well i guess that this is saying that 1 parameter was required, 0 were provided. and besides this we surely can say that there absolutly no error checking is being done before calling the function, it's blindly passing a variable that was collected. interesting: This actually makes sense, given i am probably failing to connect to mysql. What we don't see is validation that the credentials work, & i can connect. one option would be to ssh to the php server, & then connect over the cli to mysql. Otherwise, we´re just guessing. Above all - we can say that there probably is no pathing issue. honestly - there are serious doubts that wordpress has a pathing issue, or this is anyway code related. [CODE]active_connections 18446744073709551563 is this number normal? If not how can I reduce it? [/CODE] If this were the cause of the issue, none of the sites would work, assuming they are all using the same mysql server. The quickest way to reduce it would be to reboot the server. Just posting the number alone doesn't tell us enough. best thing would be to verify with netstat. If they are active connections, then i probably should have a closer look a the proper firewall rules in place blocking outside connections. hmm - i will have a closer look at all the condidions and settings - and will come back and report all the findings. have a great day
  12. hello dear Requnix - first of all - many many thanks for the quick reply great to hear from you. Well yes: i am going to check all the environment things - and i also want to replace "localhost" with 127. 0.0.1 btw: I have Linux Server. Apache 2.4.10, PHP Version 5.6.39 and mysqlnd 5.0.11-dev - 20120503 - installed. There are several wordpress website running on server. In the phpinfo(); under mysqlnd section there says; active_connections 18446744073709551563 is this number normal? If not how can I reduce it? and sorry - for the bit of confusing thread-posting with the issues. I am in need of help and i try to sort out things here. regards -
  13. hello dear all - have issues while connecting to the mysql-db during the installation process of a wordpress. i have a root-server that is administered by my friend. i can configure all the things that need to be configured with Webadmin: in other words: on the webmin-frontend (that is the area i have to controll and configure all the stuff on the server') i get back the results -error in establishing the db-connection while running the installation script of wordpress version 5.2 what else did i try out: i run a extra script to test the connection - and i got back this here... Warning: mysqli_connect(): (HY000/2002): No such file or directory in /sites/www.mysite.de/tests.php on line 3 Warning: mysqli_error() expects parameter 1 to be mysqli, boolean given in /sites/www.mysite.de/tests.php on line 4 could not connect: yyyyyy see the script: <?php if(function_exists('mysqli_connect')){ if(!($link = mysqli_connect('localhost','user','passwd','my_db'))){ die('could not connect: ' . mysqli_error($link)); } } else { die("don't have mysqli"); } echo 'connect successfully'; mysqli_close($link); the guess: the paths seem to be a problem - in the config by the way: the character-code is 1252 ANSI L well i want to do more tests - on the webmin-frontend (that is the area i have to controll and configure all the stuff on the server') USE yourdatabase; SHOW GLOBAL VARIABLES LIKE 'PORT'; SHOW GRANTS FOR CURRENT_USER; i get back the following results: Failed to execute SQL : SQL USE 'name of my db'; SHOW GLOBAL VARIABLES LIKE 'PORT'; SHOW GRANTS FOR CURRENT_USER; failed : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''name of my db'; SHOW GLOBAL VARIABLES LIKE 'PORT'; SHOW GRANTS FOR CURRENT_USER' at line 1 well what can i do now
  14. hello again - i have gathered some more infos and insights due to some more tests. see the following data: - the outcome of a testscript: Warning: mysqli_connect(): (HY000/2002): No such file or directory in /sites/www.mysite.de/tests.php on line 3 Warning: mysqli_error() expects parameter 1 to be mysqli, boolean given in /sites/www.mysite.de/tests.php on line 4 could not connect see the script: <?php if(function_exists('mysqli_connect')){ if(!($link = mysqli_connect('localhost','user','passwd','my_db'))){ die('could not connect: ' . mysqli_error($link)); } } else { die("don't have mysqli"); } echo 'connect successfully'; mysqli_close($link); some ideas: the paths seem to be a problem - in the config by the way: the character-code is 1252 ANSI L any idea and help - i look forward to hear from you regards
  15. probably the paths are not correct... /** Absolute path to the WordPress directory. */ if ( ! defined( 'ABSPATH' ) ) { define( 'ABSPATH', dirname( _FILE_ ) . '/' ); } [/CODE] see here the errors [CODE]Warning: mysqli_connect(): (HY000/2002): No such file or directory in /sites/www.mysite.de/testconnection.php on line 2 Warning: mysqli_error() expects exactly 1 parameter, 0 given in /sites/www.mysite.de/testconnection.php on line 4 Could not connect: [/CODE] i think that i have to understand the errors...
×

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.