PDA

View Full Version : Heh. Slight problem!



Newsie
08-01-2006, 10:59 AM
Well! I'm trying to make that php alert thing. I TRIED to set it up. BUT FAILED. So can anyone point out where I have gone wrong?

http://grid.dailydns.com/~bwctc/alert2/alert.php

http://grid.dailydns.com/~bwctc/alert2/alert2.php

alert.php


<?
$dbName = "-";
$dbUser = "-";
$dbPass = "-";
// Connect
mysql_connect ("localhost", "$dbUser", "$dbPass");
mysql_select_db ("$dbName");
// Get Alert
$alertQuery = mysql_query("SELECT * FROM alert WHERE active='Y'");
if(mysql_num_rows($alertQuery) =="1"){
$alertData = mysql_fetch_array($alertQuery);

if($_COOKIE[$alertData[ID]] !="Y"){
$y = "Y";
setcookie($alertData[ID], $y);
Echo"
<script language='javascript'>alert('$alertData[message]');</script>";
}
}

Echo"<META HTTP-EQUIV='refresh' content='60;URL=alert.php'>";
Echo"$_COOKIE[$alertDataID]"
?>

alert2.php


<?
$dbName = "-";
$dbUser = "-";
$dbPass = "-";
// Connect
mysql_connect ("localhost", "$dbUser", "$dbPass");
mysql_select_db ("$dbName");
switch($_GET['act']){
default:
$alertQuery = mysql_query("SELECT * FROM alert WHERE active='Y'");
if($alertData[message] !=""){
$Var ="<u>Current Active Alert</u>: $alertData[message] [<a href='alert.php?act=deactivate'>Deactivate</a>]";
}
Echo"<center><b>Alert Script Control Panel</b></center>
<u>NOTE:</u> You can only have one alert at one time. Once you want people to
stop being alerted, you will have to deactive it below. Creating a new alert
will delete the old one.<br>

$Var

<hr width='100%' height='1' color='#000000' shade='no'>

<form method='post' action='alert.php?act=create'>
Message:<br>
<textarea name='message' cols='30' rows='6'>Keep the message short</textarea><br>
<input type='submit' value='Create'>
</form>";
break;
case"create":
$message = "From your sites name DJ: ". $_POST['message'];

if(empty($message)){
Echo"<b>Error:</b> Please fill out the message.";
exit;
}
mysql_query("UPDATE alert SET active ='N'");
mysql_query("INSERT INTO alert (message,active) VALUES ('$message','Y')");

Echo"<b>Alert Added Sucessfully</b><br>
All other alerts have been deactivated. All users will recieve this alert
once, until you deactivate it.";
break;
case"deactivate":
mysql_query("UPDATE alert SET active ='N'");
Echo"<b>Alerts Deactivated</b><br>
All previous alerts have been deactivated.";
break;
}
?>

Reputation will be awarded!

Tomm
08-01-2006, 11:00 AM
Check your database info :)

Newsie
08-01-2006, 11:02 AM
Hmm... Tom. You said to turn of something. How do you do that?

Tomm
08-01-2006, 11:10 AM
You cant turn it off you need you server admin to turn it off.

Newsie
08-01-2006, 11:12 AM
Could you take a look because its exactly the php that you put on the other thread.

Robbie..
08-01-2006, 11:19 AM
Make this line:

if(mysql_num_rows($alertQuery) =="1"){
Say

if(@mysql_num_rows($alertQuery) =="1"){

Newsie
08-01-2006, 11:26 AM
Well it kind of works, but the alert send thing isn't working. Anyway reputation added.

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