Jump to content

JohnSmithers

New Members
  • Posts

    9
  • Joined

  • Last visited

    Never

Everything posted by JohnSmithers

  1. Tried to send you a PM. That sorted out a lot of ills and saved a bucket full of time. Perhaps you coluld recommend how I can thank you and this forum?
  2. Thanks for all your assistance and advice for posting. I had been giving myself a crash course on this a few months ago. The first code is lifted from an external source - the apostrophes were not in at all previously and I had tried all connotations on this; none of them work. My second code was one which I had lifted from an example I had been working on during the "crash course"; I had forgotten the differences. I suspected I could not access the database and I think this is a "port forwarding" issue, but the fact that my result said "got this far" confused me as I assumed I was connected (?). I assume therefore that I am not connected at all. Is there any advice you can give me to test if the connection actually works first, before I test for accessing the tables?
  3. I used the following code: <?php echo "hi there"; $usr = "xxxxxxxxxxx"; $pwd = "xxxxxxxxxx"; $db = "samdb"; $host = "xx.xxx.xxx.xxx"; $sqlCon = mysql_connect($host, $usr, $pwd); mysql_select_db("database_name"); if (!$sqlCon) { echo("ERROR: " . mysql_error() . "\n"); } // GET THE CURRENTLY PLAYING SONG INFO $curPlay = mysql_query("SELECT * FROM `historylist' ORDER BY date_played DESC LIMIT 1"); $curPlayRow = mysql_fetch_assoc($curPlay); if (!$curPlay) { echo( mysql_error()); } ?> and got the following message: hi there Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\samtest\samtest.php on line 13 No database selected I also tried this: <?php echo "hi there"; function db_connect() { $result = new mysqli('xx.xxx.xxx.xxx', 'xxxxx', 'xxxxx', 'samdb'); if (!$result) { throw new Exception('Could not connect to database server'); } else { return $result; } } echo "got this far"; // GET THE CURRENTLY PLAYING SONG INFO $curPlay = mysql_query("SELECT * FROM historylist ORDER BY date_played DESC LIMIT 1"); $curPlayRow = mysql_fetch_assoc($curPlay); if (!$curPlay) { echo( mysql_error()); } ?> and got this result: hi theregot this far Warning: mysql_query() [function.mysql-query]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\xampp\htdocs\samtest\samtest2.php on line 20 Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in C:\xampp\htdocs\samtest\samtest2.php on line 20 Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\samtest\samtest2.php on line 21 Access denied for user 'ODBC'@'localhost' (using password: NO) can anyone help with this?7 MySQL sever version 5.5.8 clinet version 5.0.7 I'm using xampp but I can't find the version of this, but it was the latest from about two months ago. Thanks in advance MOD EDIT: code tags added
  4. First up. I have heeded the warning and will in future post what you need. I am very appreciative of people around the world taking time to respond to these questions and the least I can do is follow what's asked for. Having said that i found the solution by removing "PASSWORD" from the following part of the code leaving "password = '$pwd'" $sql = "SELECT * FROM supporters WHERE username = '$username' AND password = PASSWORD('$pwd')"; Why would having PASSWORD make a difference? Server version - 5.1.41 CREATE TABLE `supporters` ( `supporterid` int(10) unsigned NOT NULL AUTO_INCREMENT, `username` char(50) NOT NULL, `password` char(100) NOT NULL, `email` varchar(60) DEFAULT NULL, `Registration` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`supporterid`) ) ENGINE=InnoDB AUTO_INCREMENT=43 DEFAULT CHARSET=latin1
  5. I'm only a noob. A keen amateur. So any assistance is appreciated. Test of this code? I don't know what you mean? Seriously. All I know is that i put the username and password in. I know its connecting to the database, but returns the null response even when I can look at the database - through phpmyadmin - and see the username and password are there.
  6. should really include the final part of this.... if (mysql_num_rows($result) == 0) { unset($_SESSION['username']); unset($_SESSION['pwd']); ?> <!DOCTYPE html PUBLIC "-//W3C/DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title> Access Denied </title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> </head> <body> <h1> Access Denied </h1> <p>Your user ID or password is incorrect, or you are not a registered user on this site. To try logging in again, click <a href="<?=$_SERVER['PHP_SELF']?>">here</a>. To register for instant access, click <a href="signup.php">here</a>.</p> </body> </html> <?php exit; } $username = mysql_result($result,0,'username');?>
  7. Is there anything wrong with this code? This appears to be the only way it accesses the database but any username and password which exists in the table 'testtable' is not found. Any help appreciated. <?php include_once 'common.php'; include_once 'db.php'; $username = isset($_POST['username']) ? $_POST['username'] : $_SESSION['username']; $pwd = isset($_POST['pwd']) ? $_POST['pwd'] : $_SESSION['pwd']; if(!isset($username)) { ?> <!DOCTYPE html PUBLIC "-//W3C/DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title> Please Log In for Access </title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> </head> <body> <h1> Login Required </h1> <p>You must log in to access this area of the site. If you are not a registered user, <a href="signup.php">click here</a> to sign up for instant access!</p> <p><form method="post" action="<?=$_SERVER['PHP_SELF']?>"> Username: <input type="text" name="username" size="8" /><br /> Password: <input type="password" name="pwd" SIZE="8" /><br /> <input type="submit" value="Log in" /> </form></p> </body> </html> <?php exit; } $_SESSION['username'] = $username; $_SESSION['pwd'] = $pwd; dbConnect(); $sql = "SELECT * FROM testtable WHERE username = '$username' AND password = PASSWORD('$pwd')"; $result = mysql_query($sql); if (!$result) { error('A database error occurred while checking your '. 'login details.\\nIf this error persists, please '. 'contact admin@test.com.'); }
  8. Yes. 100% (confirmed). :-( Just in case - was going to check this one out later - when I first logged in to phpmyadmin I placed a random selection of letters for my blowfish secret; I've still to read up on this (to refresh me from Welling and Thomson) but is that a threat to my long-term control of the database? Will it make any difference in this case? Ignorant, but fast learner; but willing to learn hard !
  9. My first post in here. The issue is when I try to access my database online I get the following messages: Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'Harry'@'localhost' (using password: YES) in /data/www/vhosts/liminalradio.mobi/httpdocs/signupbasic.php on line 115 Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in /data/www/vhosts/liminalradio.mobi/httpdocs/signupbasic.php on line 117 Could not connect: Access denied for user 'Harry'@'localhost' (using password: YES) (note - I also ran an alternative piece of code earlier that appeared to add user details to the database, but it wasn’t there when I looked; hence the reason I changed it for my old code that I knew worked). In phpmyadmin, "Harry" is the only name that has access to the database and the password has been double-checked. Is it my code or my server? ======================================= My code: ========================================== //connects to database $name = ($_post['username']); $password = ($_post['password']); $email = ($_post['emailaddress']); $awareness = ($_post['awareness']); if(isset($_POST['submitok'])) { //$dbhost = 'localhost'; //$dbuser = 'Harry'; //$dbpass = 'x67sfd'; //$dbname = 'CloudenRoad'; //$table = 'supporters'; $conn = mysql_connect('localhost','Harry', 'x67sfd'); mysql_select_db($dbname, $conn); if (!$conn) { die('Could not connect: ' . mysql_error()); } echo "it works again";
×
×
  • 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.