Jump to content

Jarod

Members
  • Posts

    70
  • Joined

  • Last visited

    Never

Everything posted by Jarod

  1. It just prints out Details provided to connect to the database are invalid. now, it's still not working. I know for sure it's connecting BECAUSE when I didn't have the die() it was outputting all the users from the database, so I know for sure something else is wrong with the database. I'm just not sure "what" is wrong though :-\.
  2. I fixed it a little, it's displaying but the error still wont go away :'(, it says somethings wrong with connecting to the database when it's displaying data from the database, see what I mean? These errors are hunting me! <?php class dbComponent { var $dbhost; var $dbusername; var $dbpassword; var $dbname; /** * Creates the database on construct */ function connectDB($host, $username, $password, $name) { $this->dbhost = $host; $this->dbusername = $username; $this->dbpassword = $password; $this->dbname = $name; $connect = mysql_connect($this->dbhost, $this->dbusername, $this->dbpassword) or die('Details provided to connect to the database are invalid.' . mysql_error()); mysql_select_db($this->dbname, $connect) or die('Could not select the database. ' . mysql_error()); } function get_host() { return $this->dbhost; } function get_username() { return $this->dbusername; } function get_password() { return $this->dbpassword; } function get_name() { return $this->dbname; } } ?> <?php require_once( dirname(__FILE__) . '/class.dbComponent.php'); class dbConnector extends dbComponent { var $query; var $thelink; function __construct() { $dbComponent = new dbComponent(); $this->thelink = $dbComponent->connectDB('localhost', 'root', NULL, 'jv_cms') or die('Details provided to connect to the database are invalid.' . mysql_error()); mysql_select_db($dbComponent->get_name(), $this->thelink) or die('Could not select the database. ' . mysql_error()); } function query($q) { $this->query = $q; return mysql_query($this->query); } function fetch_array($result) { return mysql_fetch_array($result); } function close() { mysql_close($this->thelink); } } ?> <?php include_once(dirname(__FILE__) . '/inc/lib/class.dbConnector.php'); $db = new dbConnector(); require_once('inc/header.php'); require_once('inc/sidebar.php'); ?> <div id="entries"> <div class="entry"> <!-- Entry #1 --> <div class="entry_name">This is an entry</div> <div class="entry_content"> <p> <?php $query = $db->query('SELECT users_username FROM jays_users'); $row = $db->fetch_array($query); echo $row['users_username']; ?></p> </div> </div> <div id="browse_entries"><a href="#" title="Browse news archive">Browse Archive</a></div> </div> <?php require_once('inc/footer.php'); ?>
  3. Okay this is how all this started, I literally thought to the best ways around this solution and they failed, so I was like I'mma just start from ground up, which is what I'm supposedly doing right now, but these freaken errors wont go way for anything in the world, wtf man ! I cant get this freaken oop project to work for a thing in the world wtf , last one I did it literally printed out like 1K queries of the same usernames, which like crashed my browser HEAVILY. So I rewrote the script again and messed up and then again and messed up AGAIN... So on this chance I rewrote it again in the best way I could this time and these fucking bizarre errors are like hunting me man wtf , im frustrating over here right now . I get this error: Warning: mysql_query() expects parameter 2 to be resource, null given in C:\wamp\www\inc\lib\class.dbConnector.php on line 16 Warning: mysql_fetch_array() expects parameter 1 to be resource, null given in C:\wamp\www\inc\lib\class.dbConnector.php on line 20 Okay here is the code I used to start myself off with, before I get to showing that I'll explain the purpose of these codes though. The first script you'll see is an object that sets up the connection for using the database, and the last one is where I make custom functions for how the site will be accessing future queries, obviously that is not working because of my gay vista laptop I guess :'(. The source where I implemented the 2 codes together is the last block of code you'll see. Please I reallllllyyyyyyyy neeeeed help! *pulls hear out* <?php class dbComponent { var $dbhost; var $dbusername; var $dbpassword; var $dbname; /** * Creates the database on construct */ function connectDB($host, $username, $password, $name) { $this->dbhost = $host; $this->dbusername = $username; $this->dbpassword = $password; $this->dbname = $name; mysql_connect($this->dbhost, $this->dbusername, $this->dbpassword); mysql_select_db($this->dbname); } function get_host() { return $this->dbhost; } function get_username() { return $this->dbusername; } function get_password() { return $this->dbpassword; } function get_name() { return $this->dbname; } } ?> <?php require_once( dirname(__FILE__) . '/class.dbComponent.php'); class dbConnector extends dbComponent { var $query; var $thelink; function __construct() { $dbComponent = new dbComponent(); $this->thelink = $dbComponent->connectDB('localhost', 'root', NULL, 'jv_cms'); mysql_select_db($dbComponent->get_name()); } function query($q) { $this->query = $q; return mysql_query($this->query, $this->thelink); } function fetch_array($result) { return mysql_fetch_array($result); } function close() { mysql_close($this->thelink); } } ?> <?php include_once(dirname(__FILE__) . '/inc/lib/class.dbConnector.php'); $db = new dbConnector(); require_once('inc/header.php'); require_once('inc/sidebar.php'); ?> <div id="entries"> <div class="entry"> <!-- Entry #1 --> <div class="entry_name">This is an entry</div> <div class="entry_content"> <p> <?php $query = $db->query('SELECT users_username FROM jays_users'); $row = $db->fetch_array($query); echo $row['users_username']; ?></p> </div> </div> <div id="browse_entries"><a href="#" title="Browse news archive">Browse Archive</a></div> </div> <?php require_once('inc/footer.php'); ?>
  4. Fatal error: Maximum execution time of 60 seconds exceeded in C:\wamp\www\inc\lib\class.MySQL.php on line 24 I get this error on my page, I was testing if the function worked, and it doesn't apparently. This is the code I used: This is the class.MySQL.php file <?php require_once( dirname(__FILE__) . '/class.dbComponent.php'); class MySQL extends dbComponent { var $query; function __construct() { // Connect to the database dbComponent::connectDB('localhost', 'root', NULL, 'jv_cms'); } function select($table, $columns, $where=NULL, $orderby=NULL, $limit=NULL) { $etc = ""; if($where != NULL) { $etc .= " WHERE $where"; } if($orderby != NULL) { $etc .= " ORDER BY $orderby"; } if($limit != NULL) { $etc .= " LIMIT $limit"; } $this->query = "SELECT $columns FROM $table" . $etc; return mysql_query($this->query); } } ?> And the code in the index.php file, which is where the problem is occuring: (ignore the php comment) <?php include_once(dirname(__FILE__) . '/inc/lib/class.MySQL.php'); $mysql = new MySQL(); require_once('inc/header.php'); require_once('inc/sidebar.php'); ?> <div id="entries"> <div class="entry"> <!-- Entry #1 --> <div class="entry_name">This is an entry</div> <div class="entry_content"> <p> <?php //$query = $mysql->select('jays_users', '*', NULL, 'ASC', '5'); while( $row=mysql_fetch_assoc($mysql->select('jays_users', '*')) ) { $username = $row['users_username']; echo $username . "<br />\n"; } ?></p> </div> </div> <div id="browse_entries"><a href="#" title="Browse news archive">Browse Archive</a></div> </div> <?php require_once('inc/footer.php'); ?> The problem is though, is that my page literally outputs like a thousand usernames, when there's only 1 row in the table, how is that possible?? How did it even like multiply the query?
  5. Okay I'm having a hard problem setting up my site I want to convert to a personal CMS syste, but the problem is I don't know where to start. I don't want to use oop at the same time because it's confusing too, just linear style. I was thinking of structuring my site like this, but I have a problem on how I'm suppose to be using it: ROOT folder >>admin-cp folder //This is where the admin control is going to be _____________ >>inc folder //This is where the functions (for constructing a new "theme" or "template") will be stored _____________ >>content folder //This is where the templates will be stored, where they can be used ....>>Themes _____________ ....>>index.php file //This page, in the root folder will be where the template is displayed It's sort of like the wordpress structure but NOT wordpress come to think of it lol, please help me I've been trying to think of how I would get started for a good 3 days now and still no undestanding of how I'm suppose to start .
  6. try if ( isset($action) =="yes") { see if that works =/ also it's probably because you have $ip = $ip = $_SERVER['REMOTE_ADDR']; instead of $ip = $_SERVER[REMOTE_ADDR]; (punctuations) try this too: $foundnum = mysql_num_rows($run); instead of $foundnum = (mysql_num_rows($run));
  7. I dont see 2 of the same ids in this code : <div id="contact_form"> <form action="" method="post"> <label for="name">Your Name:</label> <br /> <input type="text" name="name" id="name" /> <br /> <label for="email">Your Email:</label> <br /> <input type="text" name="email" id="email" /> <br /> <label for="content">Content:</label> <br /> <textarea name="content" id="content"></textarea> </form> </div>
  8. My contact form is acting up strangely, it's not coming out the way it's intended to: http://jarodsworld.ismywebsite.com/website/contact.php See how that box goes all the way to the right and outside of the content area of the site? I need that to be inside of the content area, it's acting retarded for some reason though, I can't figure out the problem.
  9. Does anyone know how Wordpress distributes it's functions? I am wanting to distribute functions the same way for future use, right now I'm thinking that they transact through a middle page, I'm not exactly sure if they're imported right above the <html> tag though. But maybe I'm just completely wrong, any idea?
  10. I didn't really know where to post this, but here it goes : Hey, My name is Jarod as you may have not know of already, I love to work with websites literally. One of my most favorite things to do with websites is to design them, which I present to you Enjeege. This was originally for my friend Andrew for his gaming site, I didn't really know what to put on the website for design, so I just improvised. Thanks for the critic and if you have any suggestions in mind please let me know of them . [CLICK] Design [CLICK]
  11. I guess, I was just curious though :'(.
  12. like if I inputted Jays, which is 3bc7b0fecbd8e586fcdaf70feaeaab9e in MD5, how do I reverse 3bc7b0fecbd8e586fcdaf70feaeaab9e so that it outputs Jays though?
  13. Hi, I am quite familiar with this community now, from the time I've been here so far. I've learned a lot of PHP since my existence here at Talk PHP, and so the reason of this post is that I am asking for help. I am very confused at the moment on what I would like to even start coding on. The project I am looking forward to completing is maybe something that will get me going with my own personal site maybe. I also was recommended by my friend that I fully learn linear programming first; instead of object oriented programming, so maybe that will give you a good idea on what I can start with. Thanks for the help, need it anyways *!*.
  14. I forgot what it is, but it goes something like this: (condition) code : thisThen; am I right and/or what is the name of this?
×
×
  • 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.