Jump to content

Gaia

Members
  • Posts

    95
  • Joined

  • Last visited

    Never

Everything posted by Gaia

  1. I'm a noob. I searched everywhere but the PHP docs . Thanks for the link, worked like a charm.
  2. Nice to see surpasshosting.com on the list. They are an amazing company.
  3. For Windows I use SmartFTP, great program. For my Mac I use Cyberduck. Has been working so far without any difficulties.
  4. Hi, I'm trying to extract data from an Atom feed using PHP. I can get the title and published/updated date, but am having a hard time figuring out the path to the link="href" section of the Atom feed. I have $xml->entry->link, but when I try to go any further it results in an empty result. How do I finish the query to extract the link data? Here is a print_r of $xml->entry->link SimpleXMLElement Object ( [@attributes] => Array ( [href] => /p/doulx ) ) I've never tried to extract data from an Atom feed before and am finding it difficult. Any tips would be great. thanks.
  5. I think the issues I am having are due to the following code: $sql = "SELECT COUNT(*) FROM entries WHERE nickname LIKE '%$nickname%' OR ip LIKE '$partial_ip%' AND deleted = 0"; if ($res = $db->query($sql)) { if ($res->fetchColumn() > 0) { $is_dup = 1; } else { $is_dup = 0; } } When I attempt to re-build it using the example from PHP.NET docs, I get an error: $sql = "SELECT COUNT(*) FROM entries WHERE nickname LIKE '%$nickname%' OR ip LIKE '$partial_ip%' AND deleted = 0"; if ($res = $db->query($sql)) { // Check the number of rows that match the SELECT statement if ($res->fetchSingle() > 0) { echo 'Entries found'; } // No rows matched -- do something else else { print "No rows matched the query."; } } Error: Fatal error: Call to undefined method PDOStatement::fetchSingle() in /home/gaia/public_html/xx/classes/class.manage.php on line 55 I am taking this directly from the PHP docs, so why would it not work?
  6. Hmm, still getting the same error message. I really don't know why this is being so problematic.
  7. Couldn't locate the edit button: However, I think it is saying this query was not complete, or closed? $sql = "SELECT COUNT(*) FROM entries WHERE nickname LIKE '%$nickname%' OR ip LIKE '$partial_ip%' AND deleted = 0"; if ($res = $db->query($sql)) { if ($res->fetchColumn() > 0) { $is_dup = 1; } else { $is_dup = 0; } }
  8. Hmm, I am getting this error from PDO. As far as i know,no other queries are active... I have a common.php that initiates the class, and at the end i include footer.php that nulls out $db ( $db=NULL; ).
  9. But doesn't that defeat the purpose of assigning it to $query? Wouldn't I just do the following and it be the same then? $db->prepare("INSERT INTO entries VALUES ('0','$admin', '$admin_ip', '$nickname', '$nick_ip', '$date', '$reason', '$action','','','0','','','','$is_dup')"); $db->execute();
  10. I think I corrected the problem. The $config array is in a file called class.config.php. The config vars are in another file called config.php. Hopefully you guys can help me with another issue now, with the same script. I have a form where you can add things to a database, which uses a class called manage::add which is located in class.manage.php. manage::add also uses a var named $db which initiates a PDO connection. $db is declared in a file called common.php. common.php: // // Initiate the database connection // $db = new PDO('mysql:host=localhost;dbname=xx', 'xx', 'xx'); // // Get the class that contains the config info // require_once("classes/class.config.php"); $config = new config(); // // Get the class that controls entries // require_once("classes/class.entries.php"); $entries = new entries(); // // Class the manages deleting, editing, etc // require_once("classes/class.manage.php"); $manage = new manage(); // // Get the session class & start it // require_once("classes/class.session.php"); $session = new session; $session->start(); // // Set default timezone ( PHP 5+ only ) // date_default_timezone_set('GMT'); class.manage.php: class manage extends entries { public $edit_form; // // Add an entry // public function add($post_info=array()) { global $db; // // Make sure there are no blank fields // if ( in_array("",$post_info) ) { echo '<div class="entry">You left a field blank!</div>'; } else { $admin = $post_info['admin']; $admin_ip = $post_info['admin_ip']; $nickname = $post_info['name']; $nick_ip = $post_info['ip']; $date = $post_info['date']; $reason = $post_info['reason']; $action = $post_info['action']; $partial_ip = manage::break_ip($nick_ip); $partial_ip = $partial_ip[0].'.'.$partial_ip[1]; $sql = "SELECT COUNT(*) FROM entries WHERE nickname LIKE '%$nickname%' OR ip LIKE '$partial_ip%' AND deleted = 0"; if ($res = $db->query($sql)) { if ($res->fetchColumn() > 0) { $is_dup = 1; } else { $is_dup = 0; } } $query = $db->prepare("INSERT INTO entries VALUES ('0','$admin', '$admin_ip', '$nickname', '$nick_ip', '$date', '$reason', '$action','','','0','','','','$is_dup')"); $query->execute(); //Send to home page $host = $_SERVER['HTTP_HOST']; $uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\'); $extra = 'index.php'; header("Location: http://$host$uri/$extra"); exit(); } } ....... some more below, but only concerns the above method When I attempt to submit the form, I get the following error saying that $db is non-object: I figured setting it as a global $db would allow the use of $db in another file?
  11. The path seems to exist, when I do the following, it works: class config { private $config_path; // // Get a configuration value from the config file // public function get_config($config_name) { require( '/home/gaia/public_html/ae/includes/config.php'); $value = $config[$config_name]; return $value; } } I tried the previous code on another server, and got the following error: So, it looks like the var isn't being passed into the module for some reason.
  12. I am still learning OOP, so I am bound to make noobish mistakes. See below: class config { private $config_path = '/home/gaia/public_html/xx/includes/config.php'; // // Get a configuration value from the config file // public function get_config($config_name) { require($this->config_path); $value = $config[$config_name]; return $value; } } I think the private $config_path may be wrong or I need to declare it differently?
  13. Yes, however, I was hoping there might be some general suggestions/thoughts of the issue. It is a couple pages of code, so I wasn't sure that posting it all here would be efficient. I will go through it and try to copy/paste the main area's that I think are causing the issues. I am at work so I don't have the code handy. I will update once I have the exact code. Until then, is it possible to initiate a class, within a class? For example, if i have class.one.php and class.two.php. Can I run an 'include' function to include class.one.php in class.two.php and initiate it without problems? I am currently doing that right now, and it works in my environment, but not the other. Was another reason I was curious if there were any PHP updates that perhaps restricted that kind of coding for some reason. I'm not the best at explaining things . Hopefully my code will be of more help.
  14. Hi, Not really sure how to direct this certain issue I am having. I built a PHP script that uses OOP on a PHP 5.2.3 environment. It is working fine in that environment. However, once I copied it over a PHP 5.2.5 enviromnet, it doesn't seem to like it. It comes up in IE as Programming Error or Unavailable Page. Does not show any error messages at all either, I even tried setting the error reporting to E_ALL and still no luck. Just hoping for some suggestions on how to pin-point the exact issue. I have been commenting out small pieces of code but it just does not seem to be parsing the classes correctly. Are their any major updates from 5.2.3 to 5.2.5 that may cause issues? Like restrictions on how classes can be used? Thanks in advanced for any info or suggestions anyone has.
  15. Thanks, . Here is the direct URL when a PHP session ID is added: http://phpfreaks.com/forums/index.php?PHPSESSID=7b70f0773ab05f62c1b71364a82a5a91;www
  16. Hi All, When I go to phpfreaks.com, the redirection set in place does not work correctly if there is a session ID attached, there is a 'www' attached to the end of the URL, which is causing the issue http://www.phpfreaks.com/forums/index.php?www The above works fine, but when first visiting the site, a session gets added on so it ends up being a session ID + www, which the browser doesn't understand. Not sure if it's already known or not, but figured I would pop it in here .
  17. From taking a look, the following part in your log in form does not look correct at all: [b]$_SESSION['userlevel'] = $userlevel;[/b] I am surprised your PHP file isn't throwing up an error. Also, what is the User Level table called in your database, and, is there any content in it?
  18. I would not get angry at all. Though, nothing much going on at my site worth getting upset over. What I can't really understand is why people get soooooooo upset over such small things. Specially those who have no idea how the Internet/Computers works, as they are the one's who are the most upset. And that is all they do too! They threaten this and that but never actually switch hosts. I mean, if I was that upset over a single host, I would do the smart thing and leave, not sit there and complain for weeks on end about the bad service. Sorry for the rant, I'm in the Webhosting support business so I hear a lot of it .
  19. IPB for me. Though vB comes in a very close second. They both have their pros and cons.
  20. Self taught. Though, I took some other programming classes such as C++ that probably didn't hurt in helping out.
  21. Gaia

    PHP Version?

    Version 5 hands down. Gotta love PDO and OOP .
  22. I quite like UseBB as a free forum software :)
  23. Thanks, switching the value to 0 worked. I will have to look up on that a bit .
  24. Hi, Not sure if this is really MySQL related or PHP related, sorry if I am posting in the wrong spot! I have a PHP application that uses PDO FrameWork. I have moved it to another web server and now I am having a bit of trouble. Here is the MySQL query: $query = $db->prepare("INSERT INTO entries VALUES ('','$admin', '$admin_ip', '$nickname', '$nick_ip', '$date', '$reason', '$action','','','','','','','$is_dup')"); $query->execute(); The first value is 'id' and is, of course, set to auto_increment. However, PDO is not allowing the value to be empty for some reason. It is throwing out the following error: As far as I know the auto increment field is supposed to be empty/null ? Anyone have any insight on this? Would this perhaps be something caused by MySQL 5.0? I believe the last server was running MySQL 4.1.x but I think the new server is running MySQL 5.x Much thanks in advanced.
×
×
  • 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.