Jump to content

frenchpl

Members
  • Posts

    22
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

frenchpl's Achievements

Member

Member (2/5)

0

Reputation

  1. Hi I am migrating my mysql database from windows xp to centos 6. I have the database up and running on the linux. However I cannot connect to it through firefox as I usually do on windows. I am pretty sure that my PHP scripts are OK and this is a configuration issue. Reading the error logs I find that it is trying to connect via /var/lib/mysql/mysql.sock and cannot find it [Thu Jan 26 08:14:19 2017] [error] [client ::1] PHP Warning: mysql_connect(): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /var/www/htdocs/HomeLogIn.php on line 87, referer: http://localhost/HomeLogIn.php The correct location is of course /var/run/mysqld/mysql.sock There is obviously a configuration file somewhere that is setting the wrong path info, however I cannot find it. /etc/my.cnf is correct as is /etc/php.ini to the best of my knowledge ------------------------------------------------ my.cnf [client] port=3306 socket = /var/run/mysqld/mysql.sock # SERVER SECTION [mysqld] # The TCP/IP Port the MySQL Server will listen on port=3306 socket = /var/run/mysqld/mysql.sock #Path to the database root datadir="/var/lib/mysql/mysql" -------------------------------- I checked the /etc/httpd content and that seemed OK too. Obviously I am missing one somewhere but where, any thoughts please? I tried restarting Mysql with no effect at all. In fact shutting down the machine and restarting it makes no difference either.
  2. Thank you Kicken that worked just fine Now I have another configuration problem I have to solve. My firefox will not connect to the mysql. Reading the error logs I find that it is trying to connect via /var/lib/mysql/mysql.sock and cannot find it The correct location is of course /var/lib/mysqld/mysql.sock There is obviously a configuration file somewhere that is using the wrong info, however I cannot find it. /etc/my.cnf is correct as is /etc/php.ini I checked the /etc/httpd content and that seemed OK too. Obviously I am missing one somewhere but where??
  3. Can someone assist me please. I am trying to shift my mysql database from windows xp to centos 6. On the windows I am running mysql 5.0.83 and using administrator 1.2.17 However on the linux I am running mysql 5.1.83 and trying to use workbench 6.3 I have backed up my database using the administrator This created a windows Backup.sql file. Trying to transfer this to linux and then restore it will not work. The workbench just will not see the file even if I rename it. My next trial was to open the backup file with Kwrite and then to copy and paste the content directly into a mysql terminal. This was successful on creating no only the database but all the tables. However the data for the tables was a different story. If there was a very limited number of rows of data it worked Anything over 10 rows gives me a mysql syntax error. Is there a way around this other than trying to edit a file with thousands of rows of data. I know there is a difference in the mysql proc table column numbers from 16 in the older version to 20 in the newer but I do not think that should make a difference here.
  4. Thanks, I will have to do some more digging on it.
  5. Thanks for the reply Ken. Can you be a bit more specific here? Like where do I change the settings, in MySql, PHP, or the Apache server?
  6. Hi there, I will have a go at this and leave it open for others to follow. No doubt there will be a whole raft of answers telling me that I am wrong but here goes. From the way you phrase your question, it would seem that you code is 'data driven'. I would seriously suggest a look at object oriented coding and follow where that leads you. Pete.
  7. Sorry, my fault, finger trouble there. I missed the 's' off of the end of the function name. mysql_numrows($chars);
  8. Hi there The line that reads :- $rows =mysql_numrows($characters); Should read $rows = mysql_numrow($chars); This is returning a count of the number of rows found in your search. You are trying to use the table name here instead of the variable.
  9. Can someone please put me right. I have a complete and working set of scripts that access a mysql database. I am using a log in script to start. The log in script forms the URL for localhost and then connects to the selected database. All the scripts use the ./dir/dir form of addressing in any href's. I am now trying to access this from another machine on my network. I am sure that because I enter the IP address of the server, I get to the login script. When the script tries to get into the rest of the suit, I get the not found page error. It is of course trying to find 'localhost', from the ./ path. ( the dot representing localhost). Any ideas please??????
  10. I have a table display of eleven columns and multiple rows. I have no problem populating the table or displaying it. I now want one of the eleven columns to be an input column. Such that the user can 'check' this column, for any row of the displayed table. If I am displaying ten rows at a time from the DB, I need the user to be able to 'check' any number from one to all ten, before hitting the submit button and the values being recorded. Any suggestions please?
  11. Can someone please help with clarifying a puzzle for me. I tried asking this last week without any satisfactory answer. I am new to PHP and therefore totally green in this area. So far I have a full PHP5 / MySql5.0 / Apache2.2 server working on my system. I have a 'con.php' script which holds the mysql connection data in the form of userName passWord Host and dataBaseName, Looks something like this :- // MySQL Settings $Hostname = "localhost"; $Username = "root"; $Password = "**********"; $Database = "MyDatabase"; /* make connection to database */ /* If no connection made, display error Message */ $dblink = MYSQL_CONNECT($Hostname , $Username,$Password) OR DIE("Unable to connect to database"); /* Select the database name to be used or else print error message if unsuccessful*/ mysql_select_db("$Database") or die( "Unable to select database"); This connects to the MySql server using the 'root' user account as specified in the mysql.user table. I know that I should only use this in a require once statement and thereafter change the user to whoever is trying to log in. I have, in 'MyDatabase' a table called users, which is populated with users of my choice. I want these users to log in and use my custom database from PHP scripts. My problem is as follows :- If I do not include the 'con.php' in each script that accesses any MySql database, I get no connection. I am positive that using the 'root' user from the mysql.user table is not good and not what I want to do. I want to have an independant custom database which has it's own admin user and multiple other users. I want to be able to log into that database via a PHP script, if necessary using the require once function and then to keep the session alive for further transactions, over multiple scripts from the same user, until he/she logs out. I am aware of using the $_SESSION variables to identify the session, when it is operating. It is the initial log in and the difference between the 'mysql database = user table' and my own database users table, that is where I am having all my problems. Someone please explain this to me in simple terms. I can find no texts that clearly explain this, why is it made such a mystery? I am not looking for the scenario of x number of users logging in to x number of databases concurrently. Rather, I want to have x number of users, possibly concurrently logged in, making changes to the various tables in ONE database. At least one of these users will have 'admin' priviledges over the database, most of the rest being normal users. My project is a company helpdesk program, where normal users can log in to do various tasks associated with 'calls' to the helpdesk. Obviously the 'admin' user has greater powers like creating the users and deleting some records etc. To the nub of my non-understanding then. Do I use the 'con.php' script ( as shown above) to make the initial connection to MySql? Whatever I use for the initial connection, how do I change to my own user, when they log in? Thereby relieving the necessity to use an include of 'con.php' in each active database script. The other part to the question is this, when my admin user creates a user for the company database, is he creating a new user in the mysql.user table, I would think that this should not be the case. If he is creating a new user in the 'company' database users table, how is that user related to MySql? Thanks for any response Pete
  12. Well thanks again for another unhelpful and sarcastic reply. I gather that you are supposed to be good at this stuff but that is no use unless you have the temperament to go with it. I may ask questions that seem obvious to you. That is why I am here asking them. I am looking for some knowledge that I obviously do not have. I do not need help like this. Thanks anyway Pete
  13. I am trying to design a web based system. The user points his/her browser to my LogIn page, (LogIn.php). After entering ther username and password the user hits the submit button. All being well the input data is re-directed to the ValidateUser.php script. Here the username and password are checked against the database for validity. If correct the user is shown the main user control page for the system. If the user who logged in, is the Administrator then he is shown the main admin page. This all seems to work OK but only if I 'include' the datacon.php at the top of every script which has mysql interraction on it. If I do not do this I get the results shown below. without the datacon included Selection boxes are displayed but they are unpopulated. With including the datacon The boxes are populated with the correct fields. My original question was twofold. The first part was to cover this incorrect behaviour. The second part to the question was different. I note that within the MySql installation there is a user table, I also have a user table within the database that I have created. When I log in to my system, via the webpage which user table am I accessing? I thought that it was the one I created but now I am not too sure of that. Sorry, I snapped a coule of jpegs to display the results I am getting nut could se no way to include them. I am also posting the ValidateUser.php script for your perusal. <?php session_start(); // chech that we have a session if(!isset($_SESSION['user_id'])) { echo "You are not logged in"; exit(); } // User is redirected here from login form if no cookie is present redirect the user if(!isset($_SESSION['user_id'])) { // start defining the URL $url = 'http://' . $_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']); // Ceck for trailing slash if((substr($url, -1) == '/') OR (substr($url, -1)=='\\')); { $url = substr($url,0,-1); // chop the last slash } // Add the page $url .= '/ValidateUser.php'; header("Location: $url"); exit(); // Quit this script } if($_SESSION['user_id'] == 1) { // you are logged in as admin user // redirect the user to the admin page $url = 'http://' . $_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']); // Ceck for trailing slash if((substr($url, -1) == '/') OR (substr($url, -1)=='\\')) { $url = substr($url,0,-1); // chop the last slash } // Add the page $url .= '/MainAdmin.php'; // add the page header("Location: $url"); exit(); } else { // you are just a normal user // redirect the user to the non-admin page $url = 'http://' . $_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']); // Ceck for trailing slash if((substr($url, -1) == '/') OR (substr($url, -1)=='\\')) { $url = substr($url,0,-1); // chop the last slash } // Add the page $url .= '/MainIndex.php'; // add the page header("Location: $url"); exit(); } ?>
  14. Thanks for the answer wildteen. Surely you are asking my question, 'what is wrong with the code'. If you need more info to help then please tell me what you need to know. As I said I am fairly new to this PHP stuff.
  15. Hi guys, OK here goes with the code thing. My datacon.php looks like this, with the exception that I have blanked out the password etc. Then there is the login script which I am again copying below. If anyone beeds anything else just ask and I will try to get it posted. Thanks Pete Datacon.php -------------------------------------------------------------------- <?php // MySQL Settings $MySqlHostname = "localhost"; $MySqlUsername = "root"; $MySqlPassword = "********"; $MySqlDatabase = "*******"; /* make connection to database */ /* If no connection made, display error Message */ $dblink = MYSQL_CONNECT($MySqlHostname , $MySqlUsername, $MySqlPassword) OR DIE("Unable to connect to database"); /* Select the database name to be used or else print error message if unsuccessful*/ mysql_select_db("$MySqlDatabase") or die( "Unable to select database"); ?> ----------------------------------------------------------------------- LogIn.php ------------- <!login.php> <!Initial entry to all helpdesk units> <!Not called from other scripts direct from browser> <?php // send nothing to the browser before the session_start() line // Check if a form has been submitted if(isset($_POST['submitted'])) { require_once('datacon.php'); $errors = array(); // initialise error array // check for a user id if(empty($_POST['user'])) { $errors[] = 'you forgot to enter your user name.'; } else { $u = $_POST['user']; } // end if empty // Check for a password. if(empty($_POST['pass'])) { $errors[] = 'you forgot to enter your password.'; } else { $p = $_POST['pass']; } // end if empty if(empty($errors)) { // if everything is OK // check the user_id for the name and password combination $query = ("SELECT * FROM users WHERE userName='$u' AND userPass= SHA('$p')")or die(mysql_error()); $result = MYSQL_QUERY($query); $arr = mysql_fetch_row($result); if($arr[0]!="") // A row was found { $user_id = $arr[0]; $name = $arr[1]; session_start(); $_SESSION['user_id'] = $user_id; $_SESSION['userName'] = $name; // redirect the user to the logged in page $url = 'http://' . $_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']); // Ceck for trailing slash if((substr($url, -1) == '/') OR (substr($url, -1)=='\\')) { $url = substr($url,0,-1); // chop the last slash } // Add the page $url .= '/ValidUser.php'; header("Location: $url"); exit(); // Quit this script } else { // No record found $errors[] = 'The username and password do not match those found on file'; //Public message $errors[] = mysql_error() . '<br /><br />Query: ' . $query; // Debugging message } // end if record found }// end if empty errors mysql_close(); // Close the database connection } else { // form has not been submitted $errors = NULL; } // end of the main submit condition // begin the page now $page_title = 'Login'; include("UM\Head.php"); if(!empty($errors)) { // print any error messages echo '<h1 id="mainhead">Error!</h1> <p class="error">The following error(s) occured:<br />'; foreach($errors as $msg) { // print each error echo " - $msg<br />\n"; } echo '</p><p>Please try again.</p>'; } // Create the form ?> <center> <h1>Login</h1> <form action="login.php" method="post"> <p>User Name: <input type 'text' name = 'user' size = "20" maxlength="40"/></p> <p>Password: <input type = text name = 'pass' size = "20" maxlength="40"/></p> <p><input type="submit" name = "submit" value = "login" /></p> <input type = "hidden" name="submitted" value="TRUE"/> </form> </center> <?php include("UM\Foot.php"); ?>
×
×
  • 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.