Page 2 of 2 FirstFirst 12
Results 11 to 15 of 15

Thread: mySQL/PHP error

  1. #11
    Join Date
    Apr 2005
    Location
    North Carolina, USA
    Posts
    4,535
    Tokens
    0

    Latest Awards:

    Default

    LOL He knows that thats the reason he wants help ;o

  2. #12
    Join Date
    Apr 2006
    Location
    England
    Posts
    71
    Tokens
    0

    Default

    Create a file called mysql_connect.php
    in that file, add:

    PHP Code:
    <?
    $connect 
    mysql_connect("localhost","DATABASE USERNAME","DATABASE PASSWORD"); 
    mysql_select_db(DATABASE NAME) or die(mysql_error());
    ?>
    in rares.php, add this code in:

    PHP Code:
    <?
    include("mysql_connect.php");
    if(
    $_POST['submit']) 

    //checks to see if the form was submitted. 
    $name $_POST['name']; 
    $desc $_POST['desc']; 
    $pict $_POST['pict']; 
    $value $_POST['value']; 
    $submitted $_POST['submitted'];
    $notes $_POST['notes']; 
    $date date("F jS, Y"); 
    if(
    $name 0|$entry==NULL

    //a feild was left blank! 
    echo "The Name field was left out, please fill in."

    else 

    //No feilds were left blank, we continue.. 
    $query mysql_query("INSERT INTO rares (name, desc, pict, value, submitted, notes,
    date) VALUES('
    $name', '$desc', '$pict', '$value', '$submitted', '$notes', '$date')") or die(mysql_error());
     
    echo 
    "The DB has successfully been updated."


    else 
    // the form was not submitted now we show it. 

    ?>
    <html>
    <head>
    <title>Habbo-wide.net - Site Management</title>
    <style type="text/css">
    BODY {
    <!--
    body {
    SCROLLBAR-ARROW-COLOR: #7F552B;
    SCROLLBAR-BASE-COLOR: #ECC547;
    SCROLLBAR-FACE-COLOR: #ECC547;
    SCROLLBAR-HIGHLIGHT-COLOR: #FFF3B7;
    SCROLLBAR-SHADOW-COLOR: #B17038;
    SCROLLBAR-3DLIGHT-COLOR: #FFF3B7;
    SCROLLBAR-TRACK-COLOR: #C9BDCC;
    SCROLLBAR-DARKSHADOW-COLOR: #B17038;
    }
    -->
    </style>
    </head>
    <body link="#991815" vlink="#991815" alink="#991815" bgcolor="#ECC547" text="#7F552B">
    <font face="Verdana" size="1">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
    <tr>
    <td width="100%">
    <p align="left"><font face="Verdana" size="1"><b><a href="http://www.habbo-wide.net/sitedb" target="_self">Site
    Databases</a> &gt; <a href="http://www.habbo-wide.net/sitedb/rares.php" target="_self">Rares</a>
    &gt; </b>Adding</font></td>
    </tr>
    <tr>
    <td width="100%">
    <p align="center"><font type="Verdana" size="1" face="Verdana"><b>Adding a
    Rare</b></font>
    </td>
    </tr>
    </table> </font> <form method="POST"> 
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
    <tr>
    <td width="11%" align="right">
    <p align="right">
    <font face="Verdana" size="1">
    Name:</font></td>
    <td width="89%">
    <font face="Verdana" size="1">
    <input type="text" size="57" maxlength="25" 
    name="name"></font></td>
    </tr>
    <tr>
    <td width="11%" align="right">
    <font face="Verdana" size="1">
    Description:</font></td>
    <td width="89%"><font face="Verdana" size="1"><input type="text" size="57" maxlength="25" 
    name="desc" ></font></td>
    </tr>
    <tr>
    <td width="11%" align="right">
    <font face="Verdana" size="1">
    Picture:</font></td>
    <td width="89%"><font face="Verdana" size="1"><input type="text" size="57" maxlength="25" 
    name="pict"></font></td>
    </tr>
    <tr>
    <td width="11%" align="right">
    <font face="Verdana" size="1">
    Rare Value:</font></td>
    <td width="89%"><font face="Verdana" size="1"><input type="text" size="3" maxlength="25" 
    name="value"> CS</font></td>
    </tr>
    <tr>
    <td width="11%" align="right">
    <font face="Verdana" size="1">
    Submitted by:</font></td>
    <td width="89%">
    <font face="Verdana" size="1">
    <textarea rows="2" name="submitted" cols="48"></textarea></font></td>
    </tr>
    <font face="Verdana" size="1">
    <tr>
    <td width="100%" align="right" colspan="2">
    <p align="center"><font face="Verdana" size="1">The ID is automactically
    assigned upon 'Add to the DB'</font></td>
    </font>
    </tr>
    <font face="Verdana" size="1">
    <tr>
    <td width="100%" align="right" colspan="2"></td>
    </tr>
    </font>
    <tr>
    <td width="100%" align="right" colspan="2">
    <p align="center"><b><font face="Verdana" size="2">Staff
    Notes; </font></b><font face="Verdana" size="1">Staff dates
    must be written in the following format, 3-letter month (Jan,
    Feb, Mar), 2-digit day (01-09,10-31), and 4 digit year (2006),
    correct date would be 'Apr 24, 2006'</font></td>
    </tr>
    <font face="Verdana" size="1">
    <tr>
    <td width="100%" align="right" colspan="2">
    <p align="left"><font face="Verdana" size="1"><textarea rows="9" name="notes" cols="80"></textarea></font></td>
    </tr>
    <tr>
    <td width="11%" align="right"></td>
    <td width="89%">
    <p align="center"><font face="Verdana" size="1"><input name="submit" type="submit" value="Add to the DB"> 
    </td>
    </tr>
    </table>
    </form> </body>
    </html>
    <?

    ?>
    That might work.
    Last edited by Arisham; 03-05-2006 at 10:15 PM.

  3. #13

    Default

    Ty so much it works now, next step, how do I get it to retrieve from the DB? eg i want a page rareview.php?id=0001 with id=0001 retrieving 0001 from the DB

  4. #14
    Join Date
    Jun 2005
    Posts
    4,795
    Tokens
    0

    Latest Awards:

    Default

    Since we dont know your database structure we cant help you.

  5. #15

    Default

    There is an image of my structure in page 1, near the bottom, apart from that only other info is the ID is the PRIMARY key, and a auto_increment

Page 2 of 2 FirstFirst 12

Posting Permissions

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