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


Groups > comp.lang.php > #9515 > unrolled thread

cause of error is what?

Started byrichard <noreply@example.com>
First post2013-05-21 21:44 -0400
Last post2013-05-23 15:33 -0700
Articles 14 — 6 participants

Back to article view | Back to comp.lang.php


Contents

  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

#9515 — cause of error is what?

Fromrichard <noreply@example.com>
Date2013-05-21 21:44 -0400
Subjectcause of error is what?
Message-ID<j3e3kkp57qb7$.ejqn5joyml1q$.dlg@40tude.net>
Can't get past the error message.
Could not run query: You have an error in your SQL syntax; check the manual
that corresponds to your MySQL server version for the right syntax to use
near '' at line 1
www.mroldies.net/menu2.php


<?php

$year=$_GET["year"];
if (empty($year)) {$year=1900;}
$year=(int)$year;

/* connect to the db */
$con = mysql_connect('localhost','user','pass');


if (!$con){die("can not connect: " . mysql_error());}

mysql_select_db('richbull_top100',$con);

echo "<div style='clear:left;'>";

if ($year==1900){echo '<iframe  width="1000" height="500" src="test2.php"
frameborder="0"></iframe>';}
    else {echo $year."\n";

$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>";

?>

[toc] | [next] | [standalone]


#9516

Fromrichard <noreply@example.com>
Date2013-05-21 21:54 -0400
Message-ID<ddtw7n2lagnn$.16jem7sw3oujw.dlg@40tude.net>
In reply to#9515
Forgot to give the $number a value.

[toc] | [prev] | [next] | [standalone]


#9517

FromDavid Robley <me@home.invalid>
Date2013-05-22 12:05 +0930
Message-ID<knhat8$h7v$1@news.albasani.net>
In reply to#9516
richard wrote:

> Forgot to give the $number a value.

Guess you didn't read my reply to your other question then
-- 
Cheers
David Robley

Iraq's national bird?, "DUCK"

[toc] | [prev] | [next] | [standalone]


#9521

FromScott Johnson <noonehome@chalupasworld.com>
Date2013-05-21 21:35 -0700
Message-ID<knhhna$61c$1@dont-email.me>
In reply to#9515
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*

I could be wrong but..

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

[toc] | [prev] | [next] | [standalone]


#9522

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2013-05-22 12:25 +0200
Message-ID<3757310.uHaZ80sULO@PointedEars.de>
In reply to#9521
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>

[toc] | [prev] | [next] | [standalone]


#9524

FromScott Johnson <noonehome@chalupasworld.com>
Date2013-05-22 05:34 -0700
Message-ID<knidp9$770$1@dont-email.me>
In reply to#9522
On 5/22/2013 3:25 AM, Thomas 'PointedEars' Lahn wrote:
> 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
>

First off I have never been rude to you or anyone in this group so no 
idea why you feel you need to 'RTFM' to me, but if you have to then you 
have to.

My original thought/idea was that if 'id' was an (int) in the Db then 
sending an empty value should not of caused a query error.  But on 
elaborating on the thought, there is much more to it when not having 
$number set aside from the basic query.  Stuff as simple as column set 
to not accept NULL values, etc..

It was just a quick un-thought out thought (yes the existence of 
un-thought can be argued), nothing more, nothing less.

Thanks however for expanding on the thought so as not to confuse anyone 
reading it.

Scotty

[toc] | [prev] | [next] | [standalone]


#9526

FromScott Johnson <noonehome@chalupasworld.com>
Date2013-05-22 05:48 -0700
Message-ID<kniekg$atf$1@dont-email.me>
In reply to#9524
On 5/22/2013 5:34 AM, Scott Johnson wrote:
> On 5/22/2013 3:25 AM, Thomas 'PointedEars' Lahn wrote:
>> 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
>>
>
> First off I have never been rude to you or anyone in this group so no
> idea why you feel you need to 'RTFM' to me, but if you have to then you
> have to.
>
> My original thought/idea was that if 'id' was an (int) in the Db then
> sending an empty value should not of caused a query error.  But on

Edit: 'sending a NULL value' (man I gotta have my coffee before posting)

> elaborating on the thought, there is much more to it when not having
> $number set aside from the basic query.  Stuff as simple as column set
> to not accept NULL values, etc..
>
> It was just a quick un-thought out thought (yes the existence of
> un-thought can be argued), nothing more, nothing less.
>
> Thanks however for expanding on the thought so as not to confuse anyone
> reading it.
>
> Scotty

[toc] | [prev] | [next] | [standalone]


#9533

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2013-05-22 23:05 +0200
Message-ID<456437807.dArH623vQ9@PointedEars.de>
In reply to#9524
Scott Johnson wrote:

> On 5/22/2013 3:25 AM, Thomas 'PointedEars' Lahn wrote:
>> 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

So, what does “JTOL” mean?

>>> I could be wrong but..
>>
>> You are.  RTFMs.
>>
>> […]
>> <http://php.net/mysql_query>
>> […]
>> <http://dev.mysql.com/doc/refman/5.6/en/type-conversion.html> p.
> 
> First off I have never been rude to you or anyone in this group so no
> idea why you feel you need to 'RTFM' to me, but if you have to then you
> have to.

<http://www.catb.org/~esr/faqs/smart-questions.html#not_losing>

And please quote only the relevant parts.  Time and space are precious 
goods.

> My original thought/idea was that if 'id' was an (int) in the Db then
> sending an empty value should not of caused a query error.  But on
> elaborating on the thought, there is much more to it when not having
> $number set aside from the basic query.  Stuff as simple as column set
> to not accept NULL values, etc..

I do not follow.  MySQL will never see a NULL value in this case.  It will 
see *no* value at all, causing a MySQL syntax error.

> It was just a quick un-thought out thought (yes the existence of
> un-thought can be argued), nothing more, nothing less.

Well, I for one try to test my assumptions before I post them, thereby not 
wasting other people's time with such thoughts.  Many things are 
conceivable; few are well-founded.

> Thanks however for expanding on the thought so as not to confuse anyone
> reading it.

You're welcome, I think.


PointedEars
-- 
Sometimes, what you learn is wrong. If those wrong ideas are close to the 
root of the knowledge tree you build on a particular subject, pruning the 
bad branches can sometimes cause the whole tree to collapse.
  -- Mike Duffy in cljs, <news:Xns9FB6521286DB8invalidcom@94.75.214.39>

[toc] | [prev] | [next] | [standalone]


#9530

Fromrichard <noreply@example.com>
Date2013-05-22 13:03 -0400
Message-ID<13wfvc1imkdmw.1aa1q0cg3iz4a$.dlg@40tude.net>
In reply to#9521
On Tue, 21 May 2013 21:35:31 -0700, 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*
> 
> I could be wrong but..
> 
> Even if you left $number unset, that query should not of returned false 
> unless 'id' is not an (int) in your table definition.

FYI, 'id' IS defined as an integer and is the primary key.

[toc] | [prev] | [next] | [standalone]


#9534

FromScott Johnson <noonehome@chalupasworld.com>
Date2013-05-22 16:42 -0700
Message-ID<knjkul$9h3$1@dont-email.me>
In reply to#9530
On 5/22/2013 10:03 AM, richard wrote:
> On Tue, 21 May 2013 21:35:31 -0700, 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*
>>
>> I could be wrong but..
>>
>> Even if you left $number unset, that query should not of returned false
>> unless 'id' is not an (int) in your table definition.
>
> FYI, 'id' IS defined as an integer and is the primary key.
>

I was just wondering because I have seen these issues in the past when I 
am first coding and testing and some data does not populate properly.

It was a fleeting thought and nothing other.

Hope the rest of your project is moving forward.

Scotty

[toc] | [prev] | [next] | [standalone]


#9535

From"Beauregard T. Shagnasty" <a.nony.mous@example.invalid>
Date2013-05-23 00:21 +0000
Message-ID<knjnek$e52$1@dont-email.me>
In reply to#9534
Scott Johnson wrote:

> Hope the rest of your project is moving forward.

He's been working on it seems for about a decade now. You've seen the 
results. It will never work sufficiently well enough to attract real 
visitors.

-- 
   -bts
   -This space for rent, but the price is high

[toc] | [prev] | [next] | [standalone]


#9537

FromScott Johnson <noonehome@chalupasworld.com>
Date2013-05-23 05:42 -0700
Message-ID<knl2k8$dd5$1@dont-email.me>
In reply to#9535
On 5/22/2013 5:21 PM, Beauregard T. Shagnasty wrote:
> Scott Johnson wrote:
>
>> Hope the rest of your project is moving forward.
>
> He's been working on it seems for about a decade now. You've seen the
> results. It will never work sufficiently well enough to attract real
> visitors.
>

It did seem like he was given many good ideas on how to make his code 
and application better but decided to ignore them.

I have rewritten so much code after looking thru so many of these NG 
threads.

I am hopeful that as he runs into some serious issues (like when some of 
the mysql extensions he is using are deprecated and removed), he will 
see why many where giving him certain advice.

Scotty

[toc] | [prev] | [next] | [standalone]


#9541

FromDenis McMahon <denismfmcmahon@gmail.com>
Date2013-05-23 16:02 +0000
Message-ID<knleih$ei9$2@dont-email.me>
In reply to#9537
On Thu, 23 May 2013 05:42:27 -0700, Scott Johnson wrote:

> I am hopeful that as he runs into some serious issues (like when some of
> the mysql extensions he is using are deprecated and removed), he will
> see why many where giving him certain advice.

Or even when his site gets hacked and all his data is trashed, and then 
it's used to serve kiddieporn, malware, and as part of a spamming botnet.

-- 
Denis McMahon, denismfmcmahon@gmail.com

[toc] | [prev] | [next] | [standalone]


#9554

FromScott Johnson <noonehome@chalupasworld.com>
Date2013-05-23 15:33 -0700
Message-ID<knm58p$nmk$1@dont-email.me>
In reply to#9541
On 5/23/2013 9:02 AM, Denis McMahon wrote:
> On Thu, 23 May 2013 05:42:27 -0700, Scott Johnson wrote:
>
>> I am hopeful that as he runs into some serious issues (like when some of
>> the mysql extensions he is using are deprecated and removed), he will
>> see why many where giving him certain advice.
>
> Or even when his site gets hacked and all his data is trashed, and then
> it's used to serve kiddieporn, malware, and as part of a spamming botnet.
>

Damn that Richard.....JK.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.php


csiph-web