Log in

View Full Version : php coding is this correct



Jamie.
07-04-2006, 04:55 PM
mysql_close($ms);

does that work or is it wrong :s

timROGERS
07-04-2006, 04:57 PM
Yeah, as long as that variable is the connection handle.

Jamie.
07-04-2006, 05:20 PM
but i keep getting a error:
Warning: mysql_close(): supplied argument is not a valid MySQL-Link resource in /home/habbotea/public_html/djp/bannedsongs.php on line 58

here is coding:

<? session_start();

include 'database.php';

$ip = $_SERVER['REMOTE_ADDR']; //get the ip of the current user

if(!isset($_SESSION['session_username']) || empty($_SESSION['session_username']) || $ip!= $_SESSION['session_ip']) {

//if the username is not set or the session username is empty or the ip does not match the session ip log them out

session_unset(); //clears firefox

session_destroy(); //clears IE

die("You are not logged in - Please Log In"); }

include("ol.php");?><body bgcolor="#3366FF">

<p><font face="Verdana" size="1"> Below Are A List Of Songs That Have Been Banned By The Administrator.<br>
<b>Please Do Not Play Any Of These Songs Or You Will Be Issued With A Formal Ban By One Of Our Administrators !</b>

<? if($_SESSION['session_level'] == "1") { ?>

</font><font face="Verdana" size="1"><br><a href="?action=delete">Delete All</a>

<? } ?>

<?

$query = mysql_query("SELECT * FROM `bannedsongs` ORDER BY `id`");

while($result = mysql_fetch_array($query)) {

$Song = $result["Song"];

$From = $result["From"];

$Long = $result["Long"];



echo "<p><b>Song: $Song </b>has been banned<br><b>Banned From:</b> $From<br><b>For: </b>$Long</b><br><hr color='#000000' size='1'><br>";



if($action == "delete") {

$delete = mysql_query("TRUNCATE TABLE `bannedsongs`");

echo "All Banned Songs In The System Have Been Deleted.";



}

}

mysql_close($ms);

?>

</font> </font> </td>

</tr>

</table>

</td>

</tr>

</table>

</body>

</html>

Edit: 58th line:
mysql_close($ms);

Nick.
07-04-2006, 06:05 PM
Does it means the table doesn't exist or isn't setup properly?

ClubTime
07-04-2006, 06:14 PM
i think it means the table does not exist. what panel is it?

Tomm
07-04-2006, 06:18 PM
I cant see to see where your connection to the DB is.. Could you post database.php please.

Jamie.
07-04-2006, 08:29 PM
d/w, fixed now :D i deleted that bit and it works clever me

Tomm
08-04-2006, 07:08 AM
d/w, fixed now :D i deleted that bit and it works clever me

I wouldent recomend deleting it.

Jamie.
08-04-2006, 07:52 AM
I wouldent recomend deleting it.
lol :) works :s

Want to hide these adverts? Register an account for free!