SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Member
    Join Date
    Jan 2005
    Location
    Montreal
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    MySQL returned an empty result set

    I have a really big problem and can't get the solution in the forums I visited.

    CREATE TABLE price(
    `id` INT( 3 ) NOT NULL DEFAULT '0',
    `fig_id` INT( 3 ) NOT NULL DEFAULT '0',
    `dim_id` INT( 3 ) NOT NULL DEFAULT '0',
    `dim` VARCHAR( 20 ) NOT NULL DEFAULT '0',
    `fig` INT( 3 ) NOT NULL DEFAULT '0',
    `price` DECIMAL( 10, 2 ) DEFAULT '0.00',
    KEY `price_idx` ( `fig` , `dim` ) ,
    PRIMARY KEY ( `id` )
    ) ENGINE = MYISAM ;# MySQL returned an empty result set (i.e. zero rows).
    'dim' (size) and 'fig' (qty) are independant variables in 2 dropdown lists whose the values determine the value of the dependent variable 'price'.

    The problem is that I can't test the program because the aabove error.

    Some help, please.

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,350
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    where did you get this error message? because there's nothing wrong with that CREATE TABLE statement

    (other than the funny dimensions on the INT columns and the incorrect quotes on numeric constants)
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Addict CWebguy's Avatar
    Join Date
    Mar 2009
    Posts
    247
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Have you tried creating it using PHPMyadmin?

  4. #4
    SitePoint Member
    Join Date
    Jan 2005
    Location
    Montreal
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,
    Tha's the problem
    I use MySql 3.23.58 and PhpMyAdmin 2.6.0-pl3.
    Are there other ways todo that. Or is it best to ignore this warning?

  5. #5
    SitePoint Member
    Join Date
    Jan 2005
    Location
    Montreal
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is it best to ignre this warning.
    Anyway, Im going to change the 'funny value and bad quotes.
    Tanks for your fast answer.

    E. P.

  6. #6
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,350
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    where are you running the CREATE TABLE statement, in phpmyadmin?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  7. #7
    SitePoint Member
    Join Date
    Jan 2005
    Location
    Montreal
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    SQL-->Choose File
    Compression: Auto
    Character set: utf8

  8. #8
    SitePoint Member
    Join Date
    Jan 2005
    Location
    Montreal
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Besides the "empty rows" issue, I have another problem:
    'dim' and 'fig' are 2 dropdown lists which value determine a given price.
    Ajax/MySql/PhP/ are used for this purpose. (see details in attachment).

    By clicking on "Submit" we have a "not available" result instead of the hoped price.

    I don't see really what is really wrong.

    Firstly, I think that the "empty_row" was responsible of this situation.

    Some help, please.

    E. P.
    Attached Files Attached Files

  9. #9
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,350
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    to save people from opening your word document, here it is in plain text --
    2 dropdown
    ….
    <script src="prototype.js" type="text/javascript"></script>
    <script src="myAjax.js" type="text/javascript"></script>
    </head>

    <body>
    <form>
    <select id="fig" onchange="calc_price();return false;">
    <option value = "" selected="selected">Nombre de figures sur la peinture</option>
    <option value = "1">1</option>
    <option value = "2">2</option>
    <option value = "3">3</option>

    <option value = "10">10</option>
    </select>

    <select id="dim" onchange="calc_price();return false;">
    <option value = "" selected="selected">Dimensions choisies</option>
    <option value = "field1">12inx16in/30cmx40cm</option>
    <option value = "field2">16inx20in/40cmx50cm</option>
    <option value = "field3">20inx24in/50cmx60cm</option>
    <option value = "field4">24inx36in/60 cmx90cm</option>
    <option value = "field5">30inx40 in/75cmx100 cm</option>
    </select>
    </form>

    <div id="price"></div>

    <form>
    <input type="submit" value="Submit" onClick="new Ajax.Updater('price','newdbfunction.php',{method: 'post'})";></input>
    </form>
    </body>
    </html>

    Newdbfunction.php
    <?php
    <script>
    //Connect to mysql server
    $link = mysql_connect("localhost","xxxx","yyyyy"); // ("hostname","username","password");
    if(!$link)
    die('Failed to connect to server: ' . mysql_error());

    //Select database
    $db = @mysql_select_db("dddddd"); // dbname
    if(!$db)
    die("Unable to select database");

    $fieldname = $_POST['dim'];
    $num = $_POST['fig'];

    $qresult = mysql_query("SELECT {$fieldname} FROM price WHERE fig='{$num}'");

    $ret = mysql_query ($query) or die(mysql_error());

    if(mysql_num_rows($result) > 0){
    $data = mysql_fetch_array($result);
    if($data[$fieldname] == "-"){
    echo "Non-available";
    }else{
    echo "$" . $data[$fieldname];
    }

    }else{
    echo "Non available";
    }
    </script>
    ?>

    Javascript file (e.g. myajax.js)
    function calc_price(){
    if($F('dim') != "" || $F('fig')){
    $('price').innerHTML = 'prix not available'; // Not available
    } else{
    var fig = $F('fig');
    var dim = $F('dim');
    var pars = "fig=" + fig + "&dim=" + dim;
    var oAjax = new Ajax.Updater('price','newdbfunction.php',{method: 'post',parameters: pars}); } }

    Price table name - Price.sql
    Prices vs fig and size are non linear variable value

    DROP TABLE IF EXISTS `price`;
    CREATE TABLE IF NOT EXISTS `price` (
    `id` int(3) NOT NULL default '0',
    `fig_id` int(3) NOT NULL default '0',
    `dim_id` int(3) NOT NULL default '0',
    `dim` varchar(20) NOT NULL default '0',
    `fig` int(3) NOT NULL default '0',
    `price` decimal(10,2) default '0.00',
    PRIMARY KEY (`id`),
    KEY `price_idx`(`fig`,`dim`)
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1;

    --
    -- Dumping data for table `price`
    --

    INSERT INTO `price` (`id`, `fig_id`, `dim_id`, `dim`, `fig`, `price`) VALUES (0, 0, 0, '12x16in/30x40cm', 1, 400.00),
    (1, 1, 1, '12x16in/30x40cm', 2, 560.00),
    (2, 2, 2, '12x16in/30x40cm', 3, 640.00),
    (3, 3, 3, '16x20in/40x50cm', 1, 475.00),
    (4, 4, 4, '16x20in/40x50cm', 2, 665.00),
    (5, 5, 5, '16x20in/40x50cm', 3, 800.00),
    (6, 6, 6, '16x20in/40x50cm', 4, 925.00),
    (7, 7, 7, '16x20in/40x50cm', 5, 975.00),
    (8, 8, 8, '20x24in/50x60cm', 1, 575.00),
    (9, 9, 9, '20x24in/50x60cm', 2, 800.00),
    (10, 10, 10, '20x24in/50x60cm', 3, 925.00),
    (11, 11, 11, '20x24in/50x60cm', 4, 1050.00),
    (12, 12, 12, '20x24in/50x60cm', 5, 1125.00),
    (13, 13, 13, '20x24in/50x60cm', 6, 1175.00),
    (14, 14, 14, '20x24in/50x60cm', 7, 1250.00),
    (15, 15, 15, '24x36in/50x60cm', 1, 700.00),
    (16, 16, 16, '24x36in/50x60cm', 2, 900.00),
    (17, 17, 17, '24x36in/50x60cm', 3, 1100.00),
    (18, 18, 18, '24x36in/50x60cm', 4, 1275.00),
    (19, 19, 19, '24x36in/50x60cm', 5, 1350.00),
    (20, 20, 20, '24x36in/50x60cm', 6, 1425.00),
    (21, 21, 21, '24x36in/50x60cm', 7, 575.00),
    (22, 22, 22, '24x36in/50x60cm', 8, 1650.00),
    (23, 23, 23, '24x36in/50x60cm', 9, 1750.00),
    (24, 24, 24, '30x40in/75x100cm', 1, 775.00),
    (25, 25, 25, '30x40in/75x100cm', 2, 1100.00),
    (26, 26, 26, '30x40in/75x100cm', 3, 1300.00),
    (27, 27, 27, '30x40in/75x100cm', 4, 1475.00),
    (28, 28, 28, '30x40in/75x100cm', 5, 1550.00),
    (29, 29, 29, '30x40in/75x100cm', 6, 1675.00),
    (30, 30, 30, '30x40in/75x100cm', 7, 1800.00),
    (31, 31, 31, '30x40in/75x100cm', 8, 1925.00),
    (32, 32, 32, '30x40in/75x100cm', 9, 2050.00),
    (33, 33, 33, '30x40in/75x100cm', 10, 2200.00);
    i've moved the thread to the php forum for further assistance
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  10. #10
    SitePoint Member
    Join Date
    Jan 2005
    Location
    Montreal
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Tanks a lot.
    Sorry for posting at the unappropriate forum.

    E. P.


Bookmarks

Posting Permissions

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