You are here: Re: $POST is the differnce char or a reserved name « PHP SQL « IT news, forums, messages
Re: $POST is the differnce char or a reserved name

Posted by Norman Peelman on 12/06/06 13:03

"fedor" <fedo2@dds.nl> wrote in message
news:GKmdnbraf4RvIenYRVnygg@fiberworld.nl...
> I have two peaces of code which are allmost the same.
> The first -see the comment OK- executes
> the second -NOK- (as I see it) generates an error.
>
> Why executes the first and the second not. Is it because the second is a
> char and the first an integer.
> Or is it because one of the names is a reserved word or is b1
> hexadecimal.
>
> I am looking at this code and do not know how to continue the coding.
> Can you and give me an advice?
> thanks in advance.
>
> ERROR
> Could Not Execute SQL statementUnknown column 'b1' in 'where clause'
> Warning: mysql_fetch_array(): supplied argument is not a valid MySQL
> result resource in
>
/nfs/vsp/dds.nl/t/thmulder/public_html/topbimini.nl/upd/vinalux_modify2.php
> on line 21
>
>
> CODE
> <?php
> include "db.php";
> $link = mysql_connect("$hostname", "$username", "$password");
> if(!$link)
> print "Could Not Connect to DB Server";
> $db = mysql_select_db("$databasename", $link);
> if(!$db)
> print "Could Not Open DB";
>
> $query = "select * from vinalux join (size, price)
> where vinalux.size_key = size.size_key
> and vinalux.size_key = price.size_key
> and vinalux.fabric = price.fabric
> and vinalux.vinalux_id =
> $_POST[vinalux_id]
> order by vinalux.vinalux_id, vinalux.size_key,
> vinalux.color";
>
> $result= mysql_query($query);
> if(!$result)
> print "Could Not Execute SQL statement".mysql_error();
>
> while($row = mysql_fetch_array($result))
> {
> $query = "update vinalux
>
> set qty = qty - 0
>
> where vinalux_id = $_POST[vinalux_id]";
> /* OK */
> $result= mysql_query($query);
> if(!$result)
> print "Could Not Execute SQL statement".mysql_error();
> $query = "update size
>
> set size_qty = size_qty - 0
>
> where size_key = $_POST[size_key]";

insert an echo "<!-- $query --> /n/r"; here and then check your source code
to see what your query looks like. There is no problem with the code, you
probably need to make sure that $_POST[size_key] exists. or if it is a
string and not a number try '$_POST[size_key]' (single quotes around whole
$_POST variable.



> /* NOK */
> $result= mysql_query($query);
> if(!$result)
> print "Could Not Execute SQL statement".mysql_error();
> }
>
>
>
>
> $r = mysql_affected_rows();
> if($r == 1)
> header("location:vinalux_modify_confirm.php");
>
> ?>


Norm
--
FREE Avatar hosting at www.easyavatar.com

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация