Jump to content

speedy33417

Members
  • Posts

    80
  • Joined

  • Last visited

    Never

Everything posted by speedy33417

  1. Sorry. Your page should start kind of like this: [code]if (isset($_POST['txtCommentMessage'])) {        $message = $_POST['txtCommentMessage']; //validate message if needed //then... $query = "INSERT INTO comments (video_id, user_id, date, comment) VALUES ('$video_id', '$user_id', '$time', '$message')"; [/code] My example DOES require a database. In my case there's a registration required as well. In your case you don't need to store a user_id, but might want to store at least a nick name or full name instead. You need a database with a comments table and 5 fields at least: comment_id, video_id, nick_name, comment. Oops, you won't need video_id field until you have your videos in the database as well. Which I highly recommend! Hope this helps.
  2. I guess it wouldn't make a difference. I just happened to do it another way. Either case, something is off with the for statements...
  3. By the way this is the html code that I'm trying to achieve: [code]<div align="center">   <table width="740" border="0" cellpadding="0" cellspacing="0">     <tr>       <td valign="top" align="center"><span class="text1">           Name 1<br>           Name 2<br>           Name 3<br>           Name 4<br>           Name 5<br>       </span></td>       <td valign="top" align="center"><span class="text1">           Name 6<br>           Name 7<br>           Name 8<br>           Name 9<br>           Name 10<br>       </span></td>       <td valign="top" align="center"><span class="text1">           Name 11<br>           Name 12<br>           Name 13<br>           Name 14<br>           Name 15<br>       </span></td>       <td valign="top" align="center"><span class="text1">           Name 16<br>           Name 17<br>           Name 18<br>       </span></td>     </tr>   </table> </div> [/code] And for some reason I'm getting this: [code]<div align="center"> <table width="740" border="0" cellpadding="0" cellspacing="0"> <tr> <td valign="top" align="center"><span class="text1">Name 1<br>Name 2<br>Name 3<br>Name 4<br>Name 5<br>Name 6<br>Name 7<br>Name 8<br>Name 9<br>Name 10<br>Name 11<br>Name 12<br>Name 13<br>Name 14<br>Name 15<br>Name 16<br>Name 17<br>Name 18<br>Name 19<br>Name 20<br></span></td><td valign="top" align="center"><span class="text1"> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br></span></td><td valign="top" align="center"><span class="text1"> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br></span></td><td valign="top" align="center"><span class="text1"> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br></span></td><td valign="top" align="center"><span class="text1"> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br></span></td> </tr> </table> </div>[/code] Sorry. No line breaks...
  4. $total is the number of names pulled from the database. In our case it's 18. Sorry.
  5. I would suggest using a database to accomplish this and also to avoid having to create a page for every video file as well. With PHP and MySQL you can create a one page to display a user selected video and an add a comment feature. Here's something to get you started Form at the end of your page: [code] <form action="" method="post" name="frmAddComment" id="frmAddComment"> <div align="center"> <table border="0" width="420" cellpadding="0" cellspacing="0"> <tr> <td><span class="text1">Do you have a comment?&nbsp;&nbsp; </span></td> </tr> <tr> <td height="1"></td> </tr> <tr> <td><textarea rows="3" name="txtCommentMessage" class="form2"></textarea></td> </tr> <tr> <td height="5"></td> </tr> <tr> <td align="right"><input name="btnAddComment" type="submit" id="btnAddComment" value="Add comment"></td> </tr> </table> </div> </form> [/code]
  6. I'm having a little trouble with my for statements. My goal would be to display customer names in columns. Assuming I have 18 names to display in 5 columns, I display 4 names in the first 4 columns and the remaining 3 names in column 5. For some reason I'm getting a different result and all of my names are in one column, but my echoed html code is very weird! Here's the php code: [code]<?php $columns = 5; $columnsMinusOne = $columns - 1; $columnMax = ceil($total/$columns); ?> blah blah <div align="center"> <table width="740" border="0" cellpadding="0" cellspacing="0"> <tr> <?php for ($j = 0; $j < $columns; $j++) { echo "<td valign=\"top\" align=\"center\"><span class=\"text1\">"; if ($j == $columnMinusOne) $columnMax = $total - ($columnMax * $columnMinusOne); for ($i = 0; $i < $columnMax; $i++) { $counter = ($j * $columnMax) + $i; echo $cust_firstname[$counter] . " " . $cust_lastname[$counter] . "<br>"; } echo "</span></td>"; } ?> </tr> </table> </div> [/code] $column is the number of columns $columnMax is the number of names to be displayed in a column $counter is calculated on the fly and should go from 0 to 17. Any thoughts?
  7. I have a little problem validating a user entry Here's the code: [code]if (preg_match('![a-z0-9\-_]+!',$albumName)) {   //passed   $message = "passed"; } else {   // failed   $message = "did not pass";    } [/code] The code should only accept a-z0-9 dash and underscore. For some reason it only checks the first letter and user entry such as a@#$ slip through. What am I doing wrong?
  8. I'm working on a function that processes $time_gmt and $timezone and returns $time. $time_gmt is true GMT time and the value of $timezone can be "GMT", "EST", "CET", etc. and is user selected upon registration and stored in a db. $time is $time_gmt in the user's selected time zone. My question is how do I generate a true GMT time? [code]echo gmdate('l, Y F j, H:i:s \G\M\T', time());[/code] It gives me 16:28, but it's 17:28 in London now...
  9. Not to mention that you're missing a " sign around your href. [code]<a href"=dog.php?dogid=something">[/code] Also you said: Um-that code seems to be working fine? Are you asking or saying?
  10. You can't just echo <a href=dog.php?dogid=$dogid> Part of it is html and other part is php. Like $dogid has no value in html Switching back and forth between html and php goes something like this: [code]echo "<a href=dog.php?dogid=" . $dogid . "more html code";[/code] Hope this helps. Also here's a nice tutorial for paging [url=http://www.phpnoise.com/tutorials/9/1]http://www.phpnoise.com/tutorials/9/1[/url]
  11. I'm working on a photo album, where I need to get a path out of my database. $album indicates which album we're seeing and determines a path_id. The value of $album can be "main" if we're still on the main page or "some album name" if we already made an album selection. If $album="main", then I don't need to need to do anything and $path="" If $album is other than "main" then I need to get the correct path_id, then get the correct path. For some reason I'm not getting the else part of my if statement working. Here's my code: [code]    if ($album="main") {     $path="";     } else {     echo "I'm here"; $sql2 = "SELECT album_pathid FROM albums WHERE album_thumbpicfilename = '$album' "; $pathresult = mysql_query($sql2); while ($row = mysql_fetch_assoc($pathresult)) { $pathid['album_pathid'][] = $row['album_pathid']; }        $pathid = $pathid['album_pathid'][0];     $sql3 = "SELECT path_text FROM paths WHERE path_id = '$pathid' ";     $pathresult = mysql_query($sql3); while ($row = mysql_fetch_assoc($pathresult)) { $path['path_id'][] = $row['path_id']; }        $path = $path['path_id'][0];     }[/code]
  12. What is the best way to break up a string separated by a certain character. I have path saved in $path which could me something like this: folder1/folder2/folder3/ I'd like to break up the string into folder1 folder2 folder3 and save it into an array. Any suggestions would be great.
  13. First of all, my customers don't have to have a PayPal account in order to pay me. They can use their credit card just fine. Figures on my site around $5000/month. Check out their demo at [url=http://www.paypal.com/cgi-bin/webscr?cmd=_merchant-outside#]http://www.paypal.com/cgi-bin/webscr?cmd=_merchant-outside#[/url] Don't worry it's not an affiliate link or anything. Hope this helps.
  14. In my experience, the best way is not to store it. No responsibilty on your shoulder. I see no reason why I would have to. I use PayPal on my site for online payments and I don't even see the cc info ever, but still get paid.
  15. Awesome. I would have hated putting all the effort moving stuff over, just to find out I won't have access to until I'm on localhost again. Thanks a lot.
  16. I will be transfering my hosting to godaddy. They have multiple domain hosting now and it seems like a good move for me. I already purchased the hosting and it's active. But I'm still hosted with the old company as well. My godaddy account comes with 25 mysql databases. I'd like to set up a database there and repopulate while still hosted at the old place. My question might seem silly, but I just want to make sure. Can I log into my database at godaddy from a site hosted with a different company, so I can start working on it and potentially not lose any data? Thanks.
  17. One solution would be to make a second table called categories, with fields: id, category_name (add more for your taste) Pull all category names from this table to create your links. Change the product table so you would have a category_id instead of category. Hope this helps.
  18. I'm trying to set $album to "main" if there's no GET value coming in. [code]$album = $_GET['album']; if ($album = "") {         $album = "main"; } [/code] I'm guessing ($album = "") is where I'm wrong. Thanks.
  19. Would you be surprised if I told you that I'm new to php?  ;D Thanks!
  20. Thanks guys. It really helped me out! I ended up using the first code [code]$total = mysql_result(mysql_query("SELECT COUNT(*) FROM pictures WHERE picture_albumid = 1"),0);[/code] It works great, but now I need to use a variable instead of a plain number and I'm getting an error again. The statement is supposed to find out how many albums I have to display. album_root can have a value of "main" or the name of a sub-album. If it's "main" that means it's displayed on the main page. Here's the statement: [code]$album = "main"; $total = mysql_result(mysql_query("SELECT COUNT(*) FROM albums WHERE album_root = $album"),0); [/code] Right now I'm manually feeding the variable $album. But it doesn't seem to work... ???
  21. Quick newbie question. I'm trying to get a count of albums in my table: [code]        $sql = "SELECT COUNT(*)                 FROM pictures                 WHERE picture_albumid = 1";                         $numofpics = mysql_query($sql);                 echo $numofpics;[/code] But this is what I get echoed: Resource id #7 What am I doing wrong? Thanks.
  22. Actually one more question  :D When I do a view source of my code, the echoed code becomes very long with no line break. Which makes it hard to check for mistakes in my generated code. How do I add a line break to the end of my echo code? Thanks.
  23. That worked! Great. Thank you. Btw, I was starting out slow, that's why I left my TR's out of the loop. I wanted TD's to work fine before I added another loop for the TR's as well. I knew it was just a small glitch somewhere, but I just couldn't figure out what for the life of me... Thanks again.
  24. I'm not sure what I'm describing wrong, but I don't need a tr in my code. The part I need debuged is the code I have on top, but I'll post it again: [code]<?php         $numpicsleft=2;         $numcol = 1; ?> blah blah <div align="center">   <table border="0" width="648" cellpadding="5" cellspacing="2">     <tr>     <?php       while ($numcol < 5) {           if($numpicsleft > 0) {             echo "<td width=\"162\" bgcolor=\"#e6e6e6\" valign=\"top\"><p align=\"center\">";             echo "<img border=\"0\" src=\"images/somepic.jpg\" width=\"150\" height=\"113\"><br>";             echo "<span class=\"text1\"><b>some text</b><br>some text<br>some text<br></span>";             echo "</p></td>";             $numcol++;             $numpicsleft--;           } else {             echo "<td width=\"162\"></td>";           }         }     ?>     </tr>   </table> </div>[/code] Basically the idea is that there's 4 cells in the row. Ideally there's a pic and some description in each cell. That's when $numpicsleft=4. However if $numpicsleft=2, then only the first two cells are posting pictures, but the last two cells are still created only it's empty (<td></td>) Please don't post totally new coding, because I'm new to php. I only intend to find out what I did wrong in mine. Thanks again.
×
×
  • 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.