Php+mysql The simplest message board

Source: Internet
Author: User

Remember to do your homework.


<?php header ("content-type:text/html; Charset=utf-8 ");  $con = mysql_connect ("* * *", "* * *", "* * *"), if (! $con) {die (' Could not connect: '. Mysql_error ()); }//connect table mysql_query ("SET NAMES UTF8"); mysql_select_db ("message", $con); $sql = "CREATE TABLE message (id int not NULL auto_increment, PRIMARY KEY (ID), name varchar (e), email varchar (page), Content varchar () ";//mysql_query ($sql, $con); $name = $_post[' name ']; $email = $_post[' Email ']; $content = $_post[' content '; $sql 1 = "INSERT into message (name,email,content) VALUES (' $name ', ' $email ', ' $ Content ') "; mysql_query ($sql 1, $con); echo" <table border= ' 1 ' ><tr><th>id</th><th>name </th><th>email</th><th>content</th></tr> "; $result = mysql_query (" SELECT * FROM  Message "), while ($row = Mysql_fetch_array ($result)) {echo" <tr> "; echo "<td>". $row [' id '].  "</td>"; echo "<td>". $row [' name '].  "</td>"; echo "<td>". $row [' email ']. "</TD> "; echo "<td>". $row [' content '].  "</td>";  echo "</tr>"; }echo "</table>"; mysql_close ($con);? >

Encounter a bug in the middle

Mysql_fetch_array (): supplied argument is not a valid MySQL result resource

When you navigate to the function, the value $result is not valid.

Suspect that the database is not connected successfully.

Judge $result, output mysql_error ();

The discovery is that there is no database selection.

Originally put on the local can be executed, originally placed on the site database name written form name.

Stupid cry. = =!!!

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Php+mysql The simplest message board

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.