Jump to content

mrchickenkiev

Members
  • Posts

    11
  • Joined

  • Last visited

Everything posted by mrchickenkiev

  1. Hallelujah! Straight through to the promised land this time, with the records listed on my website. Thanks boompa . As ginerjm has alluded to, I was getting really frustrated Now to get user forms, images uploaded.....
  2. Thanks Guru. Connected successfully , Unable to select database: Access denied for user mysql_error echo now tells me access denied to the new user name, and one presumes the old user name would have returned the same message. The connection echo still tells me I am connected. Logically I would have thought the same log in details apply to both connecting and to accessing the database, so that if I can't access the database I shouldn't have been able to connect either?
  3. Thanks for the tip on passwords and the information I have already given away, which I have now changed.
  4. DaveyK, I'm appreciating your comments btw. My reading insofar that I understand the links is that I should have done something like the following <?php $link = mysql_connect('localhost', 'curem801_pogopat', 'chickenkievs42'); if (!$link) { die('Could not connect: ' . mysql_error()); } echo 'Connected successfully'; $db = mysql_select_db('curem801_languages',$link)or die("Unable to select database"); Where I am now connecting successfully but getting "Unable to select database". I'm flicking between your links and my Dummies book on Website building. I realise the main bit of code I copied from a website, omitted the $db line which doesn't refer to the variable $link as my Dummies book does.
  5. The error message becomes no database selected. And I now get your point about code tags. Thanks. The database should be curem8019_languages, mentioned in the connection code, and the table within the database is rebus_tbl. So what it is missing now, I wonder?
  6. I've been trying to run the code now with the mysql_close($link);element removed, and the error message I get still relates to the following line while( $row = mysql_fetch_assoc($query) ) albeit that the line number has changed due to editing between lines. When I enter the error message into Google search, I am either told that the error relates to the query, or there is still a connection error. Surely my connection error code would have flagged the latter eventuality and my SQL code is fairly mundane. I am also able to output the table to a CSV for excel format, from MyphpAdmin and it lists all the relevant records, using the same simple piece of SQL. I am presuming that the error message about the password also related to mysql_close($link); I've tried other versions of the code including error messages to indicate whether the SQL was incorrect, but it flagged nothing up, so I've removed them, for simplicity's sake. I'll list my code in full now. <?php $link = mysql_connect('localhost', 'curem5801_pogopat', 'chickenkievs427','curem8019_languages'); if (!$link) { die('Could not connect: ' . mysql_error()); } echo 'Connected successfully'; $sql = "SELECT * FROM `Rebus_tbl`"; $query = mysql_query( $sql ); echo "<table>"; //now read and display the entire row of a table one by one looping through it. //to loop we are using While condition here while( $row = mysql_fetch_assoc($query) ) { echo "<tr><td>$row[Word]</td></tr>"; echo "<tr><td>$row[Order]</td></tr>"; echo "<tr><td>$row[Translation]</td></tr>"; } echo "</table>"; ?>
  7. Thanks. I think the connect code is essentially the same as on my previous attempt (highlighted in blue at the bottom of the page), with no reference this time to mysqli, anywhere in the code. As I said this code is now placed in a dedicated .php extension file in my public_html folder, which I suspect is not good from a security perspective. Perhaps the line I've highlighted below in red, closed the connection, though now when I run the code with that line omitted I'm getting the following error message: Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in /home/curem8019/public_html/connect.php on line 20 Line 20 should be part of the following lines of code: while( $row = mysql_fetch_assoc($query) ) { echo "<tr><td>$row[Word]</td></tr>"; echo "<tr><td>$row[Order]</td></tr>"; echo "<tr><td>$row[Translation]</td></tr>"; } <?php $link = mysql_connect('localhost', 'curem5801_pogopat', 'chickenkievs427','curem8019_languages'); if (!$link) { die('Could not connect: ' . mysql_error()); } echo 'Connected successfully'; mysql_close($link);
  8. At the moment I've got two books in front of me, and the internet, and I'm still stuck My connection code suggests I'm connected but the following error message suggests otherwise. Connected successfully Warning: mysql_query() [function.mysql-query]: Access denied for user 'curem801'@'localhost' (using password: NO) in /home/curem801/public_html/connect.php on line 12 function.mysql-query Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/curem801/public_html/connect.php on line 12 Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in /home/curem801/public_html/connect.php on line 20 I've got rid of the hyperlink that was in the function.mysql-query text. I created a php doc with the code in it but I am now getting error messages on lines 12 and 20, marked with **. The code is as follows from the sql query onwards: $sql = "SELECT * FROM `Rebus_tbl` LIMIT 0, 30 "; **$query = mysql_query( $sql ); echo "<table>"; //now read and display the entire row of a table one by one looping through it. //to loop we are using While condition here **while( $row = mysql_fetch_assoc($query) ) { echo "<tr><td>$row[Order]</td></tr>"; echo "<tr><td>$row[Word]</td></tr>"; echo "<tr><td>$row[translation]</td></tr>"; } echo "</table>"; ?> I'm getting the impression that these are variables which aren't being recognized? I generated the SQL directly from my phpadmin.
  9. That figures because I culled the code from two separate sites so, I did wonder whether the mysql and mysqli were incompatible. I was just trying to boil everything down to the bare minimum of code just to get the connection up and running. Hope I can get back to you guys because, I'm still not clear. I'm presuming I was correct to place the code between the two body tags in the HTML to begin with? Thanks again.
  10. Hi Everyone, Apologies for the basic question, but since I can't see where I am going wrong, I probably won't get far reading the FAQ's. I've been using a section of code just to see whether I can connect up to my MySQL database, and after the last part of the statement I keep getting the text appearing on the relevant web page as if it were a comment. I've changed some of the details of the connection for security reasons, but this is essentially what I have got on the web page. Everything after the "Connected" text gets written onto the page, rather than displaying the database results. I tinkered a bit with the tags around "Connected", whose line originally had a semicolon at the end, but regardless of what I do at the end of this line I still get text. Any suggestions? Thanks. <body> <?php mysql_connect("localhost", "curem5801_pogopat", "chickenkievs427","curem8019_languages") or die('Unable to connect to MySQL'); echo <h1>Connected</h1> $result = mysqli_query($link, 'SELECT * FROM Rebus34_tbl'); while($row = mysqli_fetch_assoc($result)){ echo $row['curem5801_pogopat']; } ?> </body>
×
×
  • 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.