Member Avatar for LastMitch

Hi

I'm having an issue SELECT to database, I been working on it all day. I'm still new to MYSQL.

I created a table: Records

Table: Records
Fields: id (INT(25), primary key, No Null, auto-increment)
Fields: title (VARCHAR(256), No Null)
Fields: content (TEXT, No Null)

<php if (isset ($ _POST ['submit'])) {
          $ title = $ _POST ['title'];
          $ content = $ _POST ['content'];

          $ register = "INSERT INTO records (title, content) VALUES ('$ title', '$ content')";
          $ qr = mysql_query ($ register);
              if ($ register> = 'l') {
                   echo "Your post was published";
                   }
}
?>

-

<form action="" method="post" enctype="multipart/form-data">
<span> Title </ span> <input type="text" name="title" size="50" /> <br /> <br />

<textarea name="content" rows="15" cols="80">
</ textarea> <br />

<input type="submit" name="submit" value="Submit" />
</ form>

-

<php
      $ select = "SELECT * FROM Records";
      $ qrone = mysql_query ($ select);
          while ($ ln = mysql_fetch_array ($ qrone)) {
?>
      <h2> <? php echo $ ln ['title'];?> </ h2>
       <? php echo $ ln ['content'];?>

<php
}
?>

I get this error:

mysql_fetch_array() expects parameter 1 to be resource, boolean given in

$qrone = mysql_query ($ select);

so I put

$qrone = mysql_query ($ select) or die (mysql_error());

to check the error.

It said "No database selected"

I mean I connected the database and it's working.

Is there any solution for this error?

I really appreciate if someone explain to me how to this works correctly. Thanks!

Member Avatar for LastMitch

@ShadyTyrant

Thanks for the reply and also thanks for the link! I will look into it and test it out. If I have any issue, I will post it Thanks!

Member Avatar for LastMitch

@ShadyTyrant

Thanks for the link! I finally got it working now! I appreciate your help. Thanks!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.