Jump to content

k.soule

Members
  • Posts

    30
  • Joined

  • Last visited

    Never

Everything posted by k.soule

  1. Thanks, I know the difference between HTML and XML...terrible advice (and quite insulting). It is not always the same, if you view source on this particular page I'm looking at, it shows raw XML; however, if you "Save page as", it will save it as the HTML document you actually see in your browser window. The actual solution to those that might wander into this topic looking for help is to mimic a browser. Grab the contents via curl but be sure to add this line in, or something similar, in: curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0'); This will, in the end, return the XML and not the HTML. Nifty![/code]
  2. I've spent the better part of the night searching all over the internet for a solution to a problem I'm having with XML. The problem is, I am trying to get just the raw XML file from a server (which is shown when you view source) before it turns it into HTML via the XSL stylesheet. Does anybody have any tips or pointers on how to achieve this? file_get_contents(), fopen(), and curl are all returning the server parsed HTML file; however, Firefox and IE7 show me the XML source when I view source...very strange and frustrating. Hoping you guys can help!
  3. trim is a function to remove whitespace from the beginning and/or ends of a string, it seems like you just want to have a string with all that info in it and be able to pull any of the data out of it at a given time, why not use an array? Unless I'm misunderstanding you. If it must be a string though, you can probably use preg_replace to return only the string you want.
  4. You may want to fiddle with the quote_style argument on htmlentities(), you may be able to avoid passing it through stripslashes().
  5. Try addslashes() when echoing the string, just a thought. Edit: Forgive me, addslashes() should be applied [i]before[/i] putting the information in the database. In your query, try using ' ' instead of " ", it sounds like a problem of exiting the string prematurely.
  6. [code]IF ( (ARGUMENT is TRUE) && (ARGUMENT2 is TRUE) ) { // evaluate }[/code] && is AND || is OR
  7. $upload = move_uploaded_file($_FILES[u]['picture'][/u]['tmp_name'], "[u]/home/www/htdocs/[b]$id[/b].jpg[/u]"); $_FILES['picture']['tmp_name'] is the temporary name on the server, change picture to the name of the form element that you are uploading with. /home/www/htdocs/$id.jpg is the location, change /home/www/htdocs/ to match your file system structure, $id would be the variable holding the identification of the person and, of course, .jpg is the extension. $upload will be 1, if the upload was successful. [i]EDIT -> Let me clarify the above, ['tmp_name'] should not be changed, it stands for the temporary name that the server is using to store the uploaded file, uploaded files are always moved to a temporary file and then moved to a permanent location. It doesn't pass the filename the user put in, if you wanted that name, it would just be ['name']...but that is useless unless you want to preserve the same file name; the only element of that code that will need changed is ['picture'] and the location and variable of the final location, as underlined above.[/i]
  8. Whoops! Not to even mention it printed out the same thing three times :) The below script works fine - [code]<?php echo "<table><tr><td>"; $cnt = 1; while( $row = mysql_fetch_assoc($list_result) ) {          print "<td>";     print "<img class='image' width='80px' height='150px' src='$row[picture]'             href='./recommendation.php?id=$row[item_id]' alt='Picture'><br>\n";               print "<a href='./recommendation?id=$row[item_id]>$row[Title]</a><br>$row[cost]\n";            if($cnt == '3') {         print "</td></tr><tr><td>";         $cnt = 0;     }     else {         print "</td><td>";     }                $cnt++;     } print "</td></tr></table>"; ?>[/code]
  9. Pass the array with sessions, simplest solution I can think of.
  10. Well, you stretched the page quite terribly...and you didn't even tell us your problem. You need to program that in PHP, that isn't a problem, though..."programming" it in PHP would be putting an echo before it line and making it impossible to read :) So, two things, put the HTML in [ code ] tags! and describe what you intend to do with this page and script (obviously you are sending something via mail, is that your problem?).
  11. I suppose this should even do exactly what you wanted -- [code]<?php // echo "<table><tr>"; while( $row = mysql_fetch_assoc($list_result) ) {         $cnt = 1;     while($cnt <= 3) {                 print "<td>";         print "<img class='image' width='80px' height='150px' src='$row[picture]'                href='./recommendation.php?id=$row[item_id]' alt='Picture'><br>\n";                   print "<a href='./recommendation?id=$row[item_id]>$row[Title]</a><br>$row[cost]\n";                  $cnt++;         }     print "</td></tr>"; } ?>[/code]
  12. [code]<?php echo "<table><tr>"; while( $row = mysql_fetch_assoc($list_result) ) {         $cnt = 1;     while($cnt <= 3) {         print "<td>";         // Your images here         $cnt++;     }     print "</td></tr>"; } ?>[/code] Terrible english discourages people from answering, if you can't take the time to talk intelligently, why should someone take the time to respond?
  13. You can use a loop like so: [code]$query = mysql_query("SELECT website FROM users"); while($row = mysql_fetch_assoc($query)) {     if($row['website']) {         $ret = $ret . $row['website'] . "\n";     } }[/code] When all is said and done, $ret will hold a variable with every website from the user table that had an entry (make the default website field NULL), put it in a file via whatever means you like, I don't think that was intended to be answered along with the above? Of course, the mysql_query() will need changed unless I guessed correctly...
  14. [code]$text = htmlspecialchars("<o:BLAHBLAHBLAH />"); if(ereg('&lt;o:(.*) /&gt;', $text)) {     $text = str_replace("&lt;o:", "", $text);     $text = str_replace("/&gt;", "", $text); }[/code] Maybe, it isn't as elegant as a single line replace, but it does the same thing. Sorry, I thought all you wanted to do was replace what was inside, in which case the solution was simple :o I don't know if you can match on something and replace on another match inside of the match.
  15. Try strtotime("1900-09-10"), I'm on PHP 5, also.
  16. Could it even have something to do with what operating system? Are you on linux?
  17. In Firefox, if you open Page Setup, there is a headers/footers tab with the ability to remove all that information :-P IE has similar functionality.
  18. Number one: Session capability must be enabled on your server, I don't think it is by default if you are hosting your own server. Number two: session_start() must come before ANY other output. Try this code to see if sessions work in their purest form -- [code]<?php session_start(); $_SESSION['username'] = "phpfreak"; if($_GET['action'] === 'echo') {     print $_SESSION['username'] . " -- Sessions work!"; } else {     print("<a href='" . $_SERVER['PHP_SELF'] . "?action=echo'>            Click this link to test sessions            </a>"); }      ?>[/code] If it doesn't, you don't have session capability.
  19. I'm sporting 5.1.1 on PHP and gd 2.0.32 compiled with jpeg and png support. I don't do much work with PHP's image manipulation functionality so I can't really speculate what the troubles may be. If you are going to use imagecreatetruecolor, you may want to use imagecopymerge instead of imagecopy. Try it and see: [code]<?php $print = imagecreatetruecolor(300, 500); $image = imagecreatetruecolor(555, 555); $mat1 = imagecolorallocate($image, 255, 255, 0); if ( !imagefill($image, 0, 0, $mat1) ) { die("Image not filling!"); } imagecopymerge($image, $print, 50, 50, 0, 0, 300, 500, 100); header("Content-type: image/jpg"); imagejpeg($image); imagedestroy($image); ?>[/code]
  20. Hehe, glad it works. The defined location is a matter of preference, you could just as easily put the path in where HANDLE is, nothing special in defining it. Generally speaking, if you are going to be uploading a number of things, it is convenient to define a location. There is a convenient PHP function that looks at picture formats, if you are interested! It saves the hassle of stripping off the extension, it is: [a href=\"http://us3.php.net/exif_imagetype\" target=\"_blank\"]exif_imagetype()[/a] [php.net]
  21. It is a matter of transit time, not the PHP script. It all depends on how many servers the email has to go through before it reaches the destination and how long each server holds it.
  22. Use eval(), it will look something like -- eval($result['script'];); maybe eval($result['script'] . ';'); I'm not sure of the syntax, I have never used it.
  23. Yes, I know it isn't very encouraging being told the script works fine :x Try this one: [code]<?php $image_y = imagecreate(500, 500); $colourYellow = imagecolorallocate($image_y, 255, 255, 0); imagefill($image_y, 0, 0, $colourYellow); $image_b = imagecreate(50, 50); $colourBlack = imagecolorallocate($image_b, 0, 0, 0); imagefill($image_b, 0, 0, $colorBlack); imagecopy($image_y, $image_b, 50, 50, 0, 0, 50, 50); header("Content-type: image/png"); imagejpeg($image_y); ?>[/code] It should do the same thing, just a little differently. If that doesn't work, the problem doesn't lie in the PHP.
  24. What are you trying to accomplish, I guess is the first question that needs to be answered. Yes, an advanced search...but that is an interesting term because any search is necessarily advanced :) Do you just want to search for multiple things in a specified field? Say, do you want your user to be able to say I want to search for Jon in the name field or do you it to search in a BUNCH of fields with one parameter? I will do my best to set you on your way with little knowledge of the inquiry at hand -- First, most database searches will trim whitespace off of the input, this is standard for the next step...verify that the user entered something. So, we will use $name throughout this 'guide', $name = trim($name); then if (!$name) { die("You did not enter a search term"); } because trim would have trimmed off a single space and left it blank, this simple test will verify that a term was entered or else it will murder the script with an error. Next, you are going to want to escape any user input that you are going to be searching for, you can get nasty MySQL injection hacks if you aren't careful to properly monitor all user input...so, get_magic_quotes_gpc() is a function that checks to see if MySQL escaping is automagically enabled, we proceed like so: if (!get_magic_quotes_gpc()) { $name = addslashes($name); } and there we now have a fairly safe term to search for! That is where the code you thought most of the work will be comes into play... $query = "SELECT * FROM tablename WHERE field1 LIKE \"%$trimm%\" OR field2 LIKE \"%$trimm%\" OR field3 LIKE \"%$trimm%\" ORDER BY field1 DESC"; That is just horrid, you could set it up more attractively with something like this: $query = "SELECT * FROM tablename WHERE name like '%$name%'"; that will search for name in the name table...now, if you want to search for the input $name (or general input) in a BUNCH of tables, like shown above: $query = "SELECT * FROM tablename WHERE name LIKE '%$name%' OR keyword LIKE '%$name%' OR city LIKE '%$name%'"; '%...%' is just a fancy way of saying similar to instead of name=$name, more syntax to remember, in a way. Now, if you want to search for multiple terms, you can easily figure that out. You could also explode the input string on spaces and iterate through the search for each element if you wanted to search for all terms, like they've done with the foreach loop, basically, it is taking the exploded array and assigning the variable $trimm to each value in the array and searching for it in the fields (field1, field2, etc.). If you want to search by relevance, I think that is beyond the scope of a help forum :) HTH
  25. I agree with wickning1, the cookie is definitely the first thing you want to verify...when I am debugging a script that involves a database query, I like to echo the query and kill the script directly after that. So, just to make sure everything is going according to plan, try inserting: $sql="UPDATE members SET credits=(credits + .5) WHERE user_name='$owner'"; print $sql; die; and see if everything looks correct. If you try to increment a non-interger field in a MySQL table, it will simply over-write the data in the field and insert 0.5 -- it shouldn't fail. Other than that, there really isn't anything that could fail without warning unless either members, credits, user_name or $owner don't exist.
×
×
  • 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.