Jump to content

mike12255

Members
  • Posts

    439
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by mike12255

  1. I think I understand what your going for, just to be sure could you post your code please? also code like this: $ttl_inc_val = $_POST['ttl_inc] + $inc1 + $inc2 + $inc3; what is ttl_inc? have you already defined $inc1, $inc2, $inc3 through post variables above this code?
  2. I would also recommend moving to mysqli. Your application with become obsolete in the near future if you dont.
  3. I honestly recommend you remove the credentials and change both the username and password. Also you might want to find a new forum to ask for help. Begging for people to do your work on this forum does not get you far.
  4. So ive started taking a crack at learning javascript/ajax and am trying to make a simple chat box. I got this script *almost* working flawless. What I want to do right now is make the script run my function that loads messages every three seconds. I read online about the setinterval function however this makes my post function post the same item multiple times. Also when you first load a page it doesnt show anything in the chat box for three seconds: <script> $(document).ready(setInterval(function() { $("#messageContainer").load('chat_process.php?a=load'); $("#formsubmit").submit(function() { $.post('chat_process.php?a=post', $('#formsubmit').serialize(), function (data){ document.getElementById('Message').value ="Message"; }); return false; }); },3000)); </script> Would it be best practice to make another document.ready and place the post call in that without an interval function?
  5. Thanks for giving me a suggestion of where to look. I marked this as solved I need to get to bed. If in the morning I cannot find a solution ill post more code and unsolve it
  6. Its time for bed but I have to finish this file before I go to bed and I cant figure out the mistake with my query hoping there are some fresh eyes out there that can see it. Here is the line : $query = $qls->Security->make_safe("INSERT INTO `{$qls->config['sql_prefix']}chat` (username, message) VALUES (\"$user\", \"$message\")"); when I die the statement I get: I can take that and query that in through php my admin no problem but when i run a query through php code I get the error:
  7. The above solution will work. It is best practice to use underscores ( _ ) rather then dashes for mysqli table names
  8. Was an error with my .htaccess, had a space where I shouldnt have.
  9. So im still playing around with this MVC stuff think im starting to understand/get the hang of it! The issue im currently having is getting the CSS file to work! I have my header and footer in their own files so I call them both when I load pages. All three objects being called are supposed to be linked to: public/css/default.css. my header file looks like this: <!doctype html> <html> <head> <title><?=(isset($this->title)) ? $this->title : 'MVC'; ?></title> <link rel="stylesheet" href="<?php echo URL; ?>public/css/default.css" /> <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.17/themes/sunny/jquery-ui.css" /> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js"></script> <script type="text/javascript" src="<?php echo URL; ?>public/js/custom.js"></script> <?php if (isset($this->js)) { foreach ($this->js as $js) { echo '<script type="text/javascript" src="'.URL.'views/'.$js.'"></script>'; } } ?> </head> <body> <?php Session::init(); ?> <div id="header"> <?php if (Session::get('loggedIn') == false):?> <a href="<?php echo URL; ?>index">Index</a> <a href="<?php echo URL; ?>help">Help</a> <?php endif; ?> <?php if (Session::get('loggedIn') == true):?> <a href="<?php echo URL; ?>dashboard">Dashboard</a> <a href="<?php echo URL; ?>note">Notes</a> <?php if (Session::get('role') == 'owner'):?> <a href="<?php echo URL; ?>user">Users</a> <?php endif; ?> <a href="<?php echo URL; ?>dashboard/logout">Logout</a> <?php else: ?> <a href="<?php echo URL; ?>login">Login</a> <?php endif; ?> </div> <div id="content"> When I view page source it looks like this: <!doctype html> <html> <head> <title>Login</title> <link rel="stylesheet" href="missednote.com/public/css/default.css" /> <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.17/themes/sunny/jquery-ui.css" /> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js"></script> <script type="text/javascript" src="/public/js/custom.js"></script> </head> <body> <div id="header"> <a href="/index">Index</a> <a href="/help">Help</a> <a href="/login">Login</a> </div> <div id="content"> <h1>Login</h1> <form action="login/run" method="post"> <label>Login</label><input type="text" name="login" /><br /> <label>Password</label><input type="password" name="password" /><br /> <label></label><input type="submit" /> </form></div> <div id="footer"> (C) Footer </div> </body> </html> I don't understand this maybe the htaccess file wont let it access the css file directory properly, could that be it? I am not familiar with the htaccess file and found one on the internet that I thought did what I wanted. A live version of my test can be seen at: http://www.missednote.com/login/
  10. Im really not sure what your asking remember your talking to people who have no idea what your end goal is I think I did read one part correctly, you want to retrive things from the database and list them in alphabetical order? you want to use the ORDER by clause ex: "SELECT * FROM `Some_Table` ORDER BY `Name` ASEC" <-- would list entries by alphabetical order. Although if you have very limited php/mysql knowledge Im not sure you will be able to do everything you want. Also not many people like writing code for someone but rather helping them understand theories or better methodology. And in my personal opinion and I think many other would agree, when it comes to a database no matter who should be able to access it security is always essential! Also after a quick browse through the script you uploaded unless there is a lot more that you just have not shown us I dearly hope you did not pay more then $20 for that the code is not complex.
  11. Thanks a lot for the info on codeignitor, the reviews I read (from recent dates) failed to mention that.
  12. Im trying to convert myself to this MVC style coding as well as using frameworks. (Currently learning codeigniter) anyway I was wondering if there was any generally accepted rules on how to load views. should I separate my header, footer, sidebars, and mainpage all into their own templates and load them together or is it best practice to combine those all into one template and just load one thing? Appreciate the replies Thanks, Mike
  13. I have setup the connection in a seperate file (tested it is working) with the following code: function MySQLDB(){ /* Make connection to database */ $this->connection = new mysqli( DB_SERVER, DB_USER, DB_PASS, DB_NAME) or die ('Cannot open database'); //mysql_connect(DB_SERVER, DB_USER, DB_PASS) or die(mysql_error()); // mysql_select_db(DB_NAME, $this->connection) or die(mysql_error()); So when I changed my code in my index file to $session->connection; $result = $connection->query($sql); While ($row = $result->fetch_array(MYSQLI_BOTH)){ echo "<li class=\"clear\">"; if ($img = $row['image'] != ""){ echo "<div class\"imgl\"><img src=\".$img.\" alt=\"\"/></div>"; } echo "<div class=\"latestnews\">". "<p><a href=\"news.php?id=".$row['id'].">".$row['title']."</a></p><p>".$row['content']."</p></div>"; } $connection->close(); Im sure my issue is when trying to use $connection as my database connector im just not sure why/what I am doing wrong?
  14. Hey there im trying to change my website from mysql statments to mysqli. I tried changing one of my simple statments to get some news from the db and im running into the following error: Here is the code I am using, does anyone know what/why the error is producing: $sql = "SELECT * FROM news ORDER by id DESC LIMIT 2,0"; $result = $mysqli->query($sql); While ($row = $result->fetch_array(MYSQLI_BOTH)){ echo "<li class=\"clear\">"; if ($img = $row['image'] != ""){ echo "<div class\"imgl\"><img src=\".$img.\" alt=\"\"/></div>"; } echo "<div class=\"latestnews\">". "<p><a href=\"news.php?id=".$row['id'].">".$row['title']."</a></p><p>".$row['content']."</p></div>"; }
  15. Every now and then my roommate find ourselves short of supplies for a drinking game eg. cards. So I wip up a quick program to play it but its not very interactive. For example the game im showing today is a very simple one called horserace. (if you dont know how to play it youtube horserace drinking game, its fun) Anyway what I want to do to this game is add a button so that it draws one card at a time instead of drawing all the cards until the game is finished. I have not really used Ajax/javascript much before so Im looking for what frameworks you think would be best for this and even specific functions or any advice you have. In case anyone wanted to see what I have so far it can be seen here: http://5.9.44.54/~unigames/ (its a slow free webhost) and if for whatever reason you would like to see my code it is here: <?php //define the suits $suits = array ( "Spades", "Hearts", "Clubs", "Dimonds" ); //define ALL of the faces for a full deck $fullFaces = array ( "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Jack", "Queen", "King", "Ace" ); //create the full deck array $fullDeck = array(); //full the full deck with every card foreach ($suits as $suit) { foreach ($fullFaces as $face) { $fullDeck[] = array ("face"=>$face, "suit"=>$suit); } } //take out the aces for the game $gameFaces = array ( "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Jack", "Queen", "King" ); //create a gamedeck array $gameDeck = array(); //put all the cards except aces into the game deck foreach ($suits as $suit) { foreach ($gameFaces as $face) { $gameDeck[] = array ("face"=>$face, "suit"=>$suit); } } //shuffle the gamedeck shuffle($gameDeck); //create the image paths for the aces and back of cards $aceSpades = "images/".$fullDeck['12']['face']."_".$fullDeck['12']['suit'].".png"; $aceHearts = "images/".$fullDeck['25']['face']."_".$fullDeck['25']['suit'].".png"; $aceClubs = "images/".$fullDeck['38']['face']."_".$fullDeck['38']['suit'].".png"; $aceDimonds = "images/".$fullDeck['51']['face']."_".$fullDeck['51']['suit'].".png"; $cardBack = "images/b2fv.png"; ?> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title></title> <meta name="keywords" content="" /> <meta name="description" content="" /> <link rel="stylesheet" href="css/style.css" type="text/css" media="screen, projection" /> <!--[if lte IE 6]><link rel="stylesheet" href="style_ie.css" type="text/css" media="screen, projection" /><![endif]--> </head> <body> <div id="parent"> <?php //create an array to put each of the card images into $heart = array(); $club = array(); $spade = array(); $dimond = array(); //setup counters to keep place in the array and make sure no more then 4 of one suite are drawen $spadeCount = 0; $heartCount = 0; $dimondCount = 0; $clubCount = 0; //loop untill one suit has four cards while ($spadeCount !=4 && $heartCount != 4 && $dimondCount != 4 && $clubCount != 4 ){ //draw another card from the game deck $nextCard = array_shift($gameDeck); //if card is hearts assign that to the next open hearts spot if ($nextCard['suit'] == "Hearts"){ $heart[$heartCount] = "images/".$nextCard['face']."_".$nextCard['suit'].".png"; $heartCount++; //if card is clubs assign that to the next open clubs spot }else if ($nextCard['suit'] == "Clubs"){ $club[$clubCount] = "images/". $nextCard['face']."_".$nextCard['suit'].".png"; $clubCount++; //if card is spades assign that to the next open spades spot }else if ($nextCard['suit'] == "Spades"){ $spade[$spadeCount] ="images/". $nextCard['face']."_".$nextCard['suit'].".png"; $spadeCount++; }else{ //card is dimonds assign it to the next dimonds spot $dimond[$dimondCount] = "images/". $nextCard['face']."_".$nextCard['suit'].".png"; $dimondCount++; } } //Fourth line echo "<br/><div class=\"child\"> <img src=\"".$cardBack."\" /></div>"; //blank card echo "<div class=\"child\"><img src= \"".$spade[3]."\"/></div>"; //spades echo "<div class=\"child\"><img src= \"".$heart[3]."\"/></div>";//hearts echo "<div class=\"child\"><img src= \"".$club[3]."\"/></div>";//clubs echo "<div class=\"child\"><img src= \"".$dimond[3]."\"/></div><br/>";//dimonds //Third line echo "<div class=\"child\"> <img src=\"".$cardBack."\" /></div>"; // balnk card echo "<div class=\"child\"><img src= \"".$spade[2]."\"/></div>"; //spades echo "<div class=\"child\"><img src= \"".$heart[2]."\"/></div>";//hearts echo "<div class=\"child\"><img src= \"".$club[2]."\"/></div>";//clubs echo "<div class=\"child\"><img src= \"".$dimond[2]."\"/></div><br/>";//dimonds //Second line echo "<div class=\"child\"> <img src=\"".$cardBack."\" /></div>"; // balnk card echo "<div class=\"child\"><img src= \"".$spade[1]."\"/></div>"; //spades echo "<div class=\"child\"><img src= \"".$heart[1]."\"/></div>";//hearts echo "<div class=\"child\"><img src= \"".$club[1]."\"/></div>";//clubs echo "<div class=\"child\"><img src= \"".$dimond[1]."\"/></div><br/>";//dimonds //First line echo "<div class=\"child\"> <img src=\"".$cardBack."\" /></div>"; // balnk card echo "<div class=\"child\"><img src= \"".$spade[0]."\"/></div>"; //spades echo "<div class=\"child\"><img src= \"".$heart[0]."\"/></div>";//hearts echo "<div class=\"child\"><img src= \"".$club[0]."\"/></div>";//clubs echo "<div class=\"child\"><img src= \"".$dimond[0]."\"/></div><br/>";//dimonds //draw the aces at the bottem echo "<div class=\"child\"></div>"; echo "<div class=\"child\">"; echo "<img src=\"".$aceSpades. " \" alt= \"Card\">"; echo "</div>"; echo "<div class=\"child\">"; echo "<img src=\"".$aceHearts. " \" alt= \"Card\">"; echo "</div>"; echo "<div class=\"child\">"; echo "<img src=\"".$aceClubs. " \" alt= \"Card\">"; echo "</div>"; echo "<div class=\"child\">"; echo "<img src=\"".$aceDimonds. " \" alt= \"Card\">"; echo "</div>"; ?> </div> </body>
  16. I have double checked the retreval variable and it is working fine. Aswell the $session->login() returns either a 1 or nothing. That leads to the function to see if there are any errors and if the username and password are correct. If there are no errors it then sets the sessions. I have tested that part of the code and it is working proper aswell, so then I tried running the code I run on login.php: if(!$session->logged_in){ // this is the line i use in login.php die ("no active session"); }else{ die ("active session"); } and just like I need it to the message no active session came up. There is no reason I can see that it should not be going to login.php im going to try something else when I get home but thanks alot for helping me if I manage to get it working after im done work ill update the thread.
  17. the only possible code on login.php that could send them to the index page is a check to see if a session has been created but the login information has to pass all the checkes before that happens. Also, thanks for letting me know about that I have never used that but will in the future to improve my code. Im going to double check the login process right now to make sure that no sessions are being created yeah I threw a die statment in right before the sessions are made and it did not run so there are no sessions being created.
  18. I got the following code: <?php function procLogin(){ global $session, $form; /* Login attempt */ $retval = $session->login($_POST['user'], $_POST['pass'], isset($_POST['remember'])); /* Login successful */ if($retval){ header("Location: index.php "); } /* Login failed */ else{ $_SESSION['value_array'] = $_POST; $_SESSION['error_array'] = $form->getErrorArray(); header("Location: login.php"); } } ?> Right now I am testing/working on the login failed portion of it. I have manually debugged the entire login process and the login failure works right up to where the header should be directed to login.php but instead of going to login.php its going to index.php. I have double and triple checked that the file is in the right place and has been saved. so I dont know what could be going wrong inbetween the two lines: $_SESSION['error_array'] = $form->getErrorArray(); header("Location: login.php"); any ideas?
  19. Below I have an image and then some text. Both are to be displayed on my hompage. However I would like my text to start at the top where the image does and do short lines till it gets the the bottom of the image and start doing long lines. The only thing I could think of would to be making two different divs with Zindexs but that would just place the text over the image right?
  20. Thanks guys, the only thing I had to change about the div code, was put the count++ after it echo'ed out the name
  21. no i prefer divs actually, if you see a better way
  22. I was only able to take a quick look as i am too in a rush but just wanted to say thanks for pointing me in the right direction. And your right it doesnt make much sense right now but when I can sit down tonight take my time to read it and look at the php manual i think i should be able to come up with something, so thanks alot man.
  23. That would make it go to a new line after each item, but after 12 items have been displayed how can I make it go to the top line and start going down again
  24. I want to grab a list of all the school programs I have in a database (math english biology chemistry ect ect) and dispaly them in a order so that they go alphabetically downward for 12 rows and then go across so it would look like soo: Academic Advisory Class Schedules Academic Assistance Counselling Center Academic Calendars Course Descriptions and Catalogue Academics Office Department Directory Administration Departments & Programs Adult Learners Fellowships Alumnimni Chapters Finals Schedules Alumni Events Athletics Campus Life At a Glance Campus Recreation Campus Safety & Security I know to get here: I am just unsure what to do in the while array to make it look how I want <?php $sql = "SELECT name,id FROM table_name ORDER BY name ASC"; $res =mysql_query($sql) or die (mysql_error()); while ($row = mysql_fetch_array($res)){ //now what??? } ?>
×
×
  • 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.