Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #9522

Re: cause of error is what?

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.datemas.de!uucp.gnuu.de!newsfeed.arcor.de!newsspool3.arcor-online.net!news.arcor.de.POSTED!not-for-mail
Content-Type text/plain; charset="UTF-8"
Message-ID <3757310.uHaZ80sULO@PointedEars.de> (permalink)
From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Reply-To Thomas 'PointedEars' Lahn <php@PointedEars.de>
Organization PointedEars Software (PES)
Date Wed, 22 May 2013 12:25:10 +0200
User-Agent KNode/4.10.2
Content-Transfer-Encoding 8Bit
X-Face %i>XG-yXR'\"2P/C_aO%~;2o~?g0pPKmbOw^=NT`tprDEf++D.m7"}HW6.#=U:?2GGctkL,f89@H46O$ASoW&?s}.k+&.<b';Md8`dH6iqhT)6C^.Px|[=M@7=Ik[_w<%n1Up"LPQNu2m8|L!/3iby{-]A+#YE}Kl{Cw$\U!kD%K}\2jz"QQP6Uqr],./"?;=4v
Face iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEXTxa4RFk5dUWANED8PFEfy7+MGBiW+n3ZNF/QuAAACaElEQVQ4jVXUwVOcMBQG8Dc7Rc4PUntdWV2uxjDpGaGeozOp1woar4jd5t/v9wLstMwsA/ntlxdCAgUc1hjTc9/JCZfGoo3wG3HdmdAWrIJRHe7GM/TmpY5VFefuVcAkkPbLIaN8rmPmjloyZxgyR3GuJ4K0AGtJ2htz8o7yqikm759fldQXaMpbDzjKAG+8v+AugVTOPO5DOjLvGtUYQwh0CPjnVMyGd+8/GfUB5nLKJDD2aLDh5HYyMDJGDwQIo2ZmZcKbowNmAdB/AzyFhrmF2MHRb0QJJfaAnwGB6orZhoykLzJtGwF/xpYxI1dswomiUj3gTuAIqCn/4C7cULwGNBtwMTk3Y4LfKB5YUaOKBKYtpplm7u0vip8tU1NWWyI/7XdcSuIDoMt6rVHMWT0DbjHPGqDqZVSa6zleLcUTcIKLoMv3ueJluALtAo9B302zPPlrtiVScRdCjXvVh3e3JpYa/jjkuC9N+LrBMlz/eAN4eQijX2EdLo6c5tGGHwLyHFtXk89dDGHwCVhG9T0S/j55AhRZgkMCmUQXJ49TnS1wnQDvw0eAh9ICeMmEFbCnPMFzjAvsWoEWEFdYEx+S0MoUZ1gT1wId8+AF3Bl2OoEu906AUHx5VLw/gXYg/x84loOah/2UYNrgiwSwGO7RfUzVBbx/kgpckumGOi6QirtD6gkLTitbnxNol47S2jVc2vsN5kPqaAHT8uUdAJM4v/DanjYOwmUjWznGfwB7sGtAtor5BgofDuzaRj4kSQAqDakTsKORa3Q3xKi3gE1fhl71KRMqrdZ2AWNNg/YOhQyrVBnb+i+nEg4bsDA+egAAAABJRU5ErkJggg==
Subject Re: cause of error is what?
Newsgroups comp.lang.php
References <j3e3kkp57qb7$.ejqn5joyml1q$.dlg@40tude.net> <knhhna$61c$1@dont-email.me>
MIME-Version 1.0
Lines 64
NNTP-Posting-Date 22 May 2013 12:25:50 CEST
NNTP-Posting-Host 38202d6f.newsspool4.arcor-online.net
X-Trace DXC=`000W@3n:WYU6b:FjPaGjQ4IUK<Cl32<Q4Fo<]lROoRQ8kF<OcfhCO[H?bDQ\Zh=?YDZm8W4\YJN\b@mF9jNikdUBoKGPB=12AWe2]MAD6oKTP
X-Complaints-To usenet-abuse@arcor.de
Xref csiph.com comp.lang.php:9522

Show key headers only | View raw


Scott Johnson wrote:

> On 5/21/2013 6:44 PM, richard wrote:
>> $result = mysql_query("SELECT atitle,artist,avid FROM A$year WHERE id =
>> $number");
>> if (!$result) { echo 'Could not run query: ' . mysql_error();  exit; }
>> $vid = mysql_fetch_row($result);
>>
>> echo $vid[0];
>>
>> }
>>
>> echo "</div>";
>>
>> ?>
>>
> 
> *JTOL*

-v
 
> I could be wrong but..

You are.  RTFMs.
 
> Even if you left $number unset, that query should not of returned false
> unless 'id' is not an (int) in your table definition.

$ php -r 'echo "foo" . @$number . "bar\n";'
foobar

If they left $number unset, it would be evaluated to NULL, expanded to the 
zero-length string, and the query would be syntactical in error starting 
from the last “=”.

mysql_query(), which is *deprecated*, returns FALSE if that happens or the 
query cannot be executed for some other reason (which can be found out with 
mysql_errorno() and mysql_error()).  It *never* returns the result set such 
as a field value; that has to be obtained by passing the “resource” value 
returned by it as parameter to mysql_fetch_row() etc.

<http://php.net/mysql_query>

Also, MySQL implicitly converts numeric values to string values and vice-
versa.  Suppose the `id` column of a table `foo` would be of the common type 
“UNSIGNED INT(10, 0)”, both

  SELECT * FROM `foo` WHERE `id` = 42

and

  SELECT * FROM `foo` WHERE `id` = '42'

would *always* yield the same result set.

<http://dev.mysql.com/doc/refman/5.6/en/type-conversion.html> p.


PointedEars
-- 
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
  -- Richard Cornford, cljs, <f806at$ail$1$8300dec7@news.demon.co.uk>

Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

cause of error is what? richard <noreply@example.com> - 2013-05-21 21:44 -0400
  Re: cause of error is what? richard <noreply@example.com> - 2013-05-21 21:54 -0400
    Re: cause of error is what? David Robley <me@home.invalid> - 2013-05-22 12:05 +0930
  Re: cause of error is what? Scott Johnson <noonehome@chalupasworld.com> - 2013-05-21 21:35 -0700
    Re: cause of error is what? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-05-22 12:25 +0200
      Re: cause of error is what? Scott Johnson <noonehome@chalupasworld.com> - 2013-05-22 05:34 -0700
        Re: cause of error is what? Scott Johnson <noonehome@chalupasworld.com> - 2013-05-22 05:48 -0700
        Re: cause of error is what? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-05-22 23:05 +0200
    Re: cause of error is what? richard <noreply@example.com> - 2013-05-22 13:03 -0400
      Re: cause of error is what? Scott Johnson <noonehome@chalupasworld.com> - 2013-05-22 16:42 -0700
        Re: cause of error is what? "Beauregard T. Shagnasty" <a.nony.mous@example.invalid> - 2013-05-23 00:21 +0000
          Re: cause of error is what? Scott Johnson <noonehome@chalupasworld.com> - 2013-05-23 05:42 -0700
            Re: cause of error is what? Denis McMahon <denismfmcmahon@gmail.com> - 2013-05-23 16:02 +0000
              Re: cause of error is what? Scott Johnson <noonehome@chalupasworld.com> - 2013-05-23 15:33 -0700

csiph-web