Jump to content

[SOLVED] Database not updating


BillyBoB

Recommended Posts

I have a feeling that this error is related to the php. I have an ajax blog system that I am building completely on one page(without reloading). I am currently on the edit system. When you try to edit firebug shows the variables being passed but it never gets set into the database.

 

Heres the code:

<?php
require_once("objects.php");

$dBase = new Database("Blog");
$dBase->connectDB("user","pass");

$fSql = mysql_query("SELECT * FROM `Entries` WHERE `id` = '$_POST[EntryID]'") or die(mysql_error());
$fData = mysql_fetch_array($fSql);

$uSql = mysql_query("SELECT * FROM `Users` WHERE `id` = '$fData[userid]'") or die(mysql_error());
$uData = mysql_fetch_array($uSql);

if($uData['SecurityCode']!=$_POST['SecurityCode']) {
echo("false");
}else{
$lSql = mysql_query("UPDATE `Entries` SET `title` = '$_POST[title]', `message` = '$_POST[text]' WHERE `id` = '$fSQL[id]'") or die(mysql_error());
echo("true");
}
?>

 

The site is currently at http://dreamshowstudios.net/development/Blog/index.php login is: Admin - 1234. Any help is greatly appreciated.

Link to comment
https://forums.phpfreaks.com/topic/149368-solved-database-not-updating/
Share on other sites

Shouldn't be in the db class. I think it shuts the site down if its not working.

 

<?php
class Database {
var $database = '';
var $debug = '';
var $db = '';
var $connected = 0;

function Database($database) {
	$this->database = $database;
}

function connectDB($username, $password) {
	if($this->connected==0) {
		$this->db .= mysql_connect("localhost",$username,$password) or die("Unable to connect to the database server. The username or password may be incorrect. Please reload this page. If you are viewing this page multiple times please contact the Admin.");
		$this->db .= mysql_select_db($this->database) or die("Unable to locate the database. The database name may be incorrect. Please reload this page. If you are viewing this page multiple times please contact the Admin.");
		$this->connected = 1;
		unset($this->db);
	}
}
}
?>

 

The weirdest thing is that it returns the value of true.... like it sent to the database but it totally didn't...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.