Jump to content

Bricktop

Members
  • Posts

    677
  • Joined

  • Last visited

    Never

Everything posted by Bricktop

  1. Perfect! Thanks premiso - the UNION option worked a treat!
  2. Hi all, I have the following query, as simple as it gets: $sql = mysql_query("SELECT * FROM news ORDER BY category, id DESC"); This will output: WORLD NEWS story 1 story 2 story 3 story 4 LOCAL NEWS story 1 story 2 story 3 story 4 story 5 TECH NEWS story 1 story 2 story 3 What I want is to limit the output of EACH category by 3 so I get: WORLD NEWS story 1 story 2 story 3 LOCAL NEWS story 1 story 2 story 3 TECH NEWS story 1 story 2 story 3 Obviously: $sql = mysql_query("SELECT * FROM news ORDER BY category, id DESC LIMIT 3"); Just gives: WORLD NEWS story 1 story 2 story 3 Hope this makes sense, any ideas how I can achieve this? Thanks
  3. Hi taquitosensei and thanks but I already tried that and when that 'if' condition doesn't get met nothing displays. I'll keep trying to get it going but thanks anyway. What I need is for it loop around again if that condition isn't met, until it is met. Any ideas?
  4. Hi all, This is probably really easy but I just can't figure it out! I have a text file which has data stored exactly like: some text || some name || category1 some text2 || some name2 || category1 some text3 || some name3 || category1 some text4 || some name4 || category2 some text5 || some name4 || category2 some text6 || some name6 || category3 some text7 || some name7 || category1 I'm using the following simple code to read all of the data into a variable: $text = explode("\n", $textcontent); $textcontent is defined and used earlier on just to fread the file. How do I only store in the $text variable lines of text with 'category1' (for example)? I assume I then need to 'explode("||", $text);' so I've got everything split into the relevant chunks but I'm stuck after that. I very rarely work with text files, this would be so easy in MySQL! Thanks in advance!
  5. Hi hyipinvestigation, The HTML is fine, the problem is with the function which displays the image. For example, if you type http://www.hyipchecker.com/index.php?a=image&lid=9 into your browser you're currently not getting an image returned, until you get an image returned you're not going to get an image for your button. This could be being caused by a number of different reasons including the query you're running to get the image. Post your full code if you require further help. Hope this helps.
  6. Hi deansaddigh, Firstly, create a page called "productdetail.php", this will be the page which displays the details of each product. Now, change the line of code which you would like clickable to be: <td><?php echo '<a href="productdetail.php?product='.$row['id'].'">'.$productname.'</a>';?></td> (Assuming the ID field is called 'id' in the database, change it accordingly if not) Now, on your productdetail.php page, insert the following function, this will cleanse the $_GET data and make it safe to insert into a query. function make_safe($unsafe) { //This needs to be the database connection file require("connect.php"); $safe = mysql_real_escape_string(strip_tags(trim($unsafe))); return $safe; } Now, have a query on your productdetail.php file which reads something like: $sql = mysql_query("SELECT * FROM yourtable WHERE id = '".make_safe($_GET['product'])."' ORDER BY id DESC"); Obviously, you haven't given much to work on but the above should help you build the page to your requirements. Hope this helps.
  7. Hi deansaddigh, Yes, basically, pass the ID via the URL, then on the page which displays the product in its entirety have a MySQL query which querires the database for the product WHERE id = $_GET['id'] (for example) Obviously the above is a very very basic example, in the real world you would need to sanitize the $_GET data before inserting into a query. Hope this helps.
  8. Hi jonnygrim, This would be easily achieved using Javascript. Have a Google around or click here for one example I found (using CSS) or click here for an example using pure Javascript. Hope this helps.
  9. Shameful self-promotion. I have a script which does exactly that, and it's only $3! Click
  10. Bricktop

    Odd

    Hi Leveecius, The problematic line is: if (($killer_rank == "Tramp")&&($usrrank == "Gangster")){$add Users="24000"; } Change it to read: if (($killer_rank == "Tramp")&&($usrrank == "Gangster")){$add="24000"; } Hope this helps.
  11. Hi jamiet757, The link is chagning to http://www.mysite.com/users/www.theirsite.com because you're not placing the http:// in front of the URL, therefore the browser is interpreting it as a local file/link. In the past I've used the following function to add http:// to posted website addresses. If the user forgets to add http:// it will be added, if they include it then it will not be added again (if that makes sense): function addHttp($post) { $url = $post; $protocols = array( 'http://', 'https://', 'ftp://' ); $found = false; foreach ($protocols as $value) { if (strpos($url, $value) !== false) { $found = true; break; } } if (!$found) {$url = 'http://' . $url;} return $url; } Call it by doing something like: addHttp({WEBSITE}); Although, it would be better to use this function on the user posted data so it is stored correctly in the first place. Hope this helps.
  12. Hi brmcdani, It would be better to use CSS for this, but as a quick fix, change your code to read: echo "<tr><td><font size=\"18px\">Username</font></td><td><input type=\"text\" name=\"username\"></td></tr>\n"; The above would make only "Username" appear in a 18px font. To change both the text and the size of the text inputted into each input field to a size of 18px change your code to read: echo "<tr><td><font size=\"18\">Username</font></td><td><input type=\"text\" name=\"username\" style=\"font-size: 18px\" ></td></tr>\n"; Obviously, change the 18 to a lesser or greater number depending on your requirements. However, as I mentioned, it would be better to style your tables and inputs using CSS. Hope this helps.
  13. Hi lakshmiyb, Post your code for a definitive answer.
  14. Hi robert_gsfame, Post your code and we'll be able to give a more definitive answer.
  15. Hi buzzby, Even though it's not a 'fix', you could work around this by suppressing deprecated messages using the ~E_DEPRECATED syntax. For example: error_reporting(~E_DEPRECATED) Hope this helps.
  16. Hi denoteone, Yes it would, or more precisely it would be "off". Hope this helps.
  17. Hi blmg911, You need to use the valign="top" attribute (even better would be to use a CSS equivalent) Amanded code below: <table width="80%" border="0" align="center" cellpadding="0" cellspacing="10"> <tr> <td width="50%"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="outborders"> <tr> <td bgcolor="#664609"> Existing Customers </td> </tr> <tr> <td> </td> </tr> <tr> <td bgcolor="#664609">Forgotten Password</td> </tr> <tr> <td height="26"> </td> </tr> </table></td> <td width="50%" valign="top"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="outborders"> <tr> <td bgcolor="#664609">New Customers</td> </tr> <tr> <td> </td> </tr> </table> <br /></td> </tr> </table> For future reference there is a specific HTML help forum which is better suited for this type of question.
  18. Change: {CODE] <div><label>File:</label> <input type="file" name="form[file]" /></div> [/code] to: <div><label>File:</label> <input type="file" name="file" /></div>
  19. Hi basnut, Does your server have magicquotes enabled? If so, turn it off and try again.
  20. Can you post your HTML code too.
  21. Hi busnut, Is it storing 8\ in the database? Or is 8\ the result of the echo statement?
  22. Hi runnerjp, Your first if statement has too many ( brackets. Change it to: if (($_FILES["file"]["type"] == "text/doc") && ($_FILES["file"]["size"] < 20000))
  23. Hi runnerjp, Try: $_FILES["file"]["type"] == "application/msword"
  24. Hi busnut, Try escaping the variables thus: $sql1="UPDATE $tbl_name SET status='$status[$i]', category='$category[$i]', subcategory='$subcategory[$i]', item='".addslashes($item[$i])."', description='".addslashes($description[$i])."', code='$code[$i]', qty1='$qty1[$i]', price1='$price1[$i]', qty2='$qty2[$i]', price2='$price2[$i]', qty3='$qty3[$i]', price3='$price3[$i]', qty4='$qty4[$i]', price4='$price4[$i]', qty5='$qty5[$i]', price5='$price5[$i]', weight='$weight[$i]' WHERE id='$id[$i]'"; [code] Hope this helps.
  25. Hi busnut, When entering data into a database you use addslashes(). To use this function on your query, change the relevant code to read: $sql1="UPDATE $tbl_name SET status='$status[$i]', category='$category[$i]', subcategory='$subcategory[$i]', item=".addslashes($item[$i]).", description=".addslashes($description[$i]).", code='$code[$i]', qty1='$qty1[$i]', price1='$price1[$i]', qty2='$qty2[$i]', price2='$price2[$i]', qty3='$qty3[$i]', price3='$price3[$i]', qty4='$qty4[$i]', price4='$price4[$i]', qty5='$qty5[$i]', price5='$price5[$i]', weight='$weight[$i]' WHERE id='$id[$i]'"; You could also use the mysql_real_escape_string() function to achieve the same result: $sql1="UPDATE $tbl_name SET status='$status[$i]', category='$category[$i]', subcategory='$subcategory[$i]', item=".mysql_real_escape_string($item[$i]).", description=".mysql_real_escape_string($description[$i]).", code='$code[$i]', qty1='$qty1[$i]', price1='$price1[$i]', qty2='$qty2[$i]', price2='$price2[$i]', qty3='$qty3[$i]', price3='$price3[$i]', qty4='$qty4[$i]', price4='$price4[$i]', qty5='$qty5[$i]', price5='$price5[$i]', weight='$weight[$i]' WHERE id='$id[$i]'"; If your form allows the user to enter data, it would be a good idea to use mysql_real_escape_string() on all of the variables in your MySQL query. Have a look at Daniel's excellent PHP security tutorial for more information on this. If I have misunderstood your request, and you do wish to use stripslashes() on the outputted data, change the relevant code to read: <? echo stripslashes($rows['item']); ?> and <? echo stripslashes($rows['description']); ?> However, the point I made above regarding mysql_real_escape_string() and PHP security is still valid. Hope this helps.
×
×
  • 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.