Jump to content

gizmola

Administrators
  • Posts

    5,945
  • Joined

  • Last visited

  • Days Won

    145

Everything posted by gizmola

  1. I don't see anything overtly wrong with your code. Check your original result set?
  2. As far as I can tell based on the information you provided you have all the pieces. I don't have time to look at the tutorial, and even if I did that wouldn't fix problems in your version of the code. You have to try things out, and debug it using things like $echo in your code to see what the value of variables are.
  3. Does the query return a result set? Also you used: foreach($row as $key => $value) Just use foreach($row as $value) and reference $value.
  4. Stay with your DESC query. Fetch all the rows in a loop into an array called rows. Set $rows = array_reverse($rows); foreach ($rows as $row) -- output $row.
  5. Where you query for the results, you need to have $pageid set to something. So before the query you need to have: $pageid = 1; You would change that value for each seperate page, so that the form and the value of $pageid variable match.
  6. I might do something like this: $posts = array(); $postid = '' //fetch results: while ($row = mysql_fetch_assoc($result)) { $attachment_name = $row['attachment_name']; unset($row['attachment_name']); if ($row['pid'] != $postid) { $postid = $row['pid']; $posts[$postid] = $row; $posts[$postid]['attachments']= array(); } if (!empty($attachment_name)) { $posts[$postid]['attachments'][] = $attachment_name; } } var_dump($posts);
  7. No worries You can mark topics solved with the button at the bottom if you would like to help us out.
  8. Your insert query does not even include page_id. It also seems that this is part of some ajax system. I'm not willing to get into all that with you, but at minimum change your query: mysql_query(" INSERT INTO comments(name,url,page_id,email,body) VALUES ( '".$arr['name']."', '".$arr['url']."', '".$arr['pageid']."', '".$arr['email']."', '".$arr['body']."' )"); In your comment form add a hidden field: For each different page you have you will need to use a different value, of course.
  9. I learned php in utero. I plan to shift 100% to Haskell coding by age 5 though.
  10. I understood your original question. What allows you to have multiple "groups" of comments and to keep them seperate is the use of the page_id value in the rows. As in your original code, you then need to have WHERE page_id = $pageid in your query. If you want to just do this manually, you can hardwire the page_id value into each page. You haven't shown the code that will actually INSERT a row into the comments table.
  11. Yes sure, although you'll have one giant line of emails. You probably want at least to do: $string .= "$email\n";
  12. What i'm saying is that your result set is going to be one where you have multiple rows for the same post/attachment when you have multiple attachments. As you fetch those rows, one solution is to create an array of posts, and that array could have an element that is an array of attachments. Your code needs to detect whether this is a new post or not. If it is not a new post, then you'll add to the array of attachements for that post.
  13. Just fetch them all into an array then foreach through it and write it to the file. $emails = array(); while ($row = mysql_fetch_assoc($res)) { $emails[] = $row['emails']; } foreach ($emails as $email) { // fwrite your $email }
  14. No, get the result set, read it in, and when you're parsing it, build the hierarchy in objects or arrays.
  15. This assumes that you have some system where "pages" of the site come out of a database and have an id number associated with them. Is that the case for your system?
  16. doddsey, That is how joins work. You get the product of the join. This is why it is called a "result set". Your code needs to handle the fact that the relationship includes a one to many.
  17. Yes, file or directory permissions and the apache configuration. You might even be hitting up against a symbolic link issue. Does this site have one or more .htaccess files? This is a configuration issue, it has nothing to do with the php code inside the script.
  18. I'm just trying to help you out. In the future, a screen shot, some code, an illustration, any of those things will help you greatly in trying to communicate your problem. There's a reason I'm the only person who replied --- your question was really vague. I couldn't tell whether you were talking about the eclipse UI, or your programs ui, or what. If it went away, then I guess that's ok, but things like that don't usually tend to fix themselves and come back eventually.
  19. It's not an easy discipline to master. It's always changing, and there's a lot of different interconnected technologies involved. Keep at it.
  20. Haha, holy smokes, talk about making life difficult for yourself.
  21. You missed the incredulity mixed with sarcasm that was part of my reply. Sorry, but you're not asking for programming help, you're asking for clairvoyance. My only useful observation is that the code is going to be run by the jvm, so eclipse should be irrelevant to your problem, even if you're hitting a button in eclipse to run it.
  22. This ^^^ Based on a lot of things that have come up in this thread, I share PFMaBiSmAd's concern that there are other problems. However, with that said, a crap host is a crap host, and as far as I'm concerned, very few shared hosting companies aren't crappy. There's just no way to provide good support to people who are paying $7/ month.
  23. Syntax is a very specific thing. You have to look carefully at things. This is what you have at line 38: $qry="SELECT * FROM troop WHERE login=('$_SESSION['SESS_LOGIN_NAME'])'"; That is not what I showed you. All you are trying to do is get php to interpolate (add the variables at runtime) into the string you are assigning to $qry. Usually you could just use the variable name: "Hello $name". Because this is an array element where you want to use the proper array key literal, that will not parse. If you tried: $msg = "Hello $_SESSION['SESS_LOGIN_NAME']"; you'll see that you get a parsing error from php. In order to allow the interpolation of the variable, you need to but a php block around it, so that it gets resolved and will work properly. This is just a quirk of the way php interpolation works. Some people try and get around this using concatenation, although personally i think the code is typically simpler and easier to read if you use interpolation. The php block, you should probably already know is "{ // php block here}". This is used in control structures all the time (if, then, else, while, switch, etc.). You did not use the block character, you used parens which makes php think you're trying to execute a function. This is why the parser blows up. Of course you weren't even that careful with the parens, because they need to go around the variable itself and have nothing else, and you have a paren that is outside the single quote literal you need for the sql statement. What the code needs to be is: $qry="SELECT * FROM troop WHERE login='{$_SESSION['SESS_LOGIN_NAME']}'"; I don't know any other way to say it other than, you have to be detail oriented or you're going to be flailing like this often. You have to understand the difference within php of using single quotes, double quotes, parens and braces, not to mention backtics, semicolons, and a slew of other special characters.
  24. Try reading my reply at the end of this thread, and see if that clears anything up: http://www.phpfreaks.com/forums/index.php?topic=223785.msg1579550#msg1579550
×
×
  • 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.