Re: Re: mysql query

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 8/22/2013 4:14 PM, Ethan Rosenberg wrote:
On 08/22/2013 11:54 AM, Jim Giner wrote:
On 8/22/2013 9:52 AM, Jim Giner wrote:
On 8/21/2013 7:48 PM, 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



Ethan - you are simply missing two dollar signs as pointed out. Once
you correct them, if there are any more errors you should then be seeing
the message from mysqli_error.

And as for the advice to dump single quotes, I'd ignore it.  The use of
double and single quotes is a very handy feature and makes for very
readable code.  Escaping double quotes is such a royal pia and makes for
more trouble deciphering code later on.  The sample you provided for us
is some of the best and most understandable code you've ever showed us.

Also - Ethan - if you used an editor that was designed for php you
probably would have seen these missing $ signs since a good one would
highlight php syntax and the lack of the $ would have produced a
different color than you expected.

Jim -

I  used Netbeans.  All it said is "variable unused is scope", which is
a  error that I often find does not mean anything.  I am as pressurized
as you are.  Any suggestions as to an editor?

Ethan


Did you mean to say "unused IN scope"? That would be telling you that it is not yet defined and that could be a problem if you expect to be already defined.

Several other posts here have listed their favorites. Notepad ++ seems to be a favorite. I use HTML-kit Tools as my developing environment. Handles highlighting for php, html and js, as well as project organization. Also includes an ftp engine to allow me to modify, upload and then go test my code very quickly. (I don't run php or apache locally.)

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux