Jump to content

Hussam

Members
  • Posts

    63
  • Joined

  • Last visited

    Never

About Hussam

  • Birthday 07/17/1980

Contact Methods

  • MSN
    pcplanet4tech@hotmail.com
  • Website URL
    http://tutorialtip.com/About_Me/
  • Yahoo
    pcplanet4tech@yahoo.com

Profile Information

  • Gender
    Male
  • Location
    Virginia Beach, VA

Hussam's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. using IP address is not a good idea because you know IP addresses change all the time, also you have sometimes more then one person using the same IP address. The other question, I believe you better stay away from Java Script as much as possible because some users might turn off Java Script. Good Luck!
  2. Yes that's exactly what I meant, perfect. sorry I was late lol. good luck.
  3. ok, I think this is a database question, but anyway: to show all products and the features simply you can use this simple query: $query = "SELECT * FROM products" To select only the products that a certain customer is using then you basically mean by that: each customer can select many product(s) each product can be selected by many customer(s) here you need to add another table named customer_product that has two fields: customer_id product_id they have the id's of the customers and the products attached to each other and attach the other two tables to them in your queries. the table should look like this after inserting some records: customer_id: 2 4 5 2 product_id: 5 1 2 1 means the customer number 2 took the products number 5 and 1 the product number 1 was taken by the customers numbered 2 and 4 I don't really know any tutorial that explains this, but I think I explained it clearly, if not then let me know what is hard to understand and I will explain it to you. Good luck!
  4. Yes you have to loop through all of the elements to fetch them all because mysql_fetch_array() fetchs only one row at the time.
  5. This way I think you better make a separate replies table like this: table: replies: id ---> the reply id itself, auto increment. base_comment_id ---> the id of the base comment. replyTo_id ---> has the id that it is a reply to it, or 0 if its a base comment. text ----> the reply's test I think this way you can have unlimited replies to each other and you can intend from VA to AK lol. I can't think more of it, its kinda confusing lol.
  6. I think you can't expect much answers from people with this kind of question: The code is missing alot of things as far as I am concerned, there should be a class file and other code seems to be missing, also try to put your code in php bbcode tags in the forum so we can see better. The first thing I can see wrong, is using methods of a class without instantiating an object from the class, unless you did that somewhere else in the code and didn't post it. $database->setQuery($query); $database->query(); good luck!
  7. This should be enough for these clumsy backticks to not to be used. I own you one Mchl.
  8. I doubt it if you can name a table "from", I think "from" is a reserved word in MySQL, therefore your example is not even right to begin with. Do you doubt this from your extensive knowledge of databases and in particular mysql? Please. Why don't you try it yourself. "create table `from`(test int primary key)". That's exactly why you would use ` because IT IS A RESERVED WORD. excuse me, my knowledge is not extensive in SQL, I have not written any SQL statement in ages, however, why would a reasonable programmer give a table such name? a reversed word? don't tell me that he ran out of words lol. This way he is forcing himself to use this ` in each and every statement in his SQL's which sucks. Anyway, you need to take care of millions of web sites that have their SQL's without ` and convience them all to rewrite their code or look for every piece of SQL in their code. good luck for those who want to put ` in their SQL, I promise I won't put any lol, in fact I don't even write SQL's but even if I have to, I won't because its ridiculous.
  9. your questions has been answered correctly, however your query will not work because its wrong. use this one: $query = "insert into orders (email, zip) values ('$purchase_email', '$zip')"; dont worry about the concatenation in this case, the query will work this way, no need to litter the code with quotes in this case. By the way, I love people who know how to ask the question like you did lol. good luck!
  10. I doubt it if you can name a table "from", I think "from" is a reserved word in MySQL, therefore your example is not even right to begin with. For the future, if this thing happens in the later versions of MySQL, people won't use it and it will fail because people will stick to the older version because their sites are coded without ` so they are not going to go to each and every SQL statement and add this ` to each and every field and table, this is ridiculous. Even if they did that, then they will be repeating the same mistake with XHTML 1.1 and XTHML 2.0 cheers!
  11. I don't think that they will require that in the future, otherwise a huge amount of sites won't work. this ` exists in the top left of the keyboard, next to the key 1!, right under the Esc key.
  12. your welcome twilitegxa, any time cheers!
  13. okay guys, the problem is solved and everything was tested and its all working fine on the server. I had to change the names of the fields a little bit, I like to follow the conventions. reply_id in the replies table was changed to id comment_id in the user_comments table was changed to id both of them are auto increment and primary key's Now the problem was: the condition on top if (isset($_POST['submit'])) this condition makes the page instantiate the values AFTER the submission not before. after the submission there is no GET values. so I added the GET value to the action attribute of the form therefore I have the GET values anyway, if the form is submitted or not. and that won't be a problem after the submission because there is redirection anyway. the code should be like this: <?php $comment_id = $_GET['comment_id']; // //echo $comment_id; // //exit(); //connect to server and select database $conn = mysql_connect("localhost", "webdes17_twilite", "minimoon") or die(mysql_error()); $db = mysql_select_db("webdes17_testimonials", $conn) or die(mysql_error()); if (isset($_POST['submit'])) { //create and issue the first query $name=mysql_real_escape_string($_POST['comment_owner']); $email=mysql_real_escape_string($_POST['comment_owner_email']); $reply=mysql_real_escape_string($_POST['reply']); $comment_id = $_GET['comment_id']; $error='';//initialize $error to blank if(trim($name)=='' ){ $error.="Please enter your name!<br />"; //concatenate the $error Message with a line break } if(trim($email)==''){ $error.="Plese enter your e-mail address!<br />"; } elseif (!preg_match("/^[_\.0-9a-zA-Z-]+@([0-9a-zA-Z][0-9a-zA-Z-]+\.)+[a-zA-Z]{2,6}$/i", $email)) { $error.="The e-mail you entered was not valid!<br />"; } if(trim($reply)=='' ){ $error.="Please enter your reply!<br />"; //concatenate the $error Message with a line break } if($error==''){ $sql="INSERT INTO replies (comment_id, reply, reply_create_time, reply_owner, reply_owner_email) VALUES ( '$comment_id', '$reply', now(), '$name','$email')"; mysql_query($sql,$conn) or die(mysql_error()); header('Location: testimonials.php'); // mysql_query($sql,$conn) or die(mysql_error()); } else{ echo "<div class=error><span style=color:red>$error</span><br /></div>"; } } else { $name= ''; $email= ''; $reply= ''; } ?> <form name="comment" id="comment" onsubmit="return validateFormOnSubmit(this)" action="reply.php?comment_id=<?php echo $comment_id; ?>" method="post"> <table border="0" cellspacing="0" cellpadding="5" width="662" class="style2"> <tr> <td align="left"><label for="name"> Name:</label></td> <td> <div class="c2"><input type="text" name="comment_owner" id="comment_owner" size="30" value="<?php echo $name; ?>"/></div></td> </tr> <tr> <td align="left"><label for="email">E-mail:</label></td> <td> <div class="c2"><input type="text" name="comment_owner_email" id="comment_owner_email" size="30" value="<?php echo $email; ?>"/></div></td> </tr> <tr> <td align="left"> <label for="reply">Reply:</label></td> <td> <textarea name="reply" id="reply" rows="5" cols="30" value="<?php echo $reply; ?>"></textarea></td> </tr> <tr> <td colspan="4"> <div class="c1"><input name="submit" type="submit" value="Submit" /> <input type="reset" name="reset" id="reset" value="Reset" /></div></td> <td width="2"></td> </tr> </table> </form> not very clean but tested and working! good luck!
×
×
  • 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.