Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Undefined variable: connection in

Status
Not open for further replies.

matanzas

Technical User
Apr 15, 2006
184
CA
Can anyone give a bit of guidance please?
I am gettnig a
Warning: mysql_close(): supplied argument is not a valid MySQL-Link resource in...
as a result of the following
Code:
<?php require('../../Connections/connBSD.php'); ?>

<?php
// create query
$query = "SELECT welcome FROM users WHERE username = '$kt_login_user' limit 1";

// execute query
$result = mysql_query($query) or die ("Error in query: $query. ".mysql_error());
// see if any rows were returned
if (mysql_num_rows($result) > 0) {
    // yes
    // print them one after another
    echo "<table cellpadding=10 border=1>";
//    while($row = mysql_fetch_row($result)) {
//		while(list($id, $country, $animal)  = mysql_fetch_row($result)) { 
    while($row  = mysql_fetch_object($result)) { 
        echo "<tr>"; 
        echo "<td>".$row->welcome."</td>"; 
        echo "</tr>"; 
    }
    echo "</table>";
}
else {
    // no
    // print status message
    echo "No rows found!";
}
// close connection
mysql_close();
?>
Thanks
 
Your [tt]$kt_login_user[/tt] variable is not set, so your query is failing. Where do you define this variable? If it is coming from a previous page via a form, refer to it by referencing the array it should appear in: either $_POST or $_GET depending on the method the post was sent. If it is a session or a cookie thing, use $_SESSION or $_COOKIE arrays to look for the value. Your way expects register globals to be on, which is no longer true for newer installations of PHP, due to security issues with the setting being on.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top