FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » cause of error is what?
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: cause of error is what? [message #181574 is a reply to message #181573] Wed, 22 May 2013 10:25 Go to previous messageGo to previous message
Thomas 'PointedEars'  is currently offline  Thomas 'PointedEars'
Messages: 701
Registered: October 2010
Karma:
Senior Member
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(at)news(dot)demon(dot)co(dot)uk>
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Google Voice App Comes To iPhone
Next Topic: use a value form a manu list in a form on the same page
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Thu Nov 28 08:17:34 GMT 2024

Total time taken to generate the page: 3.79223 seconds