Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 3 123 LastLast
Results 1 to 15 of 31
  1. #1
    New Coder
    Join Date
    Oct 2006
    Posts
    42
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation Help me to Finish

    i have create litle script but i have missing some codes, plz help me to finish ...

    base.sql
    PHP Code:
    CREATE TABLE `products` (
    `
    idint(5NOT NULL auto_increment,
    `
    keyvarchar(25NOT NULL default '',
    `
    productvarchar(65NOT NULL default '',
    `
    detaillongtext NOT NULL,
    `
    selectvarchar(65NOT NULL default '',
    `
    datetimevarchar(25NOT NULL default '',
    PRIMARY KEY (`id`)
    TYPE=MyISAM AUTO_INCREMENT=;


    CREATE TABLE `category` (
    `
    idint(5NOT NULL auto_increment,
    `
    name1varchar(65NOT NULL default '',
    `
    name2varchar(65NOT NULL default '',
    `
    name3varchar(65NOT NULL default '',
    PRIMARY KEY (`id`)
    TYPE=MyISAM AUTO_INCREMENT=
    config.php
    PHP Code:
    <?php

    $dbhost 
    "localhost";
    $dbname "xxx";
    $dbuser "xxx";
    $dbpassword "xxx";

    $title "Products";
    $added "New Product has been successful added";
    $add "Add new Product";

    $key1 "Key";
    $product1 "Product";
    $detail1 "Detail";
    $new1 "New";
    $select1 "Select";
    $category1 "Category";
    $date1 "Date";

    ?>

  • #2
    New Coder
    Join Date
    Oct 2006
    Posts
    42
    Thanks
    0
    Thanked 0 Times in 0 Posts
    add.php
    PHP Code:
    <?php

    include("config.php");

    ?>


    <html>

    <head>
    <meta http-equiv="Content-Language" content="en-us">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title><?php $title?></title>
    </head>

    <body bgcolor="#C0C0C0">

    <div align="center">
        <table border="1" width="90%" style="border-left-style: solid; border-left-width: 2px; border-right: 2px solid #FFFFFF; border-top-style: solid; border-top-width: 2px; border-bottom: 2px solid #FFFFFF" cellpadding="0">
            <tr>
                <td bordercolor="#808080">&nbsp;<p>&nbsp;</p>
                <p>&nbsp;</td>
            </tr>
        </table>
        <table border="1" width="90%" cellpadding="0" style="border-left-style: solid; border-left-width: 2px; border-right: 2px solid #FFFFFF; border-top-style: solid; border-top-width: 2px; border-bottom: 2px solid #FFFFFF">
            <tr>
                <td bordercolor="#808080">&nbsp;</td>
            </tr>
        </table>
        <table border="0" width="90%" style="border-left-style: solid; border-left-width: 2px; border-right: 2px solid #FFFFFF; border-top-style: solid; border-top-width: 2px; border-bottom: 2px solid #FFFFFF" cellpadding="0">
            <tr>
                <td style="border-style: solid; border-width: 1px" bordercolor="#808080" bgcolor="#FF6600" colspan="2">
                <p align="center">$add</td>
            </tr>
            <tr>
                <td style="border-style: solid; border-width: 1px" bordercolor="#808080">
                $key1</td>
                <td style="border-style: solid; border-width: 1px" bordercolor="#808080">
                &nbsp</td>
            </tr>
            <tr>
                <td style="border-style: solid; border-width: 1px" bordercolor="#808080">
                $product1</td>
                <td style="border-style: solid; border-width: 1px" bordercolor="#808080">
                &nbsp;<input type="text" name="product" size="53" /></td>
            </tr>
            <tr>
                <td style="border-style: solid; border-width: 1px" bordercolor="#808080">
                $detail1</td>
                <td style="border-style: solid; border-width: 1px" bordercolor="#808080">
    &nbsp;<textarea rows="4" cols="45" name="detail"></textarea></td>
            </tr>
            <tr>
                <td style="border-style: solid; border-width: 1px" bordercolor="#808080">
                $new1</td>
                <td style="border-style: solid; border-width: 1px" bordercolor="#808080">
                <input type="checkbox" name="new" value="new"></td>
            </tr>
            <tr>
                <td style="border-style: solid; border-width: 1px" bordercolor="#808080">
                $cd1</td>
                <td style="border-style: solid; border-width: 1px" bordercolor="#808080">
                &nbsp;<select size="1" name="select">
                <option selected>- Select -</option>
                <option value="1">1</option>
                <option value="2">2</option>
                <option value="3">3</option>
                <option value="4">4</option>
                <option value="5">5</option>
                <option value="6">6</option>
                <option value="7">7</option>
                <option value="8">8</option>
                <option value="9">9</option>
                </select></td>
            </tr>
            <tr>
                <td style="border-style: solid; border-width: 1px" bordercolor="#808080">
                $category1</td>
                <td style="border-style: solid; border-width: 1px" bordercolor="#808080">
                &nbsp;<select size="1" name="category">
                <option selected>- Category -</option>
                <option value="name1">Name 1</option>
                <option value="name2">Name 2</option>
                <option value="name3">Name 3</option>
                </select></td>
            </tr>
            <tr>
                <td style="border-style: solid; border-width: 1px" bordercolor="#808080">
                <p>$data1</td>
                <td style="border-style: solid; border-width: 1px" bordercolor="#808080">
                &nbsp;</td>
            </tr>
            </table>
        <table border="1" width="90%" cellpadding="0" style="border: 2px solid #FFFFFF">
            <tr>
                <td bordercolor="#808080">
                <p align="center"><br>
                <form id="form1" name="form1" method="post" action="added.php">
    <input type="submit" name="Submit" value="Submit">&nbsp;&nbsp;&nbsp;&nbsp;
    <input type="reset" name="Submit2" value="Clear"><br>
    &nbsp;</td>
            </tr>
        </table>
    </div>

    </body>

    </html>
    added.php
    PHP Code:
    <?php

    include("config.php");

    // Connect to server and select database.
    mysql_connect("$dbhost""$dbuser""$dbpassword")or die("cannot connect server "); 
    mysql_select_db("$dbname")or die("cannot select DB");

    // get data that sent from form 
    $product=$_POST['product'];
    $detail=$_POST['detail'];
    $new=$_POST['new'];
    $select=$_POST['select'];

    //From select Category
    $name1=$_POST['name1'];
    $name2=$_POST['name2'];
    $name3=$_POST['name3'];

    $string "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    $key ""
    for(
    $i=0$i<5$i++){ 
        
    $y rand(0,strlen($string)-1); 
        
    $code .= $string[$y]; 


    // if checked show New
    if($_POST['new']==="on"){ 
    echo 
    "New <br><br>"

    $date=date("d/m/y h:i:s"); //create date time

    $sql2="INSERT INTO category (name1, name2, name3)VALUES('$name1', '$name2', '$name3')";

    $sql="INSERT INTO products (key, product, detail, new, date)VALUES('$key', '$product', '$detail', '$new', '$date')";
    $result=mysql_query($sqlsql2);
    }
    if(
    $result){
    echo 
    "Successful<BR>";
    echo 
    "<a href=index.php>View your Products</a>";
    }
    else {
    echo 
    "ERROR";
    }
    mysql_close();

    ?>

    <html>

    <head>
    <meta http-equiv="Content-Language" content="en-us">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title><?php echo $title?></title>
    </head>

    <body bgcolor="#C0C0C0">

    <div align="center">
        <table border="1" width="90%" style="border-left-style: solid; border-left-width: 2px; border-right: 2px solid #FFFFFF; border-top-style: solid; border-top-width: 2px; border-bottom: 2px solid #FFFFFF" cellpadding="0">
            <tr>
                <td bordercolor="#808080">&nbsp;<p>&nbsp;</p>
                <p>&nbsp;</td>
            </tr>
        </table>
        <table border="1" width="90%" cellpadding="0" style="border-left-style: solid; border-left-width: 2px; border-right: 2px solid #FFFFFF; border-top-style: solid; border-top-width: 2px; border-bottom: 2px solid #FFFFFF">
            <tr>
                <td bordercolor="#808080">&nbsp;</td>
            </tr>
        </table>
        <table border="0" width="90%" style="border-left-style: solid; border-left-width: 2px; border-right: 2px solid #FFFFFF; border-top-style: solid; border-top-width: 2px; border-bottom: 2px solid #FFFFFF" cellpadding="0">
            <tr>
              </div>

    <div align="center">
        <table border="1" width="90%" cellpadding="0" style="border: 2px solid #FFFFFF">
            <tr>
                <td bordercolor="#808080">
                <p align="center">&nbsp;</p>
                <p align="center"><?php echo $added?></p>
                <p align="center">&nbsp;</td>
            </tr>
        </table>
    </div>

    </body>

    </html>

  • #3
    New Coder
    Join Date
    Oct 2006
    Posts
    42
    Thanks
    0
    Thanked 0 Times in 0 Posts
    index.php
    PHP Code:
    <?php

    include("config.php");

    // Connect to server and select database.
    mysql_connect("$dbhost""$dbuser""$dbpassword")or die("cannot connect server "); 
    mysql_select_db("$dbname")or die("cannot select DB");

    $sql "SELECT * FROM programi ORDER BY id DESC";

    $sql2 "SELECT * FROM category ORDER BY id DESC";

    $result mysql_query($sqlsql2);

    ?>

    <html>

    <head>
    <meta http-equiv="Content-Language" content="en-us">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title><?php echo $title?></title>
    </head>

    <body bgcolor="#C0C0C0">

    <div align="center">
        <table border="1" width="90%" style="border-left-style: solid; border-left-width: 2px; border-right: 2px solid #FFFFFF; border-top-style: solid; border-top-width: 2px; border-bottom: 2px solid #FFFFFF" cellpadding="0">
            <tr>
                <td bordercolor="#808080">&nbsp;<p>&nbsp;</p>
                <p>&nbsp;</td>
            </tr>
        </table>
        <table border="1" width="90%" cellpadding="0" style="border-left-style: solid; border-left-width: 2px; border-right: 2px solid #FFFFFF; border-top-style: solid; border-top-width: 2px; border-bottom: 2px solid #FFFFFF">
            <tr>
                <td bordercolor="#808080">&nbsp;</td>
            </tr>
        </table>

    <?php
    // Start looping table row 
    while($rows=mysql_fetch_array($result)){
    ?>

        <table border="0" width="90%" style="border-left-style: solid; border-left-width: 2px; border-right: 2px solid #FFFFFF; border-top-style: solid; border-top-width: 2px; border-bottom: 2px solid #FFFFFF" cellpadding="0">
            <tr>
                <td style="border-style: solid; border-width: 1px" bordercolor="#808080" bgcolor="#FF6600">
                <p align="center"><?php echo $key1?></td>
                <td bordercolor="#808080" style="border-style: solid; border-width: 1px" bgcolor="#FF6600">
                <p align="center"><?php echo $product1?></php></td>
                <td style="border-style: solid; border-width: 1px" bordercolor="#808080" bgcolor="#FF6600">
                <p align="center"><?php echo $detail1?></td>
                <td style="border-style: solid; border-width: 1px" bordercolor="#808080" bgcolor="#FF6600">
                <p align="center"><?php echo $select1?></td>
            </tr>
            <tr>
                <td style="border-style: solid; border-width: 1px" bordercolor="#808080">
                <p align="center">
                <? echo $rows['key']; ?></td>
                <td bordercolor="#808080" style="border-style: solid; border-width: 1px">
                <p align="center"><? echo $rows['product']; ?></td>
                <td style="border-style: solid; border-width: 1px" bordercolor="#808080">
                <p align="center">
    <?php echo $rows['detail']; ?><?php echo $rows['new']; ?></td>
                <td style="border-style: solid; border-width: 1px" bordercolor="#808080">
                <p align="center">
                <? echo $rows['select']; ?></td>
                      <td style="border-style: solid; border-width: 1px" bordercolor="#808080">
                <p align="center">
                <? echo $rows['category']; ?></td>
                      <td style="border-style: solid; border-width: 1px" bordercolor="#808080">
                <p align="center">
                <? echo $rows['date']; ?></td>
            </tr>
            </table>
    </div>

    <div align="center">
        <table border="1" width="90%" cellpadding="0" style="border: 2px solid #FFFFFF">
            <tr>
                <td bordercolor="#808080">
                <p align="center">&nbsp;</p>
                <p align="center"></p>
                <p align="center">&nbsp;</td>
            </tr>
        </table>
    </div>

    </body>

    </html>
    <?php ?>

  • #4
    Regular Coder
    Join Date
    May 2005
    Posts
    235
    Thanks
    0
    Thanked 0 Times in 0 Posts
    On your index page you have
    PHP Code:
    $sql "SELECT * FROM programi ORDER BY id DESC"
    think that should be

    PHP Code:
    $sql "SELECT * FROM products ORDER BY id DESC"
    Also your echoing out your mysql results wrong

    PHP Code:
    echo $key 
    should be

    PHP Code:
    echo $result['key']; 
    Whats the actual problem ?

    Crowds
    Last edited by Crowds; 10-26-2006 at 03:39 PM.
    PHP magpie | And President Of The Marmalade Atkins Fan Club | Crowds Design

  • #5
    New Coder
    Join Date
    Oct 2006
    Posts
    42
    Thanks
    0
    Thanked 0 Times in 0 Posts
    web site is:
    Code:
    http://www.prerodbalab.org/test/
    you can test here.

  • #6
    New Coder
    Join Date
    Oct 2006
    Posts
    42
    Thanks
    0
    Thanked 0 Times in 0 Posts
    this is variable echo $key
    i have for result
    Code:
    <? echo $rows['key']; ?>

  • #7
    Regular Coder
    Join Date
    May 2005
    Posts
    235
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Change your query on index from

    PHP Code:
    $result mysql_query($sqlsql2); 
    to

    PHP Code:
    $result mysql_query($sqlsql2) or die(mysql_error()); 
    and we will see what is going wrong clearer
    PHP magpie | And President Of The Marmalade Atkins Fan Club | Crowds Design

  • #8
    Regular Coder
    Join Date
    May 2005
    Posts
    235
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by balkan View Post
    this is variable echo $key
    i have for result
    Code:
    <? echo $rows['key']; ?>
    Not according to the index page you posted up here....

    PHP Code:
    <?php echo $key1?>
    Sorry, I see that further down you do have that in place. My mistake.
    Put the

    PHP Code:
    or die(mysql_error()); 
    In place and see if that helps give you a clue to what is going wrong
    Last edited by Crowds; 10-26-2006 at 03:48 PM.
    PHP magpie | And President Of The Marmalade Atkins Fan Club | Crowds Design

  • #9
    New Coder
    Join Date
    Oct 2006
    Posts
    42
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/prerodba/public_html/test/index.php on line 13

  • #10
    New Coder
    Join Date
    Oct 2006
    Posts
    42
    Thanks
    0
    Thanked 0 Times in 0 Posts
    yes i know for variable, but i have error in index and i dont know what show me ...

  • #11
    New Coder
    Join Date
    Oct 2006
    Posts
    42
    Thanks
    0
    Thanked 0 Times in 0 Posts
    // Start looping table row
    while($rows=mysql_fetch_array($result)){

  • #12
    Regular Coder
    Join Date
    May 2005
    Posts
    235
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It doesn't like

    PHP Code:
    $sql2 "SELECT * FROM category ORDER BY id DESC"
    PHP magpie | And President Of The Marmalade Atkins Fan Club | Crowds Design

  • #13
    Regular Coder
    Join Date
    May 2005
    Posts
    235
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Try this

    Change

    PHP Code:
    $sql "SELECT * FROM programi ORDER BY id DESC";

    $sql2 "SELECT * FROM category ORDER BY id DESC";

    $result mysql_query($sqlsql2); 
    to

    PHP Code:
    $sql "SELECT products.*,category.* FROM products,category ORDER BY id DESC";


    $result mysql_query($sql); 
    PHP magpie | And President Of The Marmalade Atkins Fan Club | Crowds Design

  • #14
    New Coder
    Join Date
    Oct 2006
    Posts
    42
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Column 'id' in order clause is ambiguous

  • #15
    New Coder
    Join Date
    Oct 2006
    Posts
    42
    Thanks
    0
    Thanked 0 Times in 0 Posts
    try to add product in
    Code:
    http://www.prerodbalab.org/test/add.php
    show me ERROR to added.php


  •  
    Page 1 of 3 123 LastLast

    Posting Permissions

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