Jump to content

Search the Community

Showing results for tags 'php mysql sql forms'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 1 result

  1. Hi, I'd like to apologize if I sound like a noob. Other than a book on dummies about php and mysql, I'm new to php and mysql combined. Here is the code where my form is: <class="form-horizontal"> <!-- this is bootstrap form type --> <div id="question"><h1>Have a question?</h1></div> <div class="well span5"> <div class="control-group> <!-- made for each form type --> <div class="control-label" for="name"><strong>Query</strong></label> <div class="controls"> <!-- start form stuff here --> <form action="queries.php" method="post" /> <input type="text" class="span5" placeholder="Type your question here!" name="user_questions" /> <input type="submit" value="Submit" class="btn-primary" /></button> </form> </div> </div> </div> </div> as you can see, the name of the form is "user_questions and the php script linked to it is queries.php. Here is the php code linking mysql to the form: <?php error_reporting(-1); define ('DB_NAME', 'questions'); define ('DB_USER', 'root'); define ('DB_PASSWORD', ''); define ('DB_HOST', 'localhost'); $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if (!$link) { die('Could not connect: ' . mysql_error()); } $db_selected = mysql_select_db(DB_NAME, $link); if (!$db_selected) { die('Can\'t use ' . DB_NAME . ':'.mysql_error()); } echo 'Connected successfully'; $value = $_POST['user_questions']; $sql = "INSERT INTO questions_user (questions_field) VALUES ('$value')"; if (!mysql_query($sql)) { die('Error: ' . mysql_error()); } mqsql_close(); ?> (yes i'm aware that having root and no password is very dangerous. This website that i'm making is only a project i'm doing to gain more experience.) As you can see. The script will die if anything doesn't work and it will give me an error message. However if it successfully gets through linking the database then it will say "successfully connected". When I put a query into my form and submit, I'm sent to the queries.php page where it says "successfully connected". Since I haven't made any redirecting or anything it just stops there. But then I go to my database to see if the data is stored and it is empty. **DATABASE INFO** The db name is "questions" The only table is "questions_user" The 2 fields are "ID", which is the primary key with A I and "questions_field" which stores the data with TEXT. If you need anything else just let me know. It's driving me insane. Thanks, Fisher
×
×
  • 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.