Jump to content

Michael_Baxter

Members
  • Posts

    52
  • Joined

  • Last visited

Everything posted by Michael_Baxter

  1. a full explanation as to why the code looks the way it does is in the tutorial i was following here on youtube,
  2. ok so from the console i ran the show databases and there it is so i am still as thoroughly confused as to why i am getting this error and as i stated in the start i created all of this code and databases, tables and everything in line to a tutorial in which all this works just fine
  3. i know that the database exists and i have tried this with 2 different databases <?php session_start(); $GLOBALS['config'] = array ( 'mysql' => array( 'host' => '127.0.0.1', 'username' => 'root', 'password' => '', 'db' => 'lr' ), 'remember' => array( 'cookie_name' => 'hash', 'cookie_expiry' => 604800 ), 'session' => array( 'session_name' => 'user' ) ); spl_autoload_register(function ($class) { require_once 'classes/' . $class . '.php'; }); require_once 'functions/sanitize.php'; this is where the config::get() refers to
  4. Hi I have been following a youtube tutorial trying to update my php knowledge and they use pdo to create the DB wrapper class and once i load my index.php through WAMP server i get the following on screen error: THIS IS THE DB CLASS FILE,
  5. in the end I have used array slice to fix this issue, I took array slice from index 20 then a foreach loop on the new array from the slice with the final argument as -1 to remove the stop points line if copy and paste would work on this forum I would show you my final code
  6. I did think about that to start with apart from $records is an array each line in the report from my screenshot I uploaded here is an individual index inside of records so $records[0]; would equals to "Nojoks's Tourney Bracket Tool Version 1.2.1.84 $records[1] equals to "Tournament 3/5 Backgammon 1.00pm" and so on. so I don't think strops would really work here every single line from that report has been exploded into an array that's why I need to get access to line 19 then I can run a for each loop on the lines after that
  7. hi, On my website I have a form with a single text area and a submit button, the user will come to my site with a report of points and stats from hosting a tournament online, see attached picture for details of the report once they hit submit the form posts to my processing page, in the processing page I take all the information I need from the beginning of the report this was kind of easy to do, the part I seem to be struggling with is splitting the array at this point. I have exploded each line from my report into an array $records, what I need to do now is, take everything from the line "START POINTS" down to the line "STOP POINTS" from the main array into a new array so that I can get the new array and use a foreach loop on it to separate the player name from player points I already have the foreach loop setup ready as I had this all setup once but I was not getting the information from the top of the report now I need that information so my original foreach does not work
  8. ok thanks Jaques1 that makes sense.
  9. yes I had a feeling after I was looking over the codes after I made this post that was going to be the case just was tired and my eyes hurt after staring at the screen so simply wanted to ask others advice
  10. Hi I have been working on my OOP and have put together some class files to aid my test application ( photo album ) on the upload page I have the browse box, a caption text box and an upload button this page posts to self, Once you click on upload it is also supposed to insert a database entry to allow tracking of the file's attributes, once I click the upload button I get this error message back, " Database Query Failed: Incorrect integer value ' ' for column 'id' at row 1 " so I have re looked over my codes in regards to uploading files and just can not seem to put my mouse on the spot that's causing me an issue so here is the codes that matter to the file uploads... this one is from my database.php class file, public function insert_id() { // get the last id inserted over the current db connection return mysql_insert_id($this->connection); } and this one is one comes from my photograph class file, public function create() { global $database; $attributes = $this->sanitized_attributes(); $sql = "INSERT INTO ".self::$table_name." ("; $sql .= join(", ", array_keys($attributes)); $sql .= ") VALUES ('"; $sql .= join("', '", array_values($attributes)); $sql .= "')"; if($database->query($sql)) { $this->id = $database->insert_id(); return true; } else { return false; } } Looking at my error and the information in those functions I can guess that's where the issue is coming from just don't get why any ideas please?
  11. ok so I get it you have more knowledge of the programming world than mere mortals like me, I get my programming is still under a learning process I never claimed to be any kind of expert at this Hence my been here asking question for help.. as I said before I have things like this already pre defined, function mysql_prep( $value ) { $magic_quotes_active = get_magic_quotes_gpc(); $new_enough_php = function_exists( "mysql_real_escape_string" ); // i.e. PHP >= v4.3.0 if( $new_enough_php ) { // PHP v4.3.0 or higher // undo any magic quote effects so mysql_real_escape_string can do the work if( $magic_quotes_active ) { $value = stripslashes( $value ); } $value = mysql_real_escape_string( $value ); } else { // before PHP v4.3.0 // if magic quotes aren't already on then add slashes manually if( !$magic_quotes_active ) { $value = addslashes( $value ); } // if magic quotes are active, then the slashes already exist } return $value; } and that I have to yet include the function call and yes your right I need to look at using things like mysqli stm and yes I thank you for pointing out clearly I have not finished with the writing of this code however i thought I was pretty clear in saying I was not finished with the code I just needed to have it working in the first place before I went onto making the full code I mean its not like this code is on a live application or anything been used at this time for just that reason
  12. yes I did not disregard your above comment sorry I failed to respond to it however that is not the case if you see near the top of my code last posted there is an includes/functions.php inside there now I have the actual funtions already in use and pre defined for covering all of the sql injection attacks real escape string and so on I now simply just need to call them
  13. ok that's just too funny, I was looking at all of these last few comments thinking I do have error_reporting (E_ALL) turned on, then I realised I do have E_ALL on but I didn't have the second line of code in there ini_set("display_errors",1) so there we go that's why I was not getting the real error messages shown so now I am getting the errors displayed not just reported and they are saying Warning: mysqli: :query() coundn't fetch mysqli in /file path/point_processing.php on line 50 Warning: main(): couldn't fetch mysqli in /file path/points_processing.php on line 53 then this is repeated all the way down the post................................................. OMG STOP looking I just while typing this post out found my own answer this is even more funny than anything I have EVER done if anyone could reach me I would certainly be asking you give me a quick slap for this one 1 thing I constantly point out is when I make these posts its something basic and simple and somewhere someone did mention this schoolboy error, in my code I had put my conn->close() line inside my if statement so I just as said was looking at my codes and saw what that meant so I moved it, I will show you and comment out where it was and where it is now but either way this code is working just fine now, <?PHP //THIS IS THE WHOLE OF MY CODE THAT MAKES POINTS_PROCESSING.PHP error_reporting(E_ALL); ini_set("display_errors",1); ?> <?php require_once("includes/session.php"); ?> <?php require_once("includes/functions.php"); ?> <?php confirm_logged_in(); ?> <?php $errors = array(); include("includes/header.php"); $servername = "localhost"; $username = "*************"; $password = "*********"; $dbname = "******************"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } //testing new code for points split up //Get each record based on line breaks $records = explode(PHP_EOL, $_POST['points']); //Trim each array value $records = array_map('trim',$records); //loop thorough each record foreach($records as $record) { //Get position of last space $lastSpace = strrpos($record, ' '); //Get player name and points $player = trim(substr($record, 0, $lastSpace)); $points = trim(substr($record, $lastSpace+1)); //Output for debugging, Do whatever you need with the data // e.g. put into array, run query, etc. $sql = "INSERT INTO bg_points (player_name, points) VALUES ('$player', '$points')"; if ($conn->query($sql) === TRUE) { echo "New record created successfully"; } else { echo "Error: " . $sql . "<br>" . $conn->error; } //THIS IS WHERE I DID HAVE MY DB CLOSE CONN echo "Player Name: '{$player}', Points: {$points}<br>\n"; } include("includes/footer.php"); $conn->close(); //THIS IS WHERE I HAVE NOW PLACED MY DB CLOSE CONN ?>
  14. I'm not sure how I got this error format it is just what the page is printing back to me when I hit submit, I'm using mysqli
  15. thank you that was a wonderful correction to my code. so now my code just is not inserting to the database, on submit the first records are sent to the database then I get an error as follows, "New record created successfully player name: 'Alberto', points: 5 ERROR: INSERT INTO bg_points(player_name, points) VALUES ('brs_edu2', 5) player name: 'brs_edu2', points: 5" then this repeats for every row after that any idea why it is failing after the first record inserts??
  16. Hello to you all this code I am working on just will not quiet work for me I know as always I am missing something basic that's why I thought one of you may kindly help me fix it. I have a form a very basic form a text area and a submit button, in the form my user will be submitting a result set of player names and points from a tournament, the result set looks like: player1 5 player2 5 player3 5 player4 10 player5 10 player6 15 player7 20 in the actual results player1 would be a player name followed by the points of up to 120 points, I need to take that post on submission I'm sending it to a points_processing.php, I need to break that down to insert it into a database as individual player names and player points so that when the next report is submitted I can check for the player name (if exists ) add the new points to the current total and save it again back to my database. so I started putting together a script to catch and explode this result set see my posted script, //explode the post into an array $points = $_POST['points']; $player_name = explode(" ", $points); //get the INT points value $player_points = str_split($player_name, -3); // count the array length $player_count = count($player_name); for($i = 0; $i<$player_count; $i++) { if I echo player_name[$I] I get the post echo but I can not seem to separate the INT point value from the end of each line, please please can anyone help me work out how to get this done P.S I have attached a screenshot of an actual result set that will be posted, everything from START POINTS to STOP POINTS will be submitted.
  17. oh ok ummm right then on that note I will have to have you both have said look into using one of these libraries thanks
  18. yes that would be the really easy method to have used a third party editor. and it would have left my evening very boring HAHA.... no that's not what I am trying to do the whole idea of creating a CMS in the first place was to lean how to write and best practise coding in general, also I am working on extending this into a fully customised system as I have already put together the user authentication system for this so n a nut shell I am trying to learn to build this system myself allowing me to customise it and to Taylor the functionality of this user authentication and the general CMS specific to this set group (my end users) the reason I need it so specific is that my end user are a small group of volunteers that are able to use a computer but on the most part that is all they can do they have no knowledge of any coding not even how to inline CSS their font styles.... this s why I said if I was too add a series of buttons and options in the same way this post box has across the top ( just less of them) my issue is firstly how to deal SAFELY with that code generated from the buttons that's why I asked would it be good practise to use the character count on a post then save the character position and desired CSS into a separate MYSQL table then on call of that page concatenate all that back together?
  19. mine was more a statement as I have used some of Lynda tutorials
  20. $errors = array(); // perform validations on the form data $required_fields = array('menu_name', 'position', 'visible', 'content'); $errors = array_merge($errors, check_required_fields($required_fields, $_POST)); just to check that you have set up your errors array properly into your field validation something like: and your form functions.php
  21. Hi I have been putting together a CMS system for users that have no idea how to use HMTL, at this time I have managed to build a basic CMS and now I am looking to extend the functionality of its use, right now the user can view the public pages with links, login to the Admin area to manage the subjects or pages and visibility of all and delete any of all or add an admin member, that's a nut shell to a ot of work already done; moving forwards I want to take away the need for any user ever needing to type any code, so if they wish to change the font colour, weight, type o back ground colour or image etc..... so how would anyone recommend working this, I was thinking maybe add buttons and selection boxes that save the correct data into a separate table and retrieve both and concatenate it back together
  22. for this project that I am working on the most sensitive data types I need to store is the user passwords and their personal profile data, ok I am going to give you a quick run down of this, I am involved in an online gaming community of volunteers, they host tournaments on a gaming site in games like back gammon, cribbage, Euchre, spades and pachisi this site I am making is a place where they can go for information sharing and later to store their files for their macro pushing tools also they post all tournament results and points to a forum I put on, So I want them to go to my home page and log in firstly of course I want all members to register and create a profile with rankings systems to allow me to set moderation abilities I am putting this site together for them but as a learning experience for me so that I can later go on and improve upon this codes and make something bigger and better
  23. I am curious here as far as I am aware there is no remote access to the MySQL system on my cpanel so how safe is the information in my database's
  24. ok so there was my really bad idea so now you have all given me enough to think about and research to go away a re look at this and start over, design all of it using my own codes and ideas to fit what I need, maybe I will have more success this way
  25. I have error reporting on the top of index.php and the process_login.php is only an include file to index.php, as for what data is been sent and echo'ing this data or printing it on a page, No data is been sent at all when you click on the submit button nothing happens at all that's the whole problem that's why I cant fix this myself I don't understand the nothing, feel free to view this page on my domain: mnvb.co.uk/secure_login/ that will go to the index.php page as above
×
×
  • 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.