0
<?php


	session_start();


	


	$_SESSION['title'] = $_GET['form_book_title'];


	$_SESSION['ISBN'] = $_GET['form_book_ISBN'];


	$_SESSION['qty'] = $_GET['form_book_qty'];


	$_SESSION['fName'] = $_GET['form_book_fName'];	


	$_SESSION['lName'] = $_GET['form_book_lName'];


	


if($_SESSION['ISBN']=="" || $_SESSION['title']=="" || $_SESSION['qty'] =="" || $_SESSION['lName'] =="" || $_SESSION['fName'] =="")


{


	echo "please fill out all the form fields";


	echo "<a href=\"sell.html\"> Go Back";


}else 





require_once("db_info.php");


$con = mysql_connect($localhost,$username,$pw);




    if(!$con) exit(mysql_error());

    



    $db_select = mysql_select_db("book",$con) or exit(mysql_error());



    $my_query = "INSERT INTO book_tbl (title)VALUES('".$_SESSION['title']."') ";

    $result = mysql_query($my_query) or die(mysql_error());

     

   

     while($row = mysql_fetch_array($result,$con))

            echo $row['title'];


mysql_close($con);


?>

Edited by zcj125: n/a

3
Contributors
7
Replies
8
Views
5 Years
Discussion Span
Last Post by simplypixie
0

can anyone tell me what are the possible mistakes may cause the error message "Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in"?n given in"?

i mean except the SQL syntax error...
i have been checking my SQL syntax, and i think it does not have problem.

Edited by zcj125: n/a

0

You are trying to get results from an INSERT query - you also need a SELCT query after your INSERT query to load results into your mysql_fetch_array and while loop

mysql_query("INSERT INTO book_tbl (title)VALUES('".$_SESSION['title']."') ");

$my_query = "SELECT title FROM book_tbl";
    $result = mysql_query($my_query) or die(mysql_error());
   

     while($row = mysql_fetch_array($result,$con))

            echo $row['title'];
}
0

wow, that makes sense
thank you simplypixie and rpv_sen

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.