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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.