Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8522339
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T07:05:17+00:00 2026-06-11T07:05:17+00:00

<?php function getMysqlConnection($host, $user, $pass, $database) { global $mysqli; global $Mysqlerror; $mysqli = new

  • 0
<?php

function getMysqlConnection($host, $user, $pass, $database) {
    global $mysqli;
    global $Mysqlerror;
    $mysqli = new mysqli('$host', '$user', '$pass', '$database');
    if (empty($mysqli->connect_errorno) == false) {
        $Mysqlerror = "true";
    } else {
        $Mysqlerror = "false";
    }
}

I have created a function as above which implement connection on given MySQL user credentials and I implemented this function by using

<?php
require 'myFunc.php';
getMysqlConnection("localhost", "wronguser", "wrongpass", " test");
echo $Mysqlerror;

Although i used wrong password and username the Mysqlerror is false . I also used or die function nothing happen

Warning: mysqli::mysqli(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /opt/lampp/htdocs/mysite/myFunc.php on line 5

Warning: mysqli::mysqli(): (HY000/2002): php_network_getaddresses: getaddrinfo failed: Name or service not known in /opt/lampp/htdocs/mysite/myFunc.php on line 5

I restarted lampp as usual it showed

Starting XAMPP for Linux 1.8.0...
XAMPP: Starting Apache with SSL (and PHP5)...
XAMPP: Starting MySQL...
Warning: World-writable config file '/opt/lampp/etc/my.cnf' is ignored
XAMPP: Starting ProFTPD...
/opt/lampp/share/lampp/alladdons: line 23: /opt/lampp/share/addons/: is a directory
XAMPP for Linux started.

Is the problem with my code or with my server some thing. How to fix it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T07:05:19+00:00Added an answer on June 11, 2026 at 7:05 am

    Problem is with this line.

    $mysqli = new mysqli('$host','$user','$pass','$database');
    

    Change it to

    $mysqli = new mysqli($host,$user,$pass,$database);
    

    In PHP variables within single quotes are not interpolated with their values.

    Check PHP’s variable parsing mechanism here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

PHP: function get_t_wrinkle_rel(){ global $mysqli; $q = $mysqli->query(SELECT * FROM t_wrinkle_rel ORDER BY t_wrinkle_name
The PHP function oci_connect (which connects to an Oracle database) just returns false if
fileA.php: requires function.inc.php and uses x() from that include file fileB.php: requires fileA.php User
Basic PHP function: //SOAP CALL function sayHello(){ $client = new SoapClient('http://Server:8080/MyClassService/MyClass?WSDL'); $response = $client->glassfishHello();
I have a simple PHP function that will grab information from a database based
I really like the PHP function strtotime(), but the user manual doesn't give a
I am using the PHP function mkdir($path, 0777) to create a new directory on
My php function function generateMenu($parent, $level, $menu, $utype) { global $db; $tree = array();
I am making a PHP function to return an array of a mysql database's
I have defined a php function: function my_function($text = '', $relative = false, $icon

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.