Jump to content

GingerRobot

Staff Alumni
  • Posts

    4,082
  • Joined

  • Last visited

Everything posted by GingerRobot

  1. What exactly do you mean? PHP can echo out your css.
  2. You'll need to use the eval() function to evaluate a string as php.
  3. Use str_replace with a blank replace parameter: <?php $str = 'http://example.com'; $url = str_replace('http://','',$str); echo $url; ?>
  4. May i ask, why dont you like using google?
  5. Are you sure? I thought you could through "Add or remove windows components"?
  6. If you want the user to be logged in whenever they come to your website, look into cookies. Sessions are destroyed when the browser is closed, therefore, if you just use sessions, a user will have to log in each time they come to your website after closing their browser.
  7. Try somethign like: <?php function multipleof2($num){ while($num > 2){ $num /= 2; } if($num == 2){ return true; }else{ return false; } } if(multipleof2(32)){ //multiple of two }else{ //not a multiple of two } ?>
  8. Effigy: isn't the point that it is the fields that contain all the differant times in one record, rather than there being lots of records containing each differant time? Of course, its not the best way to store data...but thats how i've understood the question. djanim8: Yeah, i would go with a multidimensional array. I dont suppose anyone can give you any sample code without more information. Where does the "start this" and "later thing" come from? Perhaps you could post you existing code?
  9. You can use arrays of matches with the str_replace function too: <?php $str = 'A string with an * and a [ in it'; $remove = array('*','['); $str = str_replace($remove,'',$str); echo $str; ?> Also, the reason why your preg_match attempt was not working is that an asterix is a special character which defines the number of times a patter occurs. You need to escape it. So this would have worked: <?php $str = 'A string with an * in it'; $str = preg_replace('/\*/','',$str); echo $str; ?> However, for simple string replaces like this, use str_replace as it is faster.
  10. Im guessing by "doesn't work" you mean that when you try and edit the file, it doesn't edit successfully. Try: <form method="POST" action="edit.php"> <?php $rows = file("file.txt"); for($i=0; $i < count($rows); $i++) { echo "<input type='text' name='lines[$i]' value='$rows[$i]'><br />"; } ?> <input type="submit" value="Edit" name="submit"></p> </form> <?php if (isset($_POST['submit'])) { $towrite = implode("\n",$_POST['lines']); if(!($fp = fopen("file.txt","r+"))) { echo "Error"; } else { fwrite($fp, $towrite); fclose($fp); } } ?> It's untested, but give it a go. Notice the way that i've named the text fields as an array. Without doing this, you would have to open the file again, and extract each field name - since the name of the fields was what was on each line of the text file.
  11. Personally, i hate the entire concept of magic_quotes. As far as i'm concerned, something shouldn't happen to data from the user without me doing something to it. It seems to me that magic_quotes can always leed to annoyances with slashes too. I feel that that magic_quotes was an attempt to "mollycoddle" developers to make sure they were producing safe code. I guess the php developers must agree with some of that, since that magic_quotes setting is being taken out of php 6. Given that, i would suggest learning to develop without magic_quotes, althuogh if you were producing something for use on other servers, you would of course need to check for the setting being on. I suppose that didn't really answer your question, but thats my 2 cents(or should i say pence, being english?) on the subject.
  12. Perhaps i've missed the point. Try: <?php $str = 'A string with an * in it'; $str = str_replace('*','',$str); echo $str; ?>
  13. I'd go along with that. It seems somewhat childish that the order of parameters and naming conventions aren't consistant.
  14. Personally, i got bored after the "Please repost this on your blogs/Social networking sites"
  15. I must be the the only one who still uses IE. I've no idea why, i think its just out of habit. I have firefox, but still, i click the IE icon. Perhaps ive been brainwashed by microsoft. One of these days ill uninstill IE. I cant possibly use it then.
  16. I must be psychic - i managed to guess the creator of the poll from the title of it.
  17. I would call it the query string. As in the predefined varirable: $_SERVER["QUERY_STRING"]
  18. It'll look something along the lines of: <table> <tr><td>Var1</td><td>Var2</td><td>Image</td></tr> <?php $sql = "SELECT * FROM `yourtable`"; $result = mysql_query($sql) or die(mysql_error()); while($row = mysql_fetch_assoc($result)){ echo '<tr><td>'.$row['var1'].'</td><td>'.$row['var2'].'</td><td><img src="images/'.$row['images'].'" /></td></tr>'; } ?> </table>
  19. Same as SA for me. Never use the heredoc syntax - not really sure why, just prefer the other methods.
  20. If you have a comma separated list, you can use the IN clause: $qs = "SELECT * FROM XL-auctions WHERE id IN ($PRESELECTED)";
  21. Add a default case: <?php $action=$_GET['page']; switch($action){ case '': index(); break; case 'view_comments': echo "here be comments"; break; default: echo 'Invalid action'; break; } ?>
  22. I would guess that most of your problems stem from this one: Notice: Undefined index: customerid in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\InputMaintainance\reportdata1.php on line 16 It seems that cutomerid is not a field in your database, as there is no key called customerid in the array returned by mysql_fetch_array()
  23. Well, i would imagine what you are after is: foreach ($invoicenumlist as $key => $value){ foreach ($value as $key1 => $value1){ $query3 = "SELECT * FROM productid where invoicenum = '$value1'"; $Result3 = mysql_query($query3); while ($row3=mysql_fetch_array($Result3)){ $productidlist[$key][]=$row3['productid']; $pidcounter = $pidcounter+1; } } } It is the value of each element of your array that is an array also, not the key.
  24. I'm quite disappointed. I came here expecting a much bigger rant than that! I hope you've not paid them for their crappy job.
  25. Well, the problem is that you can't have a WHERE clause on an INSERT statement - are you perhaps wanting to UPDATE and existing row? As for quotes here: 'WHERE `user_id`='6'' Thats perefectly right. The error message has the portion of relevant code enclosed in single quotes. The first and last quote are nothing to do with your query. I assume that is what was causing the confusion.
×
×
  • 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.