I made a class for another site I was playing around with that would echo the information in a database and what worked fine.
But here is my deal...
class echoME{
var $host = localhost;
var $login = "login";
var $pass = "pass";
var $database = "db";
function insert($name, $url, $perma) {
//Action - 0 = INSERT, 1 = Delete,
$con = mysql_connect($this->host, $this->login, $this->pass);
if (!$con) { die('Could not connect: ' . mysql_error()); }
mysql_select_db($this->database, $con);
echo "connected";
}
So when I do...
$variable = new echoME;
echo $variable->insert("test", "xxx.yyyyyy.zzz", "my-test");
The output will produce "connected".
But when I add the insert commands, I get nothing.
function insert($action, $name, $url, $perma) {
//Action - 0 = INSERT, 1 = Delete,
$con = mysql_connect($this->host, $this->login, $this->pass);
if (!$con) { die('Could not connect: ' . mysql_error()); }
mysql_select_db($this->database, $con);
echo "connected";
$d = date('d');
$sql = "INSERT INTO links (Name, URL, Perma, Dcount, Ycount, Tcount, Dstamp)
VALUES ('$name', '$url', '$perma', 0, 0, 0, '$d')";
if (!mysql_query($sql, $con)) { die('Error: ' . mysql_error()); }
echo "Added"
}
}
There's obviously something simple that I'm missing or I'm just not fully understanding classes. Can someone help me out?


Sign In
Create Account

Back to top










