Jump to content

doddsey_65

Members
  • Posts

    902
  • Joined

  • Last visited

  • Days Won

    9

Everything posted by doddsey_65

  1. Hi, I am trying to use preg_replace on a database column called content. This column contains some html code and within is several img tags. What i want to do is replace style="width: xxxpx; to style="width: 100px;. Here is the code i tried but it didn't work. Any ideas? $content = preg_replace('/(width:)=("[^"]*")/i', 'width: 100', $content);
  2. I would like to include a section on my tutorials website where people can add text tutorials. This means i would like to have a text area where html code can be inputted. I would like to be able to restrict the html tags to just stuff like <b> and <em>. I have no idea on how to even start this or if its possible. Also how would i store these tutorials? They would probably be long text documents so the contents couldnt really be stored in the database....could they?
  3. Hi, just found out my free host does not allow the rar extension. Its a good thing im making this for someone else and will be uploading it to there host soon. Thanks
  4. When the user clicks on the link i want it to open the download file dialog box so the user can download the file. Instead it opens the file in the browser. What am i doing wrong? Here is my code. <?php echo 'Attachment - <a href="ftp://thevault.000a.biz/swn/'.$row->attachment.'">'.$row->attachmentname.'</a>'; ?> $row->attachment is the filepath of the file on the server and $row->attachmentname is the name the user inputs.
  5. try adding ob_start(); at the very top of your page and ob_flush(); at the end.
  6. from what i have seen the name attribute is not used when using an image as the submit button. The codes i have seen divert you to a different page via form action. But i want to stay on the same page. I just dont know how to work around this. Any ideas?
  7. Okay i figured out the problem but i dont know why its a problem. Its this bit: <input type="image" src ="images/icons/fav.png" name="fav" /> If i just use the standard submit button it works fine. <input type="submit" value=Favorite" name="fav" /> So how is this not working with an image?
  8. how do i activate error reporting? the query echos the right values and when i insert the echoed query into phpmyadmin it inserts the values correctly, however the query in the script doesnt work. No values get added to the database.
  9. i get no errors and when i echo the query everything is as it should be. I even copied the echoed query and used it in phpmyadmin and it added the data. Could it be because i dont have any inputs in the form because they are all just hidden?
  10. Okay i have changed it a little but its still not working. Heres the form: echo '<table><tr><td style="padding: 5px;">'; echo '<form name="fav" action="' . $_SERVER['PHP_SELF'] . '?id=' . $id . '" method="post">'; echo '<input type="hidden" name="id" value="'.$id.'">'; echo '<input type="hidden" name="name" value="'.$row->name.'">'; echo '<input type="hidden" name="fullname" value="'.$row->fullname.'">'; echo '<input type="image" src ="images/icons/fav.png" name="fav" />'; echo '</form>'; And heres the php: if (isset($_POST['fav'])) { $qry = "INSERT INTO favorites (username, tutorialid, tutorialname, tutorialauthor) VALUES ('$loginusername', '".$_POST['id']."', '".$_POST['name']."', '".$_POST['fullname']."')"; $add_fav = mysql_query($qry); }
  11. i have done what you said, and yes it was spelled incorectly so i have changed it but still nothing is giong into the database.
  12. there are alot of things people could help you with but your question is too open. How about explaining what you need help with specifically.
  13. Im trying to set up an add as favorite link on my tutorials. When the link is clicked it sends the name of the tutorial and the users username to a database table called favorites. The only problem is that its not sending anything to the database. Here is the insert query: if (isset($_POST['fav'])) { $qry = "INSERT INTO favorites (username, tutorialid, tutorialname, tutorialauthor) VALUES ('".$loiginusername."', '".$row->id."', '".$row->name."', '".$row->fullname."')"; $add_fav = mysql_query($qry); } And here is the form: echo '<form name="addfavorite" action="' . $_SERVER['PHP_SELF'] . '?id=' . $id . '" method="POST">'; echo '<input type="image" src ="images/icons/fav.png" name="fav" />'; echo '</form>'; How can i get this to work?
  14. Okay here is the code. I want to run another SELECT * query within this while loop, which i thought could be done but i cant get it to work. I want the query to select the comments from the comments table in the database that matches the id of the tutorial. <?php $i = 0; $result = mysql_query("SELECT * FROM tutorials ORDER BY added ASC LIMIT 4") or die(mysql_error()); while($row = mysql_fetch_object($result)) { if($i==2) { echo '</tr><tr><td>'; $i=0; } if ($row->category == 1) { $row->category = 'Animation'; } if ($row->category == 2) { $row->category = 'Basics'; } if ($row->category == 3) { $row->category = 'Cloth'; } if ($row->category == 4) { $row->category = 'Compositing'; } if ($row->category == 5) { $row->category = 'Dynamics'; } if ($row->category == 6) { $row->category = 'Fluid'; } if ($row->category == 7) { $row->category = 'Game Engine'; } if ($row->category == { $row->category = 'General'; } if ($row->category == 9) { $row->category = 'Lighting'; } if ($row->category == 10) { $row->category = 'Modelling'; } if ($row->category == 11) { $row->category = 'Modifiers'; } if ($row->category == 12) { $row->category = 'Particles'; } if ($row->category == 13) { $row->category = 'Rendering'; } if ($row->category == 14) { $row->category = 'Rigging'; } if ($row->category == 15) { $row->category = 'Scripts'; } if ($row->category == 16) { $row->category = 'Sculpting'; } if ($row->category == 17) { $row->category = 'Texturing'; } if ($row->category == 18) { $row->category = 'Tips and Tricks'; } if ($row->category == 19) { $row->category = 'UV Mapping'; } ?> <table style="background-image:url(images/tut_back.png); background-repeat: repeat-y; border:1px solid #C2D0DC; width:100%;"> <tr> <td class="tutorials_left" valign="top"> <div class="tutorial_icon"><a href="tutorials.php?id=<?php echo $row->id; ?>"> <img src="<?php echo $row->path; ?>" alt="Tutorial Icon" class="tutorial_icon" width="50" height="50"></a> </div> </td> <td class="tutorials_right" valign="top"> <div class="tutorial_title"><a href="tutorials.php?id=<?php echo $row->id; ?>"><?php echo $row->name; ?></a> </div> <div class="tutorial_uploaded"> Uploaded by <?php echo $row->fullname; ?> on <em><?php echo $row->added; ?></em> </div> <div class="tutorial_cat">Category: <?php echo $row->category; ?> </div> </td> </tr> </table> <?php if ($row->RatedBy == 0) { $avg = 0; } else { $avg = $row->Rating/$row->RatedBy; $avg = round($avg, 2); } ?> <div class="tutorial_bar"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td class="views">Views: <em><?php echo $row->views; ?></em></td> <td class="comments">Comments: <em>3</em></td> <td class="rating">Rating: <?php echo $avg; ?></a></td> </tr> </table> </div> <td> <?php $i++; } ?>
  15. How would I assign a random ID to a new user rather than having an AI in the database?
  16. sorry but ive fixed it, thanks for your help though. after i tidied it up it was easier. I added a <td> to the end of if ($i == 2) { echo '</tr><tr>'; // added td here }
  17. okay ive tidied up the code a bit: <td id="col_main" valign="top" style="text-align:center;"> <div class="main_content"> <font size="2"><a href=""><b><em>NEWEST TUTORIALS</em></b></font><hr> <div class="tutorials_row" style="margin-bottom:0px;"> <table width="100%" border="5"> <tr> <td> <?php $i = 0; $result = mysql_query("SELECT * FROM tutorials ORDER BY added ASC LIMIT 4") or die(mysql_error()); while($row = mysql_fetch_object($result)) { if($i==2) { echo '</tr><tr>'; $i=0; } ?> <table width="50%" border="10" cellspacing="0" cellpadding="0"> <tr> <td class="tutorials_left" valign="top"> <div class="tutorial_icon"> <img src="<?php echo $row->path; ?>" alt="Tutorial Icon" class="tutorial_icon" width="50" height="50"></a> <?php echo $i; ?> </div> </td> <td class="tutorials_right" valign="top"> <div class="tutorial_title"><a href=""><?php echo $row->name; ?></a> </div> <div class="tutorial_uploaded"> Uploaded by <a href=""><?php echo $row->fullname; ?></a> on <em><?php echo $row->added; ?></em> </div> <div class="tutorial_cat">Category: <a href=""><?php echo $row->category; ?></a> </div> </td> </tr> </table> <div class="tutorial_bar"> <table width="50%" border="0" cellspacing="0" cellpadding="0"> <tr> <td class="views">Views: <em><?php echo $row->views; ?></em></td> <td class="comments"><a href="" title="Tutorial Comments">Comments:</a> <em>3</em></td> <td class="rating">Rating: <a href="">4.76</a></td> </tr> </table> </div> <?php $i++; } ?> </td> </tr> </table> </div> </div> </td>
  18. heres the source: <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>The Vault | A Tutorial Repository</title> <meta name="keywords" content="" /> <meta name="description" content="" /> <link href="stylesheet.css" rel="stylesheet" type="text/css" media="screen" /> </head> <body> <br> <div id="logo"> <img src="images/main_logo.png"> </div> <div id="container"> <div id="dyn_container"> <div id="main_container"> <div id="mainheader"> <img src="images/categories.png"><img src="images/middle.png"><img src="images/tutorials.png"></div> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td id="left" valign="top"> <div id="left_categories"> <div class="cat_content"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td class="icon"><img src="images/icons/ball.png"></td> <td class="title" valign="bottom"><a href="">Animation</a></td> <td class="icon"><img src="images/icons/ball.png"></td> <td class="title" valign="bottom"><a href="">Basics</a></td> </tr> <tr> <td class="icon"><img src="images/icons/ball.png"></td> <td class="title" valign="bottom"><a href="">Cloth</a></td> <td class="icon"><img src="images/icons/ball.png"></td> <td class="title" valign="bottom"><a href="">Compositing</a></td> </tr> <tr> <td class="icon"><img src="images/icons/ball.png"></td> <td class="title" valign="bottom"><a href="">Dynamics</a></td> <td class="icon"><img src="images/icons/ball.png"></td> <td class="title" valign="bottom"><a href="">Fluid</a></td> </tr> <tr> <td class="icon"><img src="images/icons/ball.png"></td> <td class="title" valign="bottom"><a href="">Game Engine</a></td> <td class="icon"><img src="images/icons/ball.png"></td> <td class="title" valign="bottom"><a href="">General</a></td> </tr> <tr> <td class="icon"><img src="images/icons/ball.png"></td> <td class="title" valign="bottom"><a href="">Lighting</a></td> <td class="icon"><img src="images/icons/ball.png"></td> <td class="title" valign="bottom"><a href="">Modelling</a></td> </tr> <tr> <td class="icon"><img src="images/icons/ball.png"></td> <td class="title" valign="bottom"><a href="">Modifiers</a></td> <td class="icon"><img src="images/icons/ball.png"></td> <td class="title" valign="bottom"><a href="">Particles</a></td> </tr> <tr> <td class="icon"><img src="images/icons/ball.png"></td> <td class="title" valign="bottom"><a href="">Rendering</a></td> <td class="icon"><img src="images/icons/ball.png"></td> <td class="title" valign="bottom"><a href="">Rigging</a></td> </tr> <tr> <td class="icon"><img src="images/icons/ball.png"></td> <td class="title" valign="bottom"><a href="">Scripts</a></td> <td class="icon"><img src="images/icons/ball.png"></td> <td class="title" valign="bottom"><a href="">Sculpting</a></td> </tr> <tr> <td class="icon"><img src="images/icons/ball.png"></td> <td class="title" valign="bottom"><a href="">Texturing</a></td> <td class="icon"><img src="images/icons/ball.png"></td> <td class="title" valign="bottom"><a href="">Tips And Tricks</a></td> </tr> <tr> <td class="icon"><img src="images/icons/ball.png"></td> <td class="title" valign="bottom"><a href="">UV Mapping</a></td> </tr> </table> </div> <div class="left_cat_title" align="center"> <a href="#">Weekly Quiz</a> </div> <div class="cat_content"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <form action ="/thevault/index.php" method=POST> <td class="title" valign="bottom" align="center">When was Blender 3D first Released?</td></tr> <tr><td> <div align="center"> <input type = radio name=options value=1995>1995 <input type = radio name=options value=1998>1998 <input type = radio name=options value=2000>2000 <input type = radio name=options value=2002>2002 </div></tr></td><tr><td><br> <div align="center"> <input type=submit value=Submit name=poll_btn></form> </div></td> </tr> </table> </div> <td id="col_main" valign="top" style="text-align:center;"> <div class="main_content"> <font size="2"><a href=""><b><em>NEWEST TUTORIALS</em></b></font><hr> <div class="tutorials_row" style="margin-bottom:0px;"> <table width="100%" border="2"><tr><td> <tr> <table width="100%" border="1" cellspacing="0" cellpadding="0"> <tr> <td class="tutorials_left" valign="top"> <div class="tutorial_icon"><a href=""> <img src="tutcovers/hamishsky.jpg" alt="Tutorial Icon" class="tutorial_icon" width="50" height="50"></a> </div> </td> <td class="tutorials_right" valign="top"> <div class="tutorial_title"><a href="">Render Layers</a> </div> <div class="tutorial_uploaded"> Uploaded by <a href="">Creating Sky</a> on <em>2010-04-01</em> </div> <div class="tutorial_cat">Category: <a href="">17</a> </div> </td> </tr> </table> </div> </td><td> <table width="100%" border="1" cellspacing="0" cellpadding="0"> <tr> <td class="tutorials_left" valign="top"> <div class="tutorial_icon"><a href=""> <img src="tutcovers/hamishlava.jpg" alt="Tutorial Icon" class="tutorial_icon" width="50" height="50"></a> </div> </td> <td class="tutorials_right" valign="top"> <div class="tutorial_title"><a href="">Render Layers</a> </div> <div class="tutorial_uploaded"> Uploaded by <a href="">Making Lava</a> on <em>2010-04-01</em> </div> <div class="tutorial_cat">Category: <a href="">1</a> </div> </td> </tr> </table> </div> </td><td> </tr><tr> <table width="100%" border="1" cellspacing="0" cellpadding="0"> <tr> <td class="tutorials_left" valign="top"> <div class="tutorial_icon"><a href=""> <img src="tutcovers/hamishtext.jpg" alt="Tutorial Icon" class="tutorial_icon" width="50" height="50"></a> </div> </td> <td class="tutorials_right" valign="top"> <div class="tutorial_title"><a href="">Render Layers</a> </div> <div class="tutorial_uploaded"> Uploaded by <a href="">3D Text</a> on <em>2010-04-01</em> </div> <div class="tutorial_cat">Category: <a href="">10</a> </div> </td> </tr> </table> </div> </td><td> <table width="100%" border="1" cellspacing="0" cellpadding="0"> <tr> <td class="tutorials_left" valign="top"> <div class="tutorial_icon"><a href=""> <img src="tutcovers/hamishlogo.jpg" alt="Tutorial Icon" class="tutorial_icon" width="50" height="50"></a> </div> </td> <td class="tutorials_right" valign="top"> <div class="tutorial_title"><a href="">Render Layers</a> </div> <div class="tutorial_uploaded"> Uploaded by <a href="">3D Logo</a> on <em>2010-04-01</em> </div> <div class="tutorial_cat">Category: <a href="">10</a> </div> </td> </tr> </table> </div> </td><td> </tr> </table> </tr> </table> </div>
  19. i have several <td> tags in the loop
  20. Can some one please tell me where Im going wrong and why the layout isnt displaying 2 per row. I know its gotta be something with the closing tags, but ive been trying for hours to find it. <td id="col_main" valign="top" style="text-align:center;"> <div class="main_content"> <font size="2"><a href=""><b><em>NEWEST TUTORIALS</em></b></font><hr> <div class="tutorials_row" style="margin-bottom:0px;"> <table width="100%" border="2"><tr><td> <?php $i = 0; $result = mysql_query("SELECT * FROM tutorials ORDER BY added ASC LIMIT 4") or die(mysql_error()); while($row = mysql_fetch_object($result)) { if($i==0) { echo '<tr>'; } if($i==2) { echo '</tr><tr>'; $i=0; } ?> <table width="100%" border="1" cellspacing="0" cellpadding="0"> <tr> <td class="tutorials_left" valign="top"> <div class="tutorial_icon"><a href=""> <img src="<?php echo $row->path; ?>" alt="Tutorial Icon" class="tutorial_icon" width="50" height="50"></a> </div> </td> <td class="tutorials_right" valign="top"> <div class="tutorial_title"><a href="">Render Layers</a> </div> <div class="tutorial_uploaded"> Uploaded by <a href=""><?php echo $row->name; ?></a> on <em><?php echo $row->added; ?></em> </div> <div class="tutorial_cat">Category: <a href=""><?php echo $row->category; ?></a> </div> </td> </tr> </table> <div class="tutorial_bar"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td class="views">Views: <em><?php echo $row->views; ?></em></td> <td class="comments"><a href="" title="Tutorial Comments">Comments:</a> <em>3</em></td> <td class="rating">Rating: <a href="">4.76</a></td> </tr> </table> </div> </div> </td><td> <?php $i++; } ?> </tr> </table> </tr> </table> </div>
  21. perfect thankyou my good man!
  22. Can you put a variable into a statements LIKE function? eg/ SELECT * FROM somewhere WHERE row LIKE %$variable% Ive tried it this way but i get nothing
  23. thanks for the reply, i did get around the problem by setting $i to -1 but i will probs change it to your solution as you said it is wrong. Thanks
  24. $filepath2 has been set : $filePath2 = $uploadDir2 . $fileName2; I have kept everything the same as is in the other upload script i am using(in which everything works) the only difference is that the one that works only uploads an image to the server and sends the path to the database while with this one I am trying to add some field information aswell as the image.
×
×
  • 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.