Jump to content

cjohnweb

New Members
  • Posts

    8
  • Joined

  • Last visited

    Never

About cjohnweb

  • Birthday 07/09/1987

Contact Methods

  • Website URL
    http://iluvjohn.com/

Profile Information

  • Gender
    Male
  • Location
    Auburn, Ca

cjohnweb's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I really like this, I never realized that you could handle errors like that. Worth checking out if you haven't already.
  2. Yesterday my brother came to me with an Open Office Database file. Among everything in the file, he had a few sections that were basically excel looking spread sheet type tables with his inventory in them. I messed with the Open Office program and I can't find a way to export his content into any other file format. I can parse a CSV or the like to get it into MySQL, but I just can't figure out how to get the content into a different file format. Anyone else do this before? suggestions? Alternative programs to OpenOffice that could let me export in other formats? Thanks in advance!
  3. Hey there, My name is John. I have been coding PHP / MySQL for 9 years or so now. I am 23 years old. I play guitar, bass, drums, etc. My hobbies have been between programming and playing music for so long it is basically the core of my spare time. Some of my favorite things to code are things that are automated and collect information; For example I wrote a script to scrape torrents from ThePirateBay. Made a bot for yuwie.com once but it doesn't work anymore. Recently I spend more of my time writing in my blog @ http://iluvjohn.com/. I write whatever I feel like writing but most of it is programming stuff. I have not jumped into the OOP PHP yet, but I have started to with my introduction to XPath. I have also been starting to learn C / C++, and a language called SPIN for an embedded chip known as the Propeller by Parallax. PHP is like my second language though, so I am happy to be here!
  4. Well....yeah! I mean, if that's what the need of the script calls. For instance, I run xampp on my laptop for development, etc. I can't send emails so I suppress them cause they are ugly. ...Not to mention that I was specifically answering one of the original questions: But for most circumstances, yes, you would want to fix the problem and not just cover it up ...otherwise stuff won't work, duh! I actually just noticed that like 17 minutes before I actually posted someone else went in there and mentioned using @ to suppress errors. Damn, I was too late. Oh well.
  5. It sounds to me as though you need PHP XPath! I don't know how familiar you are with XML, but I'll try to cover the basics for you: XML is more of a format than anything else. For instance, Instant Messenger programs such as Google Talk use the JABBER protocol to communicate, which uses XML to communicate. Because of the way tags are nested into each other there is also a parent/child relationship between each entry/tag. An HTML document for instance is an XML document formatted to HTML specifications. So taking HTML aside, an XML document could look like anything you want, example: <?xml version="1.0"?> <whateveryouwant> <tag1> <tag2>Some info</tag2> <another-tag attribute="xxx">Other information</another-tag> </tag1> <tag name="tag2"> <tag2>Some info</tag2> <another-tag attribute="xxx">Other information</another-tag> </tag> </whateveryouwant> You can see how an XML document can be used to transfer nearly any data in an organized manner. Thus you can see that HTML is in fact an XML document, just written to HTML specifications. Now let's get to the heart of the matter: XPath uses expressions to identify specific pieces of information within an XML document. XPath is much simpler than regular expressions too, so you will be able to modify it to meet your needs really easily! So here is what I suggest: If you can, your text files should be in an XML/HTML format. Use PHP to open the file and load the content into a variable. Here is my working example, I tested it too: xpath-test.php <?php $filename = "txt-file.txt"; // xml formatted text file... // open the file and load contents into $string $fh = fopen($filename, "r") or die("Can't open file"); $string = fread($fh, filesize($filename)); fclose($fh); // Get it ready for XPath $xml = new SimpleXMLElement($string); // Specify your XPath query / expression $result = $xml->xpath('/body'); // Loop through each result XPath has returned while(list( ,$node) = each($result)) { echo '/body: ',$node,"\n"; } ?> txt-file.txt <?xml version="1.0"?> <body> This line of information will be pulled because it is in between the body tags! </body> The script should output the following: /body: This line of information will be pulled because it is in between the body tags! Good luck! Find more information on XPath formatting: My original blog post on this: http://iluvjohn.com/knowledge-database/computers/general-cross-platform/web-internet/php-mysql-curl/xpath/php-xpath-xml-formatting-722/ The W3C XPath Tutorials: http://www.w3schools.com/xpath/default.asp Wikipedia: http://en.wikipedia.org/wiki/XPath The W3C on Xpath: http://www.w3.org/TR/xpath/
  6. If you need to suppress errors but don't want to suppress all the error on the whole site / page you can place an "at" sign before the function. Examples: @mail($to,$sub,$msg,$headers); $mail = @mail($to,$sub,$msg,$headers); if($mail){echo "Email sent";}else{echo "email error";} $url = "http://www.google.com/"; $content = @file_get_contents($url); echo $content; Good luck!
  7. Hey there, The PHP GD Image stuff doesn't have an "align" function, all nice and neat like html does. It actually uses set widths, heights, and positioning all specified in Pixels. So in order to align right you basically need to trial and error because the text may be cut off on the right side as the text is printed left to right. It is actually a lot easier to align left that it is right. I want to share with you a script I wrote a few months ago that basically places text into an image. You give the script a .ttf true type font file, some text, image height and width, font color, background color, transparent background yes or no, text position...a few other things....and it pops out a nice PNG image. The script does not need any configuration, just plop it into your images folder or something and view the sample.php in your browser. sample.php is a nice generator / front end where you enter the info into a form and it generates a sample image and gives you the code to place the image on another html page. Any questions, direct them to john@iluvjohn.com I am not sure if this would help you, but as I understand it you simply want to get PHP to output an image, correct? I have a little tool I wrote in PHP; a single file with no need for configuration. If you have the GD image library working it will place text into an image. It has code/usage samples: A code generator and a .js script to add reflection to the bottom of the image for really nice headers and things of the like.... PHP GD Text<->PNG Creator: http://iluvjohn.com/welcome-to-iluvjohn/custom-fonts-on-a-website-with-php-704 Good luck!
  8. I have never really used fsocks myself, but I have used PHP Curl, and it can return Apache codes. One of the curl settings displays the headers of the connection to Apache, as such, here is a script and its output run from my laptop (Xampp is Apache, PHP, etc) HTTP/1.1 301 Moved Permanently Date: Sat, 22 May 2010 21:24:06 GMT Server: Apache/2.2.15 (Unix) mod_ssl/2.2.15 OpenSSL/0.9.8n DAV/2 mod_fcgid/2.3.5 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 X-Powered-By: PHP/5.2.13 X-Pingback: http://iluvjohn.com/xmlrpc.php Location: http://iluvjohn.com/ Content-Length: 0 Content-Type: text/html; charset=UTF-8 So as you can see, after the HTTP/1.1 you have 301 Move Permanently. I am sure you can get the rest from there. The code below was tested and produced the header above. Goodluck ~John http://iluvjohn.com <?php $url = "http://www.iluvjohn.com/"; // the url we want to grab $cookie_file = "cookie.txt"; // specify writable cookie txt file for cookies to be stored //$post = "username=john&password=pass"; // post info, leave blank if we dont need it $refer = "http://www.google.com/search?hl=en&q=fsockopen%20tcp"; // refering url if(is_writable($cookie_file)){ $handle = fopen($cookie_file, 'w'); fclose($handle); }else{ die("<div class=\"error\">Can't write to $cookie_file cookie file.</div>"); } $ch = curl_init(); // start curl handler curl_setopt($ch, CURLOPT_URL, $url); // what url you are going to access curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); // I have never used this. if(!empty($post)){curl_setopt ($ch, CURLOPT_POSTFIELDS, $post);} // Send post info, like an html form curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); curl_setopt($ch, CURLOPT_HEADER, 1); // Use this to specify if you want headers returned or not. Set to 0 or 1 curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"); // user agent curl_setopt($ch, CURLOPT_COOKIESESSION, TRUE); // Cookies curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file); // Cookies curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file); // Cookies if(!empty($refer)){curl_setopt($ch, CURLOPT_REFERER, $refer);} // refer is the url you are coming from curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return the page content we accessed $result = curl_exec($ch); // execute the curl settings we set, this is where the actual curl process happens. curl_close ($ch); // close the curl handler echo $result; ?> [attachment deleted by admin]
  9. Hello all! I have been programming PHP/MySQL for about 6 years now. I have never had an issue like this ever, so I hope someone could shed some light. I made a website for a client, www.thelearningxchange.org. It is up right now, hosted with HostGator.Com. The client I built it for has been promoting it like mad these last few weeks, and it seams everyone else has some sort of issue with the site. Here is the most recent issue that I have no idea how to solve. Here is an email we received: The guy that reported this is a University Professor of some sort, so the computers antivirus at their University shouldn't be wrong, right? I can not find "http://10.4.1.2:9014/images/dotted-divider.gif" anywhere on the site. What should I do? Thanks!! ~John
×
×
  • 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.