Results 1 to 40 of 67

Thread: [RESOLVED] Re-designing a flash site in (x)html

Hybrid View

  1. #1

    Thread Starter
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: Re-designing a flash site in (x)html

    Quote Originally Posted by SambaNeko View Post
    Code:
    $username = mysql_real_escape_string($_POST['Aaron']);
    $password = mysql_real_escape_string($_POST['Aaron']);
    $insert = "insert into users (username, password) values (' $username', '$password')";
    My assumption would be that you haven't connected to a database, mysql_real_escape_string() is failing as a result, and - intentionally or not - you have the error message suppressed. This causes $insert to resolve to "insert into users (username, password) values ('','')". As has been repeated here, you must connect to a MySQL database before using mysql_real_escape_string().
    I do connect to the database I not that stupid here is the full code including the above sample.

    PHP Code:
    <?php
    // Database connection variables
    $dbDatabase "BazaarCeramics";

    //connect to db
    $conn = @mysql_connect("localhost""root""");
    if (!
    $conn) {
    die(
    "Connection failed: " .mysql_error());
    }

    //create database
    $query "CREATE DATABASE IF NOT EXISTS BazaarCeramics";
    if (
    mysql_query($query$conn)) {
    echo (
    "Database create query successful!");
    }else {
    die (
    "Database query failed: " .mysql_error());
    }
    //select database
    if (mysql_select_db($dbDatabase$conn)) {
    echo (
    "Database selection successful!");
    }else {
    die (
    "Could not locate test database" .mysql_error());
    }
    //create tables
    $query "CREATE TABLE IF NOT EXISTS users
    (username varchar(40) not null primary key,
    password varchar(20))"
    ;
    if (
    mysql_query($query$conn)) {
    echo (
    "Table users query successful!");
    }else {
    die (
    "Database query failed: " .mysql_error());
    }
    $query "CREATE TABLE IF NOT EXISTS products
    (productid varchar(20) not null primary key,
    pPrice decimal (8,2), pImagePath varchar(100), pImageType varchar(100))"
    ;
    if (
    mysql_query($query$conn)) {
    echo (
    "Database products query successful!");
    }else {
    die (
    "Database query failed: " .mysql_error());
    }
    //insert data into tables
      
    $username mysql_real_escape_string($_POST['Aaron']);
      
    $password mysql_real_escape_string($_POST['Aaron']);
    $insert "insert into users (username, password) values ('$username','$password')"
    if (
    mysql_query($insert$conn)) {
    echo (
    "Insert query successful!");
    }else {
    die (
    "Database query failed: " .mysql_error());
    }
    ?>
    Last edited by Nightwalker83; Oct 16th, 2009 at 08:03 PM. Reason: Fixing spelling!
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width