Jump to content

username in mySQL?


johnseito

Recommended Posts

Ok but right now I need to know how to set up a username and make a connection, then I will try to manage it with phpmyadmin later on.

 

 

I want to be able to make a connection and input the data from php into mysql and then export out of a server.

 

so you know how I can set up a username?

 

thanks

Link to comment
https://forums.phpfreaks.com/topic/86848-username-in-mysql/#findComment-443956
Share on other sites

Thanks that works. 

 

Now I could filled the from and save it into mysql but I can't get it to post on the website.  The codes seems

to be correct.

 

<?php

//test database, info table
//login in as too


  if (isset($_POST['submit'])) {
  	 $link =mysql_connect("localhost","****","*****");
    mysql_select_db("test");
    $Name = mysql_real_escape_string($_POST['Name']);
    $Age = mysql_real_escape_string($_POST['Age']);
    $sql = "INSERT INTO info (Name,Age) VALUES ('$Name','$Age')";
    if (mysql_query($sql)) {
      header("Location: " . $_SERVER['PHP_SELF']);
    } else {
      echo "Failed to insert a new record";
    }
  }
  
// Make a MySQL Connection
/*
$query = "SELECT * FROM info"; 

$result = mysql_query($query) or die(mysql_error());


$row = mysql_fetch_array($result) or die(mysql_error());
echo $row['Name']. " - ". $row['Age'];

*/


$sql = "SELECT Name,Age,FROM info";
  if ($result = mysql_query($sql)) {
    if (mysql_num_rows($result)) {
      echo "<html><head><title>posts</title></head><body>";
      while ($row = mysql_fetch_assoc($result)) {
        echo "<p>{$row['Name']} - {$row['Age']}</p>";
        //echo "<p>{$row['subject']}</p>";
        //echo "<p>{$row['post']}</p><hr />";
      }
    }
  }


?>

<HTML>
<HEAD>
  <TITLE>Add a Weblog Entry</TITLE>
</HEAD>
<BODY>
  <H1>Add an Entry</H1>
  <form method="POST" action="info.php">
   <b>NAME:</b><br>
   <input type="text" name="Name"><br>
   <b>AGE:</b><br>
   
   <input type="text" name="Age"><br>
  <input type="submit" name="submit" value="Submit">
  </form>
</BODY>


</HTML>

 

any ideas what is going on here?  The thing is that I have two output one I greyed out, that one gives an error <b>Access denied for user 'ODBC'@'localhost' (using password: NO)</b> the other one that I used below it gives nothing.  I would like it to give the output

of what is in the database.

 

thanks -

Link to comment
https://forums.phpfreaks.com/topic/86848-username-in-mysql/#findComment-444345
Share on other sites

I think my connection should be fine since I could insert data into mysql with PHP but I can't get those data onto the server.

 

So do you know why I can pull those information out form the database?

 

thanks

I wish I did... but I don't know anything about php functions.  However, I'm sure I've seen the problem addressed before, you might want to search this forum.

Link to comment
https://forums.phpfreaks.com/topic/86848-username-in-mysql/#findComment-447992
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.