Jump to content

Hussam

Members
  • Posts

    63
  • Joined

  • Last visited

    Never

Everything posted by Hussam

  1. weird, the $_GET array is blank as I thought, I think the problem is that you are redirecting before sending the query: try to do it this way, redirecting after sending the query: if($error==''){ $sql="INSERT INTO replies (comment_id, reply, reply_create_time, reply_owner, reply_owner_email) VALUES ( '$reply_comment_id', '$reply', now(), '$name','$email')"; mysql_query($sql,$conn) or die(mysql_error()); header('Location: testimonials.php');
  2. ok, the problem now that its not collecting the variable from the array $_GET. Forget about the query and comment your code and put this line: <?php echo '<pre>'; print_r ($_GET); echo '</pre>'; ?>
  3. okay, move this line to the top of the page, right after the session_start(), $reply_comment_id = $_GET['comment_id']; I just want to collect the variable anyway if the form is submitted or not. then try these lines as they are (I am using the old one again): $sql="INSERT INTO replies (comment_id, reply, reply_create_time, reply_owner, reply_owner_email) VALUES ($reply_comment_id, '$reply', now(), '$name','$email')"; echo $sql; echo '<br />'; echo $reply_comment_id ;
  4. post this code now and try to reply to different comments and tell me what your getting: $sql="INSERT INTO replies (comment_id, reply, reply_create_time, reply_owner, reply_owner_email) VALUES ($_GET[comment_id], '$reply', now(), '$name','$email')"; echo $sql; echo '<br />'; echo $_GET['comment_id'];
  5. Well, at least we know what's wrong now, let me play with the code and come back to you.
  6. I am not sure why I can't edit this reply, but anyway, here is the correct syntax: $query = "SELECT * FROM table_name ORDER BY id DESC LIMIT 10"; cheers!
  7. True, that was stupid mistake I did, but not on purpose lol. I am sorry, I just have not written an SQL statement in ages since I no longer write raw php, I was just trying to help I will alter my post for others who have the same question. good luck.
  8. ok twilitegxa, lets deal with it piece by piece, each comment can have many replies, so far, this is correct. right? Now, we need two tables which you have already, and at least having these fields: comments ===> id, body. replies ===> id, comment_id, body. if you have a different database structure, let me know. the comment_id in the second table is actually the id in the first table to be able to pull only the replies that are related to that comment, so far everything should be fine. Now, are you getting the Insert part correct or not? if not, then lets deal with that first then we discuss the display page. try to print out the query and see if it worked or inserted or not using this code then see in the database if what you wanted to be inserted, was inserted. $sql="INSERT INTO replies (comment_id, reply, reply_create_time, reply_owner, reply_owner_email) VALUES ($reply_comment_id, '$reply', now(), '$name','$email')"; echo $sql; echo '<br />'; echo mysql_query($sql,$conn) ? 'yes' : 'no';
  9. okay twilitegxa, your question didn't make alot of sense to me lol, but I am willing to help you. Yes I see that the comment_id is sent, but you have got to name your fields better then this, its a mess lol. Anyway, here is what you need to do as the first step: Replace your SQL query with this one and tell me what you got: $sql="INSERT INTO replies (comment_id, reply, reply_create_time, reply_owner, reply_owner_email) VALUES ($reply_comment_id, '$reply', now(), '$name','$email')"; its pointless to have reply_id in your SQL insert statement because its set to auto increment. I thought at first that the reply is the father and the comment is the child, that's why I wanted you to show me your tables. good luck!
  10. Yes absolutely, this is how people learn, and it was good suggestion from you to follow the way you mentioned but new developers toying with OOP might find it a little bit confusing at first. For me I use "include" as an English word and "include()" as a function . cheers!
  11. True, that will work too, but I meant to answer his question which is not related to what your talking about, may be he is not using this approach. Anyway, lets end this debate lol, you got me wrong when I said include the function file and thought of the word "include" as a php function in php language not as a word in English language otherwise you won't be telling me about the redefining the function error problem, that's what started all this lol. cheers!
  12. I am not sure if I understood exactly what you are trying to say but you have to require this function __autoload() every time you use a class, however if you require the class file itself, then you don't need to, but its always good practice to do that just in case you forgot to require a certain class. Many php developers code their classes in a very complex way to push up all the complexity into the class and make the pages clean, therefor they have alot of classes interacting with each other may be in every class file (creating instances inside each other, inheritance, call their methods statically, ..etc) in this case you might forget to require certain class you used in a certain class file. good luck!
  13. Absolutely, I meant if you are concerned about declaring it twice which is not gonna happen if you use require_once('') then just include it where its important. at the end, we both agree that a function can't be declared twice and not a reasonable programmer on this planet can disagree lol, but if you use require_once() then you don't have to worry about that, you can go ahead and do that in all classes and pages, it won't hurt but it might slow the script a little bit to check if its required already or not each and every time.
  14. Not really, because a person who is using OOP approach in php should know better and use require_once(''); Anyway even if what you said was true (which is not) he can require it before using any class in a page or using any class in another class (at least). :-)
  15. I think the reason is that you need to add single quotes around the $URL variable in the SQL statements since its a string. try this: //Get the website address from the URL string $URL = $_GET[url]; if(mysql_num_rows(mysql_query("SELECT URL FROM hits WHERE URL = '$URL'"))>=1){ // Code inside if block if URL is already there mysql_query("UPDATE hits SET counter=counter+1 WHERE URL = '$URL'"); } // Else Insert new record else { mysql_query("INSERT INTO hits VALUES ($URL, , )"); mysql_query("UPDATE hits SET counter=counter+1 WHERE URL = '$URL'"); }
  16. The second option is more logical because the data may not be entered for whatever reason. I will actually send the data to the database first. then I will grab it again just to make sure lol, I am kinda nerd, then I will collect the data in an HTML format and put it in the message variable and send it to the email I need using mail() function. This example is from php.net and it works just fine: <?php // multiple recipients $to = 'aidan@example.com' . ', '; // note the comma $to .= 'wez@example.com'; // subject $subject = 'Birthday Reminders for August'; // message $message = ' <html> <head> <title>Birthday Reminders for August</title> </head> <body> <p>Here are the birthdays upcoming in August!</p> <table> <tr> <th>Person</th><th>Day</th><th>Month</th><th>Year</th> </tr> <tr> <td>Joe</td><td>3rd</td><td>August</td><td>1970</td> </tr> <tr> <td>Sally</td><td>17th</td><td>August</td><td>1973</td> </tr> </table> </body> </html> '; // To send HTML mail, the Content-type header must be set $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; // Additional headers $headers .= 'To: Mary <mary@example.com>, Kelly <kelly@example.com>' . "\r\n"; $headers .= 'From: Birthday Reminder <birthday@example.com>' . "\r\n"; $headers .= 'Cc: birthdayarchive@example.com' . "\r\n"; $headers .= 'Bcc: birthdaycheck@example.com' . "\r\n"; // Mail it mail($to, $subject, $message, $headers); ?>
  17. hmmm, I think since you have the template ready, you need to go with the tutorials in this site since you link the videos, but I don't believe that videos only can make you develop a good web site. www.phpvideotutorials.com good luck!
  18. try this: function __autoload($class_name) { $class_name = strtolower($class_name); $path = $_SERVER['DOCUMENT_ROOT']."/includes/_process/."{$class_name}.php"; if(file_exists($path)) { require_once($path); } else { die("The file {$class_name}.php doesn't exist."); } } I believe that you have to put this function in a file and include it in each and every class.
  19. use this SQL statement: $query = "SELECT * FROM table_name LIMIT 10 ORDER BY id DESC" if your id field is set to "Auto Increment" then you should get the most recent 10 records. I haven't tried it that way but give it a try and tell me what happens. good luck.
  20. depends on what kind of numbers you are looking for, use one of these functions: is_numeric($value); is_float($value); is_double($value); I am not sure if there is more, but these are good enough. you can use is_int($value) to check if the type of the variable is integer. good luck.
  21. Then you have to use frames and refer to this link: this is the html for creating the link: <a href="http://www.google.com/search?q=keyword">keyword link text here</a>
  22. I see you have '' in your first inserted value in your SQL insert statement. leave it blank (don't put nothing, not even quotes or comma) and insert only to the fields that are not auto increment, the comment_id should be set to auto increment in the database. good luck!
  23. I am not sure if I understood your question, but the comment_id should be set on "auto increment" in the database if you are inserting into comments table. tell me how many tables you have? I think its something similar to a blog, so you need to have two tabels: posts and comments or replies whatever the name you choose.
  24. I mean use that as a link, I suppose you know some html. good luck.
  25. http://www.google.com/search?q=keyword
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.