• Our friends from the Johto Times are hosting a favorite Pokémon poll - and we'd love for you to participate! Click here for information on how to vote for your favorites!
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

PHP/MySQL

Kipkip

Join the Revolution
  • 967
    Posts
    21
    Years
    • Age 34
    • Seen Jun 24, 2007
    Ok, I'm making a tagboard for my first PHP/MySQL script and I think I have something wrong with the input query since nothing shows up in the table. Can anyone help? Here's the code:
    PHP:
    <?php
    include("dbinfo.php");
    
    $name=$_POST['name'];
    $website=$_POST['website']; 
    $email=$_POST['email'];
    $message=$_POST['message'];
    
    mysql_connect(localhost,$username,$password);
    @mysql_select_db($database) or die( "Unable to select database");
    
    $query = "INSERT INTO tagboard VALUES ('','$name,'$website','$email','$message')"; 
    mysql_query($query);
    
    mysql_close(); 
    
    ?>
    I don't see any error in it or my dbinfo page. Can someone please help? And if you know how to use a file for the database instead of a MySQL database, can you please help me on that too? Thanks.
    Also, if you need it, here's what's in the table:
    Name Type Length Extra
    id INT 6 PRIMARY auto_increment
    website VARCHAR 15
    email VARCHAR 15
    message VARCHAR 50
     
    Last edited:
    Err... I don't know all that much about php/mySQL yet... but...

    PHP:
    $name=$_POST['name'];
    $website=$_POST['website'];
    $email=$_POST['email'];
    $message=$_POST['message'];
    Should be...
    PHP:
    $name = $_POST['name'];
    $website = $_POST['website'];
    $email = $_POST['email'];
    $message = $_POST['message'];

    Right? O-o
     
    PokeVillage said:
    well this HelloPichu i know alot about PHP
    Please... only post if you can help him...
     
    I don't really think the way you're going about it is correct. Then again there are probably more than one way to retrieve data from your database. this is how I do it.

    first connect
    PHP:
    //Connecting to the database
      	ConnectToDatabase($user, $pass, $db);

    then the query
    PHP:
    $result = GetPokemonInfo(8);
      	while($a_row = mysql_fetch_object($result))
      {

    now i left the curly bracket open because what you'll have within it is the array. it'll end up being somthing like this
    PHP:
    print "$a_row->EnglishName"
    if the feild you're trying to access is called "EnglishName".
    then you just close the while function, database and connection

    I took this code from one of my projects, so it'll look alil diffrent than yours. for example, in your script $result may equal:
    PHP:
    			$result = mysql_query("SELECT * FROM tblPokemonJokes WHERE tblPokemonJoke.ID = "Pikachu");
     
    Master Kwesi Nkromah said:
    I don't really think the way you're going about it is correct. Then again there are probably more than one way to retrieve data from your database. this is how I do it.

    first connect
    PHP:
    //Connecting to the database
      	ConnectToDatabase($user, $pass, $db);

    then the query
    PHP:
    $result = GetPokemonInfo(8);
      	while($a_row = mysql_fetch_object($result))
      {

    now i left the curly bracket open because what you'll have within it is the array. it'll end up being somthing like this
    PHP:
    print "$a_row->EnglishName"
    if the feild you're trying to access is called "EnglishName".
    then you just close the while function, database and connection

    I took this code from one of my projects, so it'll look alil diffrent than yours. for example, in your script $result may equal:
    PHP:
    			$result = mysql_query("SELECT * FROM tblPokemonJokes WHERE tblPokemonJoke.ID = "Pikachu");

    Yeah, that's retriving. The problem is inserting the infomation I guess because phpMYAdmin is telling me that there's nothing in the table. But I like your way, it's better than the one in the tutorial I followed.
     
    Uhh, yeah.. you would have to insert data into the table before you could retrieve it.. hehe. if you'd like I can post a full tutorial of how i accessed and retrived data from a database.
     
    Back
    Top