Re: mysql query

Toby Hart Dyke <[email protected]>
Newsgroups gmane.comp.php.database
Message-ID <[email protected]>
1) What is the error message?

2) This has an error:

 >values ('$upc', $qnt,'$mnf','$itm', odrpt, 0, $stk)

Missing '$' in front of 'odrpt'.

   Toby


On 8/22/2013 12:48 AM, Ethan Rosenberg wrote:
> Dear List -
>
> I can't figure this out....
>
> mysql> describe Inventory;
> +-------------+-------------+------+-----+---------+-------+
> | Field       | Type        | Null | Key | Default | Extra |
> +-------------+-------------+------+-----+---------+-------+
> | UPC         | varchar(14) | YES  |     | NULL |       |
> | quant       | int(5)      | NO   |     | NULL |       |
> | manuf       | varchar(20) | YES  |     | NULL |       |
> | item        | varchar(50) | YES  |     | NULL |       |
> | orderpt     | tinyint(4)  | NO   |     | NULL |       |
> | ordrpt_flag | tinyint(3)  | YES  |     | NULL |       |
> | stock       | int(3)      | YES  |     | NULL |       |
> +-------------+-------------+------+-----+---------+-------+
>
> Here are code snippets -
>
>                           $upc   = $_SESSION['UPC'];
>                           $qnt   = $_POST['quant'];
>                           $mnf   = $_POST['manuf'];
>                           $itm   = $_POST['item'];
>                           $odrpt = $_POST['oderpt'];
>                           $opf   = $_POST['ordrpt_flag'];
>                           $stk    = $_POST['stock'];
>
>                           $sql2 = "insert into Inventory (UPC, quant, 
> manuf, item, orderpt, ordrpt_flag, stock)"
>                                 ."values ('$upc', $qnt,'$mnf','$itm', 
> odrpt, 0, $stk)";
>                           $result2 = mysqli_query(cxn, $sql2);
>                           echo '$sql2<br />';
>                           print_r($sql2);
>                           echo "<br />$upc $qnt $mnf $itm $odrpt $opf 
> $stk<kbr />";
>                           if (!$result2)
>                                 die('Could not enter data: ' . 
> mysqli_error());
>
> The mysql query fails.  I cannot figure out why.  It works from the 
> command line.
>
> TIA
>
> Ethan
>
>
>
>


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.