Jump to content

can't insert anything in database


clankill3r

Recommended Posts

MySQL server version: Serverversie: 5.1.57

---

I'm quite new so i meight explain unnecessary things..

My hosting only allows a limited amount of databases so i want to use tables in the p37827_db database.

schermafbeelding2011102u.png

schermafbeelding2011102n.png

 

I try to insert something in the historer_sites tabel.

This is the structure of the tabel:

schermafbeelding2011102w.png

 

My php shows errors cause first i had the login name wrong in the config.php and a error showed up.

Here's the code where i try to insert something in the database.

I echod, $url and $title and $date and they are correct.

 

However my database stays empty and no error shows up.

 

<?php

include '../../../config.php';
include '../../../lib.php';


$db = dbConnect();


$url = quote_smart($_POST['url']);
$title = quote_smart($_POST['title']);

$date = date("Y-m-d H:i:s", strtotime("now"));

//echo $url;
//echo $title;
//echo $date;

$query = "INSERT INTO historer_sites VALUES ('', '$url', '$title', '$date')";
$result = insertQuery($query);
$headerLoc = "test.php";


dbClose($db);

//header("Location: ../../../".$headerLoc."?msg=ok");
?>

 

here are some of the functions from my lib.php in case somone wondered how my dbConnect() looks like

function dbConnect() {
global $dbhost;
global $dbname;
global $dblogin;
global $dbpw;

$db = mysql_connect($dbhost, $dblogin, $dbpw) or die("could not connect to database".mysql_error());
mysql_select_db($dbname) or die("could not select database");
return $db;
}

function dbClose($db) {
mysql_close($db);
}

function quote_smart($value) {
if (get_magic_quotes_gpc()) {
	$value = stripslashes($value);
}
if (!is_numeric($value)) {
	$value = mysql_real_escape_string($value);
}
return $value;
}

 

hope all is clear

 

Link to comment
https://forums.phpfreaks.com/topic/249848-cant-insert-anything-in-database/
Share on other sites

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.