clankill3r Posted October 26, 2011 Share Posted October 26, 2011 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. I try to insert something in the historer_sites tabel. This is the structure of the tabel: 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 More sharing options...
AyKay47 Posted October 26, 2011 Share Posted October 26, 2011 unless insertQuery is another custom function of yours.. you should have $result = mysql_query($query) or die(mysql_error()); instead, I added the mysql_error() for debugging purposes Link to comment https://forums.phpfreaks.com/topic/249848-cant-insert-anything-in-database/#findComment-1282417 Share on other sites More sharing options...
clankill3r Posted October 26, 2011 Author Share Posted October 26, 2011 yes that was a custom function, looked over it to show here. Anyway it works now, i just switched hosting and have a new phpmyAdmin now and i'm a bit unused to the new look, i think i looked over it the first time. Thanks for your input. Link to comment https://forums.phpfreaks.com/topic/249848-cant-insert-anything-in-database/#findComment-1282418 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.