Misomurai Posted April 1, 2013 Share Posted April 1, 2013 Hey, can someone tell me what's wrong with this code? My browser says that line 3 is wrong, but I'm not sure what's wrong about it. Thanks -------------------------------------------------------------------------------------------- <?php if ($_POST['submit1'] != ''){ $link = mysql_connect("$dbname", "$_library_lab", "$password"); if (!$link == FALSE) { $database = mysql_select_db('bookmark'); if ($database==TRUE){ $name = $_POST['name']; $book = $_POST['book']; $bookmark = $_POST['bookmark']; $shiori = $_POST['shiori']; $sql="insert into bookmark (name, book, bookmark, shiori) values('{$name}','{$book}','{$bookmark}','{$shiori}')"; $result = mysql_query($sql); if ($result == TRUE){ }else{ echo('DB insert Failure!'); } } mysql_close($link); } } ?> Link to comment https://forums.phpfreaks.com/topic/276370-connecting-mysql-to-php/ Share on other sites More sharing options...
trq Posted April 1, 2013 Share Posted April 1, 2013 The variables you are passing to mysql_connect(), wehere are they defined? And why the hell are they in quotes? ps: The mysql extension has been deprecated. All new code should be using mysqli or PDO. Link to comment https://forums.phpfreaks.com/topic/276370-connecting-mysql-to-php/#findComment-1422204 Share on other sites More sharing options...
Yohanne Posted April 1, 2013 Share Posted April 1, 2013 its okay for a beginner, to protice procedural coding like you show code above. and try to reconstruct your code or else use other way for insert. Link to comment https://forums.phpfreaks.com/topic/276370-connecting-mysql-to-php/#findComment-1422218 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.