Cant able to update table from different database table mysql in php : <p>I cant able to Update my <strong>users</strong> table from different <strong>college</strong> table which is present in another <strong>main</strong> database. But my query running successfully on mysql but when I am trying to execute query using PHP it cant able to update the user database from the college database</p>

<pre><code>    UPDATE users 

     SET 

     student_name = ( SELECT main.college.Student_Name
                       FROM main.college
                       WHERE main.college.Enroll_No =  '123456'
                       LIMIT 1 ) 
      WHERE user_id =5
</code></pre>

<p>Above query successfully running on phpmyadmin. But in PHP cant able to Update the user table</p>

<pre><code>&lt;?php



         require_once('dbConnect.php');

            $sql = "UPDATE users \n"
                    . "\n"
                    . "SET \n"
                    . "\n"
                    . "student_name = ( SELECT main.college.Student_Name\n"
                    . " FROM main.college\n"
                    . "WHERE main.college.Enroll_No = '123456'\n"
                    . "LIMIT 1 ) \n"
                    . "WHERE user_id =5";
                   if(mysqli_query($con,$sql)){

                             mysqli_query($con,$sql);

                             echo 'successfully registered';
            }else{
                echo 'oops! Please try again!';
            }


     mysqli_close($con);

?&gt;
</code></pre>
