Jump to content

bian101

Members
  • Posts

    13
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

bian101's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Ah! Rookie mistake :/ it should be: $list = sql::getNYCPost("pages",1); as pages is the name of the table and its not stored in a variable. Thank you! That seems to have done the job I just gotta work on the url now, thank you!
  2. Are you using a $_GET or $_POST method for the form action?
  3. I put mysql_error(); and it didnt throw an error it just stopped executing the code at the while. The relevant table is: Pages and the field names are: id int(11) pagetitle varchar(255) linklabel varchar(255) pagebody text showing enum('0', '1') Hope that helps
  4. Hey guys, So im building a Content Management System for my A2 project in Computing, and i have a dataBase class. Now, i can return one thing, or do things like inserts however im having a problem returning a list of things such as: dataBase.class.php public static function getNYCPost($table, $limit) { dataBase::_dbConnect(); if($limit == 0) { //debug: echo 'in as 0'; $data = mysql_query("SELECT id, linklabel FROM ".$table." WHERE showing='1' AND id >= 2"); } if($limit == 1) { //debug: echo 'in'; $data = mysql_query("SELECT id, linklabel FROM ". $table ." WHERE showing='1' AND id >= 2 ORDER BY id DESC LIMIT 5"); return $data; } } When i try to do this in the main code: index.php <?php $list = dataBase::getNYCPost($pages,1); // echo $list; while ($row = mysql_fetch_array($list)) { $pageId = $row["id"]; $linklabel = $row["linklabel"]; $menuDisplay .= '<a href="index.php?pid=' . $pid . '">' . $linklabel . '</a><br />'; } echo $menuDisplay; ?> $list doesnt return anything, the previous method i used in the class was to make a list and an array and put the contents of the query in an array like: list($list[] = $row); or something i cant quite remember i saw a youtube video tutorial and it worked for them, but it wasnt for me. If anyone knows how i can return various rows from a database it would be appreciated Thanks.
  5. Hey guys, I think this is a toughie! So a work mate sent me his portion of the code and runs fine on localhost until i hit the "login" button. Now... this is odd because the code is fine but apache crashes and i get the whole windows "apache has crashed click here to send an error report". Then i restart WAMP and no luck i always get the 101 server error so i have to totally reinstall WAMP. This is the error log upon crash: Im running windows 7 32 bit Apache 2.2.11 PHP 5.2.11 (im not running the new one because some code crashes on it) The code for the page (if you wanted to know to save time is:) <?php require_once 'classes/login_idea.php'; class login extends module { public function __construct() { $this->idea = new login_idea(); $this->que_message("content", message("expected_footer","","a message example", array("name to display"=>"ian"))); } public function process_message($message) { if ($message['body']=='user login') { $u = isset($message['params']['username']) ? $message['params']['username'] : ""; $p = isset($message['params']['password']) ? $message['params']['password'] : ""; return array(reply($message, array('errors'=>$this->login_by_password($u,$p)), 'client')); } if ($message['body']=='user logout') { $this->logout(); return array(reply($message, array('success'=>true), 'client')); } if ($message['body']=="an example for ian") { return array( reply($message), message("to_some_module", "", "another example", array("some parameter"=>123, "another one"=>array(1,2,3))), message("", "login", "this one sends a message to all active modules") ); } return array(); } public function html() { return $this->generate_html(); } private function logout() { unset($_SESSION['user_id']); } private function login_by_password($usr, $pwd) { global $user; $user = $this->idea->fetch_user_by_login($usr, $pwd); $errors = ""; if ($user) $_SESSION['user_id'] = $user->id; else $errors = "Username and password did not match."; return $errors; } private function generate_html() { global $user; // template file $html = file_get_contents(dirname(__FILE__) . "/login.html"); if ($user->id) // logged in already { $html = preg_replace("~(<form.*?>)(.|\n|\r)*(</form>)~", "", $html); // remove the login form } else // needs to login? { $html = preg_replace("~<a.*?class=\"btn_logout\".*?/a>~","",$html); // remove the logout button } return $html; } } ?> Please help :S Kind Regards, Ian
  6. Ohh... okay I had it working, and apache is crashing and this is in the "more info" section of the crash log from microsoft: Files that help describe the problem: C:\ProgramData\Microsoft\Windows\WER\ReportQueue\AppCrash_httpd.exe_ecc6cb4573f5823f8f4aa2a1e99c20b2e0a7b5_cab_054017d3\WER16E9.tmp.appcompat.txt C:\ProgramData\Microsoft\Windows\WER\ReportQueue\AppCrash_httpd.exe_ecc6cb4573f5823f8f4aa2a1e99c20b2e0a7b5_cab_054017d3\WER1719.tmp.WERInternalMetadata.xml C:\ProgramData\Microsoft\Windows\WER\ReportQueue\AppCrash_httpd.exe_ecc6cb4573f5823f8f4aa2a1e99c20b2e0a7b5_cab_054017d3\WER1788.tmp.mdmp Read our privacy statement online: http://go.microsoft.com/fwlink/?linkid=104288&clcid=0x0409 If the online privacy statement is not available, please read our privacy statement offline: C:\Windows\system32\en-US\erofflps.txt and the apache log: [sun Dec 26 00:08:15 2010] [notice] Parent: Received shutdown signal -- Shutting down the server. [sun Dec 26 00:08:15 2010] [notice] Child 2360: Exit event signaled. Child process is ending. [sun Dec 26 00:08:16 2010] [notice] Child 2360: Released the start mutex [sun Dec 26 00:08:17 2010] [notice] Child 2360: All worker threads have exited. [sun Dec 26 00:08:22 2010] [notice] Child 2360: Child process is exiting [sun Dec 26 00:08:22 2010] [notice] Parent: Child process exited successfully. [sun Dec 26 00:08:28 2010] [notice] Apache/2.2.11 (Win32) PHP/5.2.11 configured -- resuming normal operations [sun Dec 26 00:08:28 2010] [notice] Server built: Dec 10 2008 00:10:06 [sun Dec 26 00:08:28 2010] [notice] Parent: Created child process 3080 [sun Dec 26 00:08:28 2010] [notice] Child 3080: Child process is running [sun Dec 26 00:08:28 2010] [notice] Child 3080: Acquired the start mutex. [sun Dec 26 00:08:28 2010] [notice] Child 3080: Starting 64 worker threads. [sun Dec 26 00:08:28 2010] [notice] Child 3080: Starting thread to listen on port 80. [sun Dec 26 00:08:33 2010] [notice] Parent: child process exited with status 255 -- Restarting. [sun Dec 26 00:08:33 2010] [notice] Apache/2.2.11 (Win32) PHP/5.2.11 configured -- resuming normal operations [sun Dec 26 00:08:33 2010] [notice] Server built: Dec 10 2008 00:10:06 [sun Dec 26 00:08:33 2010] [notice] Parent: Created child process 4648 [sun Dec 26 00:08:33 2010] [notice] Child 4648: Child process is running [sun Dec 26 00:08:33 2010] [notice] Child 4648: Acquired the start mutex. [sun Dec 26 00:08:33 2010] [notice] Child 4648: Starting 64 worker threads. [sun Dec 26 00:08:33 2010] [notice] Child 4648: Starting thread to listen on port 80. [sun Dec 26 00:08:34 2010] [notice] Parent: child process exited with status 255 -- Restarting. [sun Dec 26 00:08:34 2010] [notice] Apache/2.2.11 (Win32) PHP/5.2.11 configured -- resuming normal operations [sun Dec 26 00:08:34 2010] [notice] Server built: Dec 10 2008 00:10:06 [sun Dec 26 00:08:34 2010] [notice] Parent: Created child process 2716 [sun Dec 26 00:08:34 2010] [notice] Child 2716: Child process is running [sun Dec 26 00:08:34 2010] [notice] Child 2716: Acquired the start mutex. [sun Dec 26 00:08:34 2010] [notice] Child 2716: Starting 64 worker threads. [sun Dec 26 00:08:34 2010] [notice] Child 2716: Starting thread to listen on port 80. [sun Dec 26 00:08:36 2010] [notice] Parent: child process exited with status 255 -- Restarting. [sun Dec 26 00:08:36 2010] [notice] Apache/2.2.11 (Win32) PHP/5.2.11 configured -- resuming normal operations [sun Dec 26 00:08:36 2010] [notice] Server built: Dec 10 2008 00:10:06 [sun Dec 26 00:08:36 2010] [notice] Parent: Created child process 3100 [sun Dec 26 00:08:36 2010] [notice] Child 3100: Child process is running [sun Dec 26 00:08:36 2010] [notice] Child 3100: Acquired the start mutex. [sun Dec 26 00:08:36 2010] [notice] Child 3100: Starting 64 worker threads. [sun Dec 26 00:08:36 2010] [notice] Child 3100: Starting thread to listen on port 80. teh webpage output is the Error 101 (net::ERR_CONNECTION_RESET): Unknown error. any ideas?
  7. Ohh of course! Thanks!! I unistalled my wamp and reinstalled and i forgot, thanks
  8. [sat Dec 25 20:13:00 2010] [notice] Child 2784: Released the start mutex [sat Dec 25 20:13:01 2010] [notice] Child 2784: All worker threads have exited. [sat Dec 25 20:13:01 2010] [notice] Child 2784: Child process is exiting [sat Dec 25 20:13:01 2010] [notice] Parent: Child process exited successfully. [sat Dec 25 20:13:01 2010] [notice] Apache/2.2.11 (Win32) PHP/5.2.11 configured -- resuming normal operations [sat Dec 25 20:13:01 2010] [notice] Server built: Dec 10 2008 00:10:06 [sat Dec 25 20:13:01 2010] [notice] Parent: Created child process 1372 [sat Dec 25 20:13:01 2010] [notice] Child 1372: Child process is running [sat Dec 25 20:13:01 2010] [notice] Child 1372: Acquired the start mutex. [sat Dec 25 20:13:01 2010] [notice] Child 1372: Starting 64 worker threads. [sat Dec 25 20:13:01 2010] [notice] Child 1372: Starting thread to listen on port 80. [sat Dec 25 20:13:08 2010] [alert] [client 127.0.0.1] C:/wamp/www/d/.htaccess: Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration, referer: http://localhost/ [sat Dec 25 20:13:08 2010] [error] [client 127.0.0.1] File does not exist: C:/wamp/www/favicon.ico [sat Dec 25 20:13:18 2010] [notice] Parent: Received shutdown signal -- Shutting down the server. [sat Dec 25 20:13:18 2010] [notice] Child 1372: Exit event signaled. Child process is ending. [sat Dec 25 20:13:19 2010] [notice] Child 1372: Released the start mutex [sat Dec 25 20:13:20 2010] [notice] Child 1372: All worker threads have exited. [sat Dec 25 20:13:20 2010] [notice] Child 1372: Child process is exiting [sat Dec 25 20:13:20 2010] [notice] Parent: Child process exited successfully. [sat Dec 25 20:13:20 2010] [notice] Apache/2.2.11 (Win32) PHP/5.3.0 configured -- resuming normal operations [sat Dec 25 20:13:20 2010] [notice] Server built: Dec 10 2008 00:10:06 [sat Dec 25 20:13:20 2010] [notice] Parent: Created child process 3796 [sat Dec 25 20:13:20 2010] [notice] Child 3796: Child process is running [sat Dec 25 20:13:20 2010] [notice] Child 3796: Acquired the start mutex. [sat Dec 25 20:13:20 2010] [notice] Child 3796: Starting 64 worker threads. [sat Dec 25 20:13:20 2010] [notice] Child 3796: Starting thread to listen on port 80. [sat Dec 25 20:56:49 2010] [alert] [client 127.0.0.1] C:/wamp/www/d/.htaccess: Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration, referer: http://localhost/ [sat Dec 25 20:56:49 2010] [error] [client 127.0.0.1] File does not exist: C:/wamp/www/favicon.ico thanks i dont have a clue what it means though :/ xx
  9. Hey guys, Im getting Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator, admin@localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available in the server error log. im running windows 7, php v5.3 and 5.2.11, apache 2.2.11 Any idea as to why im getting this? Thanks, Ian
  10. Hey guys whats up. Okay... so.. first of all im running Windows 7 32 bit and WAMP for local server. I have never had issues with this in the last couple of years of coding and all of a sudden.. boom! So, me and a team are doing a project and they sent me the core files over and initially this is what happened: I installed it all and put the sql in the tables blahh blahh then i got Error 101 (net::ERR_CONNECTION_RESET): Unknown error. So after a few days of constant *head desk* my mate suggested downgrading to php version 5.2.11 from 5.3... so i did and it worked a treat, and after not editing the files all of a sudden the dreaded: Error 101 (net::ERR_CONNECTION_RESET): Unknown error. So i checked the php version its still 5.2.11 and im stumped now, really am! I am using chrome but all other browsers it just gives the whole "this page cannot be displayed" stuff Any help? Kind regards, Ian
  11. Hey, Somehow i dont know why without me changing that its been implemented, not a clue how i managed to change it, but still no fix. We think its something to do with a key in the database? Not a clue
  12. Hey guys! I know, I know this problem is EVERYWHERE but i just dont understand! I have a solid knowlage of php but my SQL skills are low, so i dont know too much about Keys and stuff. But my error is: Duplicate entry '' for key 2. The thing that im working on at this section is logging in with facebook. The code that presents my error is: $sql = "SELECT * FROM users WHERE uid=".$uid; $fbid = mysql_query($sql); $num_rows = mysql_num_rows($fbid); if(mysql_num_rows($fbid) < 1) { echo "You are not logged in. "; mysql_query("INSERT INTO `users` (`uid`) VALUES ('".$uid."')") or die(mysql_error()); } else { mysql_query("UPDATE users SET logged = '1' WHERE uid=".$uid); //mysql_query("UPDATE users SET full_name = $me WHERE uid=".$uid); echo "Your Logged in "; echo $me['name']; ?> Continue to <a href="removed "> My Settings </a>. <? } Any help is welcome
×
×
  • 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.