<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>The Book Center</title>


                include('header.html');	//shtohet pjesa e kodit qe gjendet ne fajllin header.html
  // ne variablat perkatese ruhen vlerat perkatese qe vijne nga fajlli paraprak

//ne qofte se njera nga kto variabla eshte e shprazet d.m.th. nuk kan ardh vlera nga fajlli paraprak nxiret mesazhi me poshte
if (!$bookid || !$title || !$datereal || !$cost || !$pages || !$genderid || !$pubhouseid)
     echo 'You have not entered all the required details!<br />'
          .'Please <a href=addbook.php>go back</a> and try again.';
  $bookid = doubleval($bookid);	//variabla e mer vleren si double
  $title = addslashes($title)	//variables i shtohen slash simbole ("/") qe mos te kete pengese me vone me querin kur do e shkrujm
  $datereal = addslashes($datereal); //...
  $cost = addslashes($cost);	//...
  $pages = addslashes($pages);	//...
  $genderid = doubleval($genderid);	//...
  $pubhouseid = doubleval($pubhouseid);	//...

@ $db = mysql_connect('localhost', 'root');	//krijohet lidhja me serverin

  if (!$db)	//nese $db variabla eshte null d.m.th nuk eshte lidhur me bazen atehere hyn ne if dhe e paraqet mesazhin me poshte:
     echo 'Error: The database connection fail.  Please try again later!';

mysql_select_db('bookcenter');	//selektohet databaza 'bookcenter'
//ne variablen $query, ruhet nje string vlere qe do te perdoret si query per te futur te dhena ne tabelen book
  $query = "insert into book values 
            ('".$bookid."', '".$title."', '".$datereal."', '".$cost."', '".$pages."', '".$genderid."', '".$pubhouseid."')";
  $result = mysql_query($query);	//ekzekutohet query ne databaze dhe rezultati ruhet ne variablen $result
  if ($result)	//nese eshte ekzekutuar me sukses dhe kemi ndonje vlere ne var &result, atehere...
      echo  mysql_affected_rows().' BOOK was inserted into database.'; //... printojme numrin e reshtave qe jane shtuar (qe zakonisht eshte 1)
 <P><b>Your entry has been added.</b> Would you like to
<a href="addbook.php">add another?</a> Or just <a href="login_admin1.php">go Back!</a></p>


echo "<h1 align=center>The BOOK Collection</h1>";

//make the database connection
@ $db = mysql_connect('localhost', 'root');

  if (!$db)
     echo 'Error: Could not connect to database.  Please try again later.';


//create a query
$sql = "SELECT * FROM book";
$result = mysql_query($sql);

print "<table border = 3 align = center>\n";

//get field names
print "<tr>\n";
while ($field = mysql_fetch_field($result)){
  print "  <th>$field->name</th>\n";
} // end while
print "</tr>\n\n";

//get row data as an associative array
while ($row = mysql_fetch_assoc($result)){
  print "<tr>\n";
  //look at each field
  foreach ($row as $col=>$val){
    print "  <td>$val</td>\n";
  } // end foreach
  print "</tr>\n\n";
}// end while

print "</table>\n";



Recommended Answers

All 7 Replies

See line 23.

maybe php version ?

you have missed semicolon in line 31.

commented: good spot +5

thx to all ;)

Mark as solved if your problem solved

You have missed a semicolon at line 31 and you should re-write your code with the latest PHP my be this will help ..
for any help in PHP please make a visit at http://php-mechanic.blogspot.com

where can i mark couse is soved ! this is my first post ! thx

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.