Jump to content
Larry Ullman's Book Forums


  • Posts

  • Joined

  • Last visited

  • Days Won


Everything posted by sonal

  1. Hi Antonio, thanks again for suggestions. (I have not yet solved the problem. The content on the site is displayed using old, simple query script.) mysqli_stmt_errono and mysqli_stmt_error are not showing any errors, because query is running properly. It shows title atleast. I also run the query multiple times in phpmyadmin through my hosting plan. It shows result correctly there. That's why it has been difficult to know the cause of problem. Anyway, thanks a lot for giving time to see all these things.
  2. Thanks for reply. I am using mysqli_stmt_bind_result as already shown in my code. And it displays $title value, but not displaying $content value. May be this is some kind of display problem. I am still getting mad about this.. May be I need to use something different than "%s " in printf function. But why then echo is not working as well? How can I print error from prepared statements in this condition?
  3. I am trying to update my scripts using prepared statements. (Till now I was exercising regular queries.) My updated scripts work very well on local host, but gives hard times on live site. (I have created a live site just to know and practice how things work.) The following code prints only title of the article, while article content is not displayed. I tried to check different print statements, checking column names number of times and checking syntex of binding result set. But still not come up with the reason. (I have changed table and column names here. The live site is www.myreadinglog.net. This script is first two links on left bar.) if((isset($_GET['gg'])) && (is_numeric($_GET['gg']))) { //from a.php $a = (int)$_GET['gg']; //Typecast gg. } else { //No valid Id, kill the script. echo '<p> This page has been accessed in erro.</p>'; include('includes/newf.html'); exit(); } //Make a prepared statement query to select content for the given article ID: $q = "SELECT qt, qon FROM comma WHERE a = ? LIMIT 1"; //Prepare the statment, assigning result to a variable: if($stmt = mysqli_prepare($dbc, $q)) { //bind variable to query's placeholder: mysqli_stmt_bind_param($stmt,'i', $a); //Execute the statement: mysqli_stmt_execute($stmt); //Bind result variables: mysqli_stmt_bind_result($stmt, $title, $content); //store result: mysqli_stmt_store_result($stmt); if(mysqli_stmt_num_rows($stmt) > 0) { //if statement execution returns any row, then //fetch value and display: while(mysqli_stmt_fetch($stmt)) { echo "<big><b>$title</b></big>\n"; //This value is printed correctly. //echo nl2br($content); printf("%s\n", nl2br($content)); //But this value is not being printed. } } else { echo "There is no content here."; } //close statment: mysqli_stmt_close($stmt); } //End of IF($stmt).
  4. Thanks for reply. But here I need to keep just one text input, which can be used to search book details based on either isbn, title or author. I want to put a search option just like that there in isbndb website.
  5. I'm trying to incorporate isbn db api in a php script. With the api and a key, it is easy to get a book detail either by isbn or title or author. I want to give a search box where user can enter either title, author or isbn and the script should return related items. I don't understand how to incorporate all 3 different searches in a single form. Following code return either one, not all 3 of them. if(isset($_GET['submitted'])) { if(!empty($_GET['searchterm'])) { $isbnQuery = $_GET['searchterm']; //searchterm. Is it title, isbn or author? $isbnTitle = $_GET['searchterm']; //same searchterm is assigned to title, but if used this way then it won't load proper xml file from isbn db api. } //$isbnData is xml file. //$isbnQuery is the isbn number you are interested in. $isbnData ="http://isbndb.com/api/books.xml?access_key=mk&index1=isbn&results=details&value1=$isbnQuery"; $isbnTitles = "http://isbndb.com/api/books.xml?access_key=mk&results=details&index1=title&value1=$isbnTitle"; $xmlData = simplexml_load_file($isbnData) or die("Error"); //load xml file according to received searchterm. //display data. } else { //show form: <form name="isbn" method="get" action="isbn.php" accept-charset="utf-8"> <p><valign = "center"><label for "searchterm">Enter title, author or ISBN to select your book.</label></p> <p><valign = "center"><input type="text" size="30" name="searchterm" value=" " /> <input type="submit" name="submit" value="Search" /> <input type="hidden" name="submitted" value="TRUE" /> </form> How to check which xml file is loaded? How to determine whether the user has entered isbn, title or author? There is only one text input on the form which can accept either isbn, title or author(all of which are strings types). So I can't figure out what to check and how to check?
  6. I'm trying to learn performing boolean search from chapter 6. I want to apply search on 2 tables: book_name column of book_master has FULLTEXT index. book_review column of book_trn has FULLTEXT index Following query gives error : Incorrect arguments to MATCH SELECT book_name, book_review FROM book_master b, user_book_trn t WHERE b.book_id = t.book_id AND MATCH(book_name, book_review) AGAINST('WISE BROWN') how to use columns from different tables in a fulltext search query?
  7. thanks. I'm going to try ip address check. I'm keeping poll open, and don't want users to register or log in for this poll. I'm trying to learn and practice these things.
  8. I'm trying to make a poll script, where users can select an answer for a particular question. How to avoid multiple answers from the same user? I tried to set a cookie in the questions.php page which displays questions and answers. Then trying to access that cookie in submitanswer.php page, to run it if(!isset($_COOKIE['poll']) { // update the answer counting. } else { echo "only one answer" }. But this is not working. The cookie is always set as it is coming from the previous page, in this scenario. How can a cookie be helpful here? Or is there anything else I need to know/do? thanks
  9. If I do as following: after running query, $row = mysql_fetch_row($r) echo $row[1] //index for name. and then loop things... The loop misses out first record..
  10. I have a query which retrieves member's name and books he/she read. The query returns name of the member, book title and book author. I want to print member name only once, and then a table with books names and authors in it. if(mysqli_num_rows($r) > 0 ) { //Here somewhere I need to print member name. But query result is not yet found. echo '<table align="center" cellspacing="5" cellpadding="5" width="75%"> <tr> <td align="left"><b>'. $t1 .'</a></b></td> <td align="left"><b>' . $a1 .'</a></b></td> </tr>'; while($row = mysqli_fetch_row($r)) { // Is there anything which can hold $membername = $row[1]...But how to print it above the table? //How can I print the name only once? echo '<tr> <td align="left">' . $row[6] . '</td> //book title <td align="left">' . $row[7] . '</td> //author }
  11. Yes, I now know that path is from the file "index.php" to "default.css". So I gave it that, and it was not working. So I used the whole absolute path. Even that did not worked. Then I transferred my css and its related files into a different folder, than "includes" where my header file resides. And again updated link with "css/default.html" . That did not work either. Now I transferred all css stuff into parent folder, with index file. Updated link as "href="default.css" , and it shows the format. Well, I think It should work before when files were separate... Any way, thanks again for your reply...
  12. Josee, It worked yesterday on my localhost. But I tried to upload all related files, and updated the codes as well on live site. But it doesn't show the formatting. I also tried to use absolute path in <link> element. But it's not working. I don't know why. My live sitename is : www.myreadinglog.net (I have not included new formatted header to any other pages, except the homepage.) thanks in advance..
  13. Thank you very much, Josee. It worked for me. The last line of your reply, "And the path in the < link > element is from "index.php" to "css_main.css", not from "header.php" to "css_main.css"." showed me the correct way to link that css file. I was doing the other way, showing the path from my header file. I also got the basics of CSS in just one line of your answer, " create different formatting styles for all the different HTML elements". That's so great! Thanks again for taking time to elaborate the answer.
  14. I try to modularize my site with header and footer templates of a css file. When I link a css file in my header file, it does not show the format/style. But when I copy-paste entire CSS code into head part of the header file, then I can see the style and formatting applied to the index page. ( I make sure that link and paths are correct, and file exists.) But I don't know CSS yet. Second thing I want to know is, How can I apply different CSS parts in different pages? I mean my index page shows an introductory text, but login and registration page requires to show forms. Do I apply the CSS file again in those pages?
  15. I want to register for Larry's newsletter through this forum. I tried to enter my name and email twice. Upon submitting, it says that I need to confirm the link in my email. But I am not receiving that email. I checked my spam mails too. Please register me. Thanks
  16. Trying to figure out a point about view: As far as I understood, I can write a complex query in a view, which can generate large amount of data. And then, I can write a smaller query on that view? Am I correct? Please let me know.
  17. Thank you very much, Antonio. I'll figure out how I can go further. I'll be back with my finished page, and if not, then more questions.
  18. I hope I'm posting in right place. I'm trying to develop a website, where families can make their reading logs. My concept is, one of the parent gets registered to the site. Then he/she can add family members to his/her account. After that, they can make their reading log by adding book entries through the site. Each family member can have their own list of books, under their name. I'm trying to make tables for users and books. What I have come up with till now is as follows: Now my confusion is here: A user can register as an individual, where he/she won't have any record in users_details. A user as a family can have members in users_details tables. A parent can register as a family type user. He can make his own reading log, as well as his family member's reading logs too. I want to add and retrieve, each member's book details. I'm confused about parent_id value. I can keep that value as 0 for individual user, but what about a registering parent? I don't understand how to manipulate this in database and, even in php.
  19. I'm trying to add new records into database using ajax layer. I'm following the example given in the book. My php script works fine itself. But when I add ajax.js and add_client.js, the script does not give result. It seems like the script is not getting form values. I tried to print values after fields data, and the alert shows "This alert values shows "fname=null&lname=null&email=null" When I run the script, the php script goes into query failure part. But I can say, that php script is alright but it is working fine, when run without ajax parts. window.onload = init; function init() { var ajax = getXMLHttpRequestObject(); if(ajax) { if(document.getElementById('results')) { document.getElementById('client_form').onsubmit = function() { ajax.open('post', 'add_client_xml.php'); ajax.onreadystatechange = function() { handleResponse(ajax); } var fields = ['fname', 'lname', 'email']; for(var i = 0; i < fields.length; i++) { fields = fields + '=' + encodeURIComponent(document.getElementById(fields.value)); } var values = fields.join('&'); alert(values); This alert values shows "fname=null&lname=null&email=null"
  20. I'm happy that my site is up and running, thanks to Larry's book! I'm developing this site www.myreadinglog.net as I'm learning php+mysql. There is so much left to do and not all parts are complete, but as this is my site, I'm excited to say that it's working!
  21. <quote> As for your fatal error, it looks like you have your error handler function in an included file (configr.inc.php), but you are re-declaring it in the script displaying the error, or maybe it is in another include file. Basically, the error message is stating that you can't have two functions with the same name, even if it is the same function. Thanks a lot for the reply. I got the solution for "headers already sent" errors, and they are not showing up. But fatal error is still there. Yes, the error handler function is in included file, configr.inc.php. It is only declared in this file on line no 20.And then it is called to show errors through "set_error_handler" function in the same file, at line no. 53. It is not redeclared anywhere else. And this error shows up only in LIVE mode, ohterwise the script works fine in development mode. Thanks again
  • Create New...