Jump to content

Alex-Grim

Members
  • Posts

    58
  • Joined

  • Last visited

    Never

Everything posted by Alex-Grim

  1. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 's set up and you\''ve rebooted, log into your desktop and look for the network i' at line 1 The part where it says "you\''ve" is what concerns me. In my code, i tell it to replace a single quote with two single quotes. I don't know where the hell the backlash is coming from, but i'm guessing that php is doing it automatically. How can i stop this, so that it doesn't convert my words into weird characters (see the characters in the article i just posted at the link below to see what i'm talking about). Because that backlash is in there, and because i'm replacing single quotes, php is interpreting the slash as whitespace type stuff, and generating wired characters. http://linuxintro.com/?con=Fstab01 Thanx
  2. Hey, my host had me under php4, but i got them to switch me to 5. Btw, i like the trick for renaming the extention to php5, it worked. Thanx for your help, and i guess i'll mark this thread closed, since i don't need to find another way now
  3. I'm not really used to working with php yet, or xml, so this is a new topic to me. I wrote a script that uses the php simpleXMLElement() class to update my rss feed when i write a new topic on my site. All it does, is load the rss file, and append a new item to it, and write it back to disk. It's works great, i love having this function! The problem is that when i uploaded it to my host (Godaddy.com), it stopped working, claiming that i am calling a non existant class. I called them and they claim that that means that i have a script error, but i know better: It means that they don't support it. So, that leads me to my question. What is the most COMMON method used to manipulate xml in php? I've been doing a little homework, and have seen the xmlReader and xmlWriter and DomXml classes, but they are a little advanced, and not readily understood. Hell, i don't even know if they're even capable of doing what i'm trying to do. I'd prefer something simple (if there is something more simple than simpleXML! I love this thing), because i'm still new, but whatever will work, will work for me. Btw, just in case I'M wrong, here's the error: Fatal error: Cannot instantiate non-existent class: simplexmlelement in /var/www/... Thanx
  4. I fixed it, here's the resulting code: $xml = new SimpleXMLElement("../rss/NewArticles.rss",null,true); $item = $xml->channel[0]->addChild("item"); $item->addChild("title", $_POST['title']); $item->addChild("description", substr($_POST['contents'],0,666)); $item->addChild("link","http://LinuxIntro.com?con=".$_POST['name']); $item->addChild("guid","http://LinuxIntro.com?con=".$_POST['name']); echo $xml->asXML(); //fwrite($,$); Btw, i love your avatar. Now to work on getting it to write to my rss file...
  5. Changed code to this... $xml = new SimpleXMLElement("NewArticles.rss",null,true); $item = $xml->addChild("item"); $item->addChild("title", $_POST['title']); $item->addChild("description", substr($_POST['contents'],0,666)); $item->addChild("link","http://LinuxIntro.com?con=".$_POST['name']); $item->addChild("guid","http://LinuxIntro.com?con=".$_POST['name']); echo $xmlFile->asXML(); And now i'm only getting this error: Fatal error: Call to a member function asXML() on a non-object in /var/www/html/Alex/LinuxIntro/terminal/CreateContent2.php on line 26
  6. I changed my code and amended this: if (file_exists('NewArticles.rss')) { $xmlFile = simplexml_load_file('NewArticles.rss'); print_r($xml); } else { exit('Failed to open test.xml.'); } And it's finding the file, it just can't read it...
  7. The path should be correct, so i doubts that's the problem, and the file is a valid rss feed: <?xml version="1.0" encoding="ISO-8859-1" ?> <rss version="2.0"> <channel> <title>LinuxIntro.com</title> <description>A great place to learn Linux! Featuring Video lessons, examples, and more</description> <link>http://LinuxIntro.com/</link> <language>en-us</language> <webMaster>[email protected]</webMaster> <item> <title>Dark Elysium's website's are down for a while</title> <description>The both AlexGrim.com and GrimMusic.com are down for a while.</description> <link>http://GrimMusic.com</link> <guid isPermaLink="true">http://GrimMusic.com</guid> </item> <item> <title>Register as an official Linux user!</title> <description>If you use linux, you can add yourself to the registered user db.</description> <link>http://counter.li.org</link> <guid isPermaLink="true">http://counter.li.org</guid> </item> </channel> </rss> Here's my error: Warning: SimpleXMLElement::__construct() [function.SimpleXMLElement---construct]: Entity: line 3: parser error : Start tag expected, '<' not found in /var/www/html/Alex/LinuxIntro/terminal/CreateContent2.php on line 12 Warning: SimpleXMLElement::__construct() [function.SimpleXMLElement---construct]: in /var/www/html/Alex/LinuxIntro/terminal/CreateContent2.php on line 12 Warning: SimpleXMLElement::__construct() [function.SimpleXMLElement---construct]: ^ in /var/www/html/Alex/LinuxIntro/terminal/CreateContent2.php on line 12 Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in /var/www/html/Alex/LinuxIntro/terminal/CreateContent2.php:12 Stack trace: #0 /var/www/html/Alex/LinuxIntro/terminal/CreateContent2.php(12): SimpleXMLElement->__construct('??') #1 {main} thrown in /var/www/html/Alex/LinuxIntro/terminal/CreateContent2.php on line 12 Thanx in advance, i'd really like to fix this one.
  8. Thanx guys, this problem has been solved: http://www.phpbuilder.com/board/showthread.php?&t=10348765 Evidently, the ini file didn't like my = sign...
  9. I have, several times.
  10. I have to put this at the top of all my scripts: ini_set('display_errors', 1); error_reporting(E_ALL | E_STRICT); which sux, because, well, i shouldn't have to --for starters, and when i go to upload my crap to my host, i'm sure that i'm going to forget to go through all my files and take that out first. But the settings in my php.ini file are not making a difference. I've tried changing the display_errors parameter to "on", "On", and "1", all to no avail. I also have had the error reporting section set to E_ALL, and now E_STRICT. Nothing is different... Here's my ini file: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Error handling and logging ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; error_reporting is a bit-field. Or each number up to get desired error ; reporting level ; E_ALL - All errors and warnings (doesn't include E_STRICT) ; E_ERROR - fatal run-time errors ; E_RECOVERABLE_ERROR - almost fatal run-time errors ; E_WARNING - run-time warnings (non-fatal errors) ; E_PARSE - compile-time parse errors ; E_NOTICE - run-time notices (these are warnings which often result ; from a bug in your code, but it's possible that it was ; intentional (e.g., using an uninitialized variable and ; relying on the fact it's automatically initialized to an ; empty string) ; E_STRICT - run-time notices, enable to have PHP suggest changes ; to your code which will ensure the best interoperability ; and forward compatibility of your code ; E_CORE_ERROR - fatal errors that occur during PHP's initial startup ; E_CORE_WARNING - warnings (non-fatal errors) that occur during PHP's ; initial startup ; E_COMPILE_ERROR - fatal compile-time errors ; E_COMPILE_WARNING - compile-time warnings (non-fatal errors) ; E_USER_ERROR - user-generated error message ; E_USER_WARNING - user-generated warning message ; E_USER_NOTICE - user-generated notice message ; ; Examples: ; ; - Show all errors, except for notices and coding standards warnings ; ;error_reporting = E_ALL & ~E_NOTICE ; ; - Show all errors, except for notices ; ;error_reporting = E_ALL & ~E_NOTICE | E_STRICT ; ; - Show only errors ; ;error_reporting = E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR ; ; - Show all errors, except coding standards warnings ; error_reporting = E_STRICT ; Print out errors (as a part of the output). For production web sites, ; you're strongly encouraged to turn this feature off, and use error logging ; instead (see below). Keeping display_errors enabled on a production web site ; may reveal security information to end users, such as file paths on your Web ; server, your database schema or other information. display_errors = 1 ; Even when display_errors is on, errors that occur during PHP's startup ; sequence are not displayed. It's strongly recommended to keep ; display_startup_errors off, except for when debugging. display_startup_errors = Off ; Log errors into a log file (server-specific log, stderr, or error_log (below)) ; As stated above, you're strongly advised to use error logging in place of ; error displaying on production web sites. log_errors = On ; Set maximum length of log_errors. In error_log information about the source is ; added. The default is 1024 and 0 allows to not apply any maximum length at all. log_errors_max_len = 1024 ; Do not log repeated messages. Repeated errors must occur in same file on same ; line until ignore_repeated_source is set true. ignore_repeated_errors = Off ; Ignore source of message when ignoring repeated messages. When this setting ; is On you will not log errors with repeated messages from different files or ; source lines. ignore_repeated_source = Off ; If this parameter is set to Off, then memory leaks will not be shown (on ; stdout or in the log). This has only effect in a debug compile, and if ; error reporting includes E_WARNING in the allowed list report_memleaks = On ;report_zend_debug = 0 ; Store the last error/warning message in $php_errormsg (boolean). track_errors = Off ; Disable the inclusion of HTML tags in error messages. ; Note: Never use this feature for production boxes. ;html_errors = Off ; If html_errors is set On PHP produces clickable error messages that direct ; to a page describing the error or function causing the error in detail. ; You can download a copy of the PHP manual from http://www.php.net/docs.php ; and change docref_root to the base URL of your local copy including the ; leading '/'. You must also specify the file extension being used including ; the dot. ; Note: Never use this feature for production boxes. ;docref_root = "/phpmanual/" ;docref_ext = .html ; String to output before an error message. ;error_prepend_string = "<font color=ff0000>" ; String to output after an error message. ;error_append_string = "</font>" ; Log errors to specified file. ;error_log = filename ; Log errors to syslog (Event Log on NT, not valid in Windows 95). ;error_log = syslog Thanx
  11. Solved. : http://phpbuilder.com/board/showthread.php?p=10840762#post10840762 I misspelled function, and i can use errors now too. Thnx for your help guys.
  12. If i could, i would LOVE to, but that's another story too: http://www.phpfreaks.com/forums/index.php/topic,172044.msg762415.html#msg762415
  13. That was a GREAT idea, i forgot about a class's constructor (or whatever it's called). But, unfortunately, that didn't work....
  14. Thank you, you probably just saved me time after we get this imediate problem fixzed. But at the moment, the problem is in the class file. I'm sure now, because i deleted all the code in the calling file, except wheere i call the class, and it still dies.
  15. Simply calling the page to be included is where it's being stopped. I have commented out where i tired to instantiate it and use it, to see if merely including it would kill the page, and as you can see, it does, so the error must be in the class file... Even THIS kills it: <?php include_once("variables.php"); ?> ===Edit=== And YES, they're in the same directory
  16. Yes, as you can see, i'm calling the class file, but i'm not even using it yet, and it's still killing the page.
  17. <?php include_once("variables.php"); include_once("../classes/MySql.php"); //$uvar = new UserVars(); $db = new MySql(); $con = $db->C(); $name = $_POST['name']; $phone = $_POST['phone']; $email = $_POST['email']; $comment = $_POST['comment']; $uri = str_replace("http://","",$_POST['uri']); //echo $name . $br; //echo $phone . $br; //echo $email . $br; //echo $comment . $br; //echo $time . $br; //echo $ip . $br; //echo $ip2 . $br; //echo $uvar->browser . $br; //echo $uvar->agent . $br; //echo $uvar->os . $br; //echo $uvar->dist . $br; echo $uri . $br; //$q = $db->Q("Insert into Comments (name,phone,email,comment,uri,commentdate,ipaddy,ipforward,useragent,browser,distro,platform)values('$name','$phone','$email','$comment','$uri','$uvar->time','$uvar->ip','$uvar->ip2','$uvar->agent','$uvar->browser','$uvar->dist','$uvar->os')"); ?>
  18. This was just an included script, but i changed it to be oo, and now it's broken. If you take out all the code between the class definitaion, it doesn't stop page execution, but i've tried taking out sections of the code, and no matter what section i remove, it's not allowing the page to execute, so i don't know what it is, i can't see any errors. Here it is: <?php class UserVars{ $uagent = $_SERVER['HTTP_USER_AGENT']; function time(){ date_default_timezone_set('UTC'); return date('Y-m-d H-i-s'); } function agent(){ return $uagent; } function browser(){ if (ereg("MSIE",$uagent)) { $browser = "IE"; } elseif (ereg( "Opera",$uagent)) { $browser = "Opera"; } elseif(ereg("Firefox",$uagent)) { $browser = "Firefox"; } elseif(ereg("Safari",$uagent)) { $browser = "Safari"; } else { $browser= "other"; } return $browser; } function os(){ if (ereg("Win",$uagent)) { $os="Win"; } else if (ereg("Mac",$uagent)) { $os="Mac"; } else if (ereg("Linux",$uagent)) { $os="Linux"; } else if (ereg("Unix",$uagent)) { $os="Unix"; } else { $os="Other"; } return $os; } funtion dist(){ if (ereg("Fedora",$uagent)) { $distro="Fedora"; } else if (ereg("Ubuntu",$uagent)) { $distro="Ubuntu"; } else if (ereg("Debian",$uagent)) { $distro="Debian"; } else if (ereg("FreeBSD",$uagent)) { $distro="FreeBSD"; } else if(ereg("NT 4.0",$uagent)) { $distro="NT"; } else if (ereg("NT 5.0",$uagent)) { $distro="2000"; } else if (ereg("NT 5.1",$uagent)) { $distro="XP"; } else if (ereg("NT 5.2",$uagent)) { $distro="XP"; }else if (ereg("NT 6.0",$uagent)) { $distro="Vista"; } else { $distro="Other"; } return $distro; } function ip(){ return $_SERVER['REMOTE_ADDR']; } function ip2(){ if ($ip2 = getenv('HTTP_CLIENT_IP')) {} elseif ($ip2 = getenv('HTTP_X_FORWARDED_FOR')) {} elseif ($ip2 = getenv('HTTP_X_FORWARDED')) {} elseif ($ip2 = getenv('HTTP_FORWARDED_FOR')) {} elseif ($ip2 = getenv('HTTP_FORWARDED')) {} else { $ip2 = "0"; } return $ip2; } } ?> Thanx
  19. Thanx, that fixed it. I got another error afterwards about not being able to connect on 127.0.0.1(13), but i changed it from 127.0.0.1 to "localhost" and it's fine now, but i wonder what the difference really is. Thanx again.
  20. As you can see from the code, i've declared all the variables in the class already, becasue they'll not change, but for some reason, when i try to connect and execute a query, i get : Access denied for user 'apache'@'localhost' (using password: NO) But i've sent the password and the user name in my script? <?php echo "<h1>MySql.php is now included</h1>"; class MySql{ var $d="AlexGrim"; var $h="127.0.0.1"; var $u="webuser"; var $p="666"; var $connection; var $query; var $num; var $array; var $rows; // function MySql($h,$u,$p,$d){ // $this->d = $d; // $this->h = $h; // $this->u = $u; // $this->p = $p; // } function Connect(){ $connection = mysql_connect("$h","$u","$p"); mysql_select_db("$d", $connection); } function Close(){ mysql_close($this->connection); } function Query($sql){ $query = mysql_query($sql) or die(mysql_error()); return $query; } function FetchRow($query){ $rows = mysql_fetch_row($query); return $rows; } function FetchArray($query){ $array = mysql_fetch_array($query); return $array; } function FetchNum($query){ $num = mysql_num_rows($query); return $num; } } ?> And here's the calling page, ignore the testing crap: <?php $br = "<br/><br/>"; $e = "<h1>ErRoR</h1>"; $myfile = "includes/classes/MySql.php"; if (file_exists($myfile)){ echo "The file DOES exist. $br"; include_once($myfile); echo "Page Loaded, and MySql.php included. $br"; }else{ echo ($e."<h1>ErRoR! Content not available!</h1>"); } $db = new MySql(); $con = $db->Connect(); $q = $db->Query("Select * from Comments"); ?>
  21. Disregard that last comment. The cause was that there were errors in the second file, so it couldn't load it , but that brings me back to the reason i started this thread: why am i not getting any errors....
  22. The funny thing is, the leading slash is the shorthand way of saying "webroot", and works for everything else in a website (css, html, javascript, etc), but that got past one error after removing it, thatnx. The next problem is that i'm still not loading the page, and now it stops executing after the readfile() method. Here's the madification i made to the code: if (file_exists($myfile)) { echo "The file DOES exist. $br"; include_once($myfile); echo "Page Loaded, and MySql.php included. $br"; } I get the first echo, and nothing else after that.
  23. I could be completely overlooking something in the path (i've been up for 2 days working on a flash website, now this). Here's a screenshot of Gedit, you can see the path in the top, and the file name in the tab -- wel, you know what the hell you're looking at, duh (i keep forgetting i'm talking to OTHER LINUX/Unix users for a change). http://phpbuilder.com/board/attachment.php?attachmentid=3357&d=1197629225 ===Edit=== I meant to add, AlexGrim is the root web folder, so the path is relative to that. One thing i want to ask is, do i have to have my includes folder listed in my includes path (if there is such a thing, which i'm sure there is). This can't be the problem though, because it's saying the file cannot be found even by the readfile() method. I use readfile() for my other site (LinuxIntro.com) to load the content into the Index (only) page, and i don't have anything listed in my include path.
  24. I meant to include this: display_errors On On display_startup_errors Off Off doc_root no value no value docref_ext no value no value docref_root no value no value enable_dl On On error_append_string no value no value error_log no value no value error_prepend_string no value no value error_reporting 2048 2048
  25. yeah, i turned on the display_errors and restarted apache, and i still get no errors, other than the ones i use in my script. I've also tried screwing up the code on purpose, and still, nothing.
×
×
  • 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.