Query stopping after 2 records?

Query stopping after 2 records?

am 27.04.2009 16:19:23 von tmiller

I need help/advice figuring out why my query dies after 2 records. Here is
the query:

// Build your INSERT statement here
=20

$query =3D "INSERT into `warrants` (wid, name, age, warrant, bond, wnumber=
,
crime) VALUES (";
$query .=3D " '$wid', '$name', '$age', '$warrant',
'$bond', '$wnumber', '$crime' )";
$wid =3D mysql_insert_id();

// run query
=20
mysql_query($query) or die ("GRRRRRRR");


echo $query;

It inserts two records and dies half way thru the 3rd?
Thanks in advance for clues to fix this.
T.Miller


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

Re: Query stopping after 2 records?

am 27.04.2009 16:21:57 von Phpster

--001636c5a736a43c7104688a116f
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

On Mon, Apr 27, 2009 at 10:19 AM, Miller, Terion <
tmiller@springfi.gannett.com> wrote:

> I need help/advice figuring out why my query dies after 2 records. Here is
> the query:
>
> // Build your INSERT statement here
>
>
> $query = "INSERT into `warrants` (wid, name, age, warrant, bond, wnumber,
> crime) VALUES (";
> $query .= " '$wid', '$name', '$age', '$warrant',
> '$bond', '$wnumber', '$crime' )";
> $wid = mysql_insert_id();
>
> // run query
>
> mysql_query($query) or die ("GRRRRRRR");
>
>
> echo $query;
>
> It inserts two records and dies half way thru the 3rd?
> Thanks in advance for clues to fix this.
> T.Miller
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
echo out each sql statement and then change the or die to

mysql_query($query) or die (mysql_error());
--

Bastien

Cat, the other other white meat

--001636c5a736a43c7104688a116f--

Re: Query stopping after 2 records?

am 27.04.2009 16:38:13 von HawX

On Mon, 27 Apr 2009 07:19:23 -0700, "Miller, Terion"
wrote:
> I need help/advice figuring out why my query dies after 2 records. Here
is
> the query:
>
> // Build your INSERT statement here
>
>
> $query = "INSERT into `warrants` (wid, name, age, warrant, bond,
wnumber,
> crime) VALUES (";
> $query .= " '$wid', '$name', '$age', '$warrant',
> '$bond', '$wnumber', '$crime' )";
> $wid = mysql_insert_id();
>
> // run query
>
> mysql_query($query) or die ("GRRRRRRR");
>
>
> echo $query;
>
> It inserts two records and dies half way thru the 3rd?
> Thanks in advance for clues to fix this.
> T.Miller

Make sure any apostrophes in the variable strings are escaped correctly.
Check the addslashes() function.

--
Hawx

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

Re: Query stopping after 2 records?

am 28.04.2009 00:32:13 von dmagick

Hawx wrote:
> On Mon, 27 Apr 2009 07:19:23 -0700, "Miller, Terion"
> wrote:
>> I need help/advice figuring out why my query dies after 2 records. Here
> is
>> the query:
>>
>> // Build your INSERT statement here
>>
>>
>> $query = "INSERT into `warrants` (wid, name, age, warrant, bond,
> wnumber,
>> crime) VALUES (";
>> $query .= " '$wid', '$name', '$age', '$warrant',
>> '$bond', '$wnumber', '$crime' )";
>> $wid = mysql_insert_id();
>>
>> // run query
>>
>> mysql_query($query) or die ("GRRRRRRR");
>>
>>
>> echo $query;
>>
>> It inserts two records and dies half way thru the 3rd?
>> Thanks in advance for clues to fix this.
>> T.Miller
>
> Make sure any apostrophes in the variable strings are escaped correctly.
> Check the addslashes() function.

No - use the mysql_real_escape_string function. Addslashes is the wrong
thing to use here.

--
Postgresql & php tutorials
http://www.designmagick.com/


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

Re: Query stopping after 2 records?

am 04.05.2009 21:43:29 von Martin Zvarik

Miller, Terion napsal(a):
> I need help/advice figuring out why my query dies after 2 records. Here is
> the query:
>
> // Build your INSERT statement here
>
>
> $query = "INSERT into `warrants` (wid, name, age, warrant, bond, wnumber,
> crime) VALUES (";
> $query .= " '$wid', '$name', '$age', '$warrant',
> '$bond', '$wnumber', '$crime' )";
> $wid = mysql_insert_id();
>
> // run query
>
> mysql_query($query) or die ("GRRRRRRR");
>
>
> echo $query;
>
> It inserts two records and dies half way thru the 3rd?
> Thanks in advance for clues to fix this.
> T.Miller
>


Should be:
------------------

$sql = ...

$query = mysql_query($sql) or die(...

while ($r = mysql_fetch_array($query)) { ....

------------------

Notice that you need to assign the mysql_query to a $query variable!


If you understand this, then there's most probably a mistake in your SQL
statement.


Martin

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

Re: Re: Query stopping after 2 records?

am 05.05.2009 00:01:42 von Andrew Hucks

When you say die, does it just stop, or do you get an error message?
Depending on how long it's taking to perform the action, the script
will stop just because it's taking a while. (by default, I think it's
30 seconds.)

If so, use: ini_set("max_execution_time", "time in seconds");

On Mon, May 4, 2009 at 3:43 PM, Martin Zvar=EDk wrote:
> Miller, Terion napsal(a):
>>
>> I need help/advice figuring out why my query dies after 2 records. =A0He=
re
>> is
>> the query:
>>
>> =A0 =A0 =A0 =A0 // Build your INSERT statement here
>>
>> =A0$query =3D "INSERT into `warrants` (wid, name, age, warrant, bond, wn=
umber,
>> crime) VALUES (";
>> =A0 =A0$query .=3D " '$wid', '$name', '$age', '$warrant',
>> '$bond', '$wnumber', '$crime' )";
>> =A0 =A0 =A0 =A0$wid =3D mysql_insert_id();
>>
>> // run query
>> =A0   mysql_query($query) or die ("GRRRRRRR");
>>
>>
>> =A0echo $query;
>>
>> It inserts two records and dies half way thru the 3rd?
>> Thanks in advance for clues to fix this.
>> T.Miller
>>
>
>
> Should be:
> ------------------
>
> $sql =3D ...
>
> $query =3D mysql_query($sql) or die(...
>
> while ($r =3D mysql_fetch_array($query)) { ....
>
> ------------------
>
> Notice that you need to assign the mysql_query to a $query variable!
>
>
> If you understand this, then there's most probably a mistake in your SQL
> statement.
>
>
> Martin
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

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

Re: Re: Query stopping after 2 records?

am 05.05.2009 00:27:21 von Martin Zvarik

--------------010500020101000101030300
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit

If the query stopped after getting 2 entries then this has nothing to do
with max_execution_time.

But stupid topic anyway, I don't know why are we even trying to figure
what Miller meant, he most probably solved it already...


Andrew Hucks napsal(a):
> When you say die, does it just stop, or do you get an error message?
> Depending on how long it's taking to perform the action, the script
> will stop just because it's taking a while. (by default, I think it's
> 30 seconds.)
>
> If so, use: ini_set("max_execution_time", "time in seconds");
>
> On Mon, May 4, 2009 at 3:43 PM, Martin Zvarík wrote:
>
>> Miller, Terion napsal(a):
>>
>>> I need help/advice figuring out why my query dies after 2 records. Here
>>> is
>>> the query:
>>>
>>> // Build your INSERT statement here
>>>
>>> $query = "INSERT into `warrants` (wid, name, age, warrant, bond, wnumber,
>>> crime) VALUES (";
>>> $query .= " '$wid', '$name', '$age', '$warrant',
>>> '$bond', '$wnumber', '$crime' )";
>>> $wid = mysql_insert_id();
>>>
>>> // run query
>>> mysql_query($query) or die ("GRRRRRRR");
>>>
>>>
>>> echo $query;
>>>
>>> It inserts two records and dies half way thru the 3rd?
>>> Thanks in advance for clues to fix this.
>>> T.Miller
>>>
>>>
>> Should be:
>> ------------------
>>
>> $sql = ...
>>
>> $query = mysql_query($sql) or die(...
>>
>> while ($r = mysql_fetch_array($query)) { ....
>>
>> ------------------
>>
>> Notice that you need to assign the mysql_query to a $query variable!
>>
>>
>> If you understand this, then there's most probably a mistake in your SQL
>> statement.
>>
>>
>> Martin
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>>
>
>

--------------010500020101000101030300--

Re: Re: Query stopping after 2 records?

am 05.05.2009 14:39:25 von tmiller

Miller: She already posted this was solved.


On 5/4/09 5:27 PM, "Martin Zvar=EDk" wrote:

If the query stopped after getting 2 entries then this has nothing to do
with max_execution_time.

But stupid topic anyway, I don't know why are we even trying to figure
what Miller meant, he most probably solved it already...


Andrew Hucks napsal(a):
> When you say die, does it just stop, or do you get an error message?
> Depending on how long it's taking to perform the action, the script
> will stop just because it's taking a while. (by default, I think it's
> 30 seconds.)
>
> If so, use: ini_set("max_execution_time", "time in seconds");
>
> On Mon, May 4, 2009 at 3:43 PM, Martin Zvar=EDk wrote=
:
>
>> Miller, Terion napsal(a):
>>
>>> I need help/advice figuring out why my query dies after 2 records. Her=
e
>>> is
>>> the query:
>>>
>>> // Build your INSERT statement here
>>>
>>> $query =3D "INSERT into `warrants` (wid, name, age, warrant, bond, wnu=
mber,
>>> crime) VALUES (";
>>> $query .=3D " '$wid', '$name', '$age', '$warrant',
>>> '$bond', '$wnumber', '$crime' )";
>>> $wid =3D mysql_insert_id();
>>>
>>> // run query
>>> mysql_query($query) or die ("GRRRRRRR");
>>>
>>>
>>> echo $query;
>>>
>>> It inserts two records and dies half way thru the 3rd?
>>> Thanks in advance for clues to fix this.
>>> T.Miller
>>>
>>>
>> Should be:
>> ------------------
>>
>> $sql =3D ...
>>
>> $query =3D mysql_query($sql) or die(...
>>
>> while ($r =3D mysql_fetch_array($query)) { ....
>>
>> ------------------
>>
>> Notice that you need to assign the mysql_query to a $query variable!
>>
>>
>> If you understand this, then there's most probably a mistake in your SQL
>> statement.
>>
>>
>> Martin
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>>
>
>



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