Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

variables in mysql_query()
Sorry for a probably dumb question, but what am I doing wrong here?

$offset = 1;
$query = "SELECT titles,artist FROM tracks LIMIT $offset,10";
$result = msql_query($query);

This will fail and I can't understand why.
The query will work fine as follows:
mysql_query("SELECT titles,artist FROM tracks LIMIT 1,10");

Another question I have is how do you test for the existence of a
query_string variable? Or a form var for that matter. ex.
localhost/mypage.php?id=103
In my code how do I test if that variable was passed? I get an error if I
try to access it any way in my code. I used the $_GET('id') statement.
I see some variables used in examples that I can find no reference to in the
manual such as $TEXT['mypage-attrib1'] and there are some more I guess
special variables like this that I do not see in the global variables. Am I
not reading the correct thing? Any guidance would be appreciated.

TIA,
jrg






Report this thread to moderator Post Follow-up to this message
Old Post
jg
03-27-04 04:12 AM


Re: variables in mysql_query()
*** jg wrote/escribió (Tue, 23 Mar 2004 11:26:57 GMT):
> This will fail and I can't understand why.

Try to find out:

$result = msql_query($query) or die(mysql_error());


> The query will
> Another question I have is how do you test for the existence of a
> query_string variable? Or a form var for that matter. ex.
> localhost/mypage.php?id=103

There are many ways. I normally use this, but I'm not claiming it's the
best:

if($_GET['id']!=''){
..
}


--
--
-- Álvaro G. Vicario - Burgos, Spain
--

Report this thread to moderator Post Follow-up to this message
Old Post
Alvaro G Vicario
03-27-04 04:12 AM


Re: variables in mysql_query()
Uhhh... try replacing "$result = msql_query($query)" with "$result =
mysql_query($query)" ...

Maybe writing the command properly could do the work, lol


"jg" <jrg@nospam-weirdcat.com> a écrit dans le message de
news:5aV7c.393$vK5.243@news01.roc.ny...
> Sorry for a probably dumb question, but what am I doing wrong here?
>
> $offset = 1;
> $query = "SELECT titles,artist FROM tracks LIMIT $offset,10";
> $result = msql_query($query);
>
> This will fail and I can't understand why.
> The query will work fine as follows:
> mysql_query("SELECT titles,artist FROM tracks LIMIT 1,10");
>
> Another question I have is how do you test for the existence of a
> query_string variable? Or a form var for that matter. ex.
> localhost/mypage.php?id=103
> In my code how do I test if that variable was passed? I get an error if I
> try to access it any way in my code. I used the $_GET('id') statement.
> I see some variables used in examples that I can find no reference to in
the
> manual such as $TEXT['mypage-attrib1'] and there are some more I guess
> special variables like this that I do not see in the global variables. Am
I
> not reading the correct thing? Any guidance would be appreciated.
>
> TIA,
> jrg
>
>
>
>
>



Report this thread to moderator Post Follow-up to this message
Old Post
Olivier Bellemare
03-27-04 04:12 AM


Re: variables in mysql_query()
Hi Oliver, thanks for the reply but that is just a typo in my post, the
actual code is $result = mysql_query($query). I must be missing some
fundmental understanding here as this makes no sense to why this doesn't
work. I echo the $query to the page just to check and it looks ok.

jrg



"Olivier Bellemare" <__NOSPAM__olivier.bellemare__NOSPAM__@cgocable.ca>
wrote in message news:tVV7c.181838$2g.111189@charlie.risq.qc.ca...
> Uhhh... try replacing "$result = msql_query($query)" with "$result =
> mysql_query($query)" ...
>
> Maybe writing the command properly could do the work, lol
>
>
> "jg" <jrg@nospam-weirdcat.com> a écrit dans le message de
> news:5aV7c.393$vK5.243@news01.roc.ny... 
I 
> the 
Am
> I 
>
>



Report this thread to moderator Post Follow-up to this message
Old Post
jg
03-27-04 04:13 AM


Re: variables in mysql_query()
Thanks Alvaro,
That allows me to check for the existence of a variable and read a variable
in the querystring. I cannot however seem to access the form variables with
the $_GET.  What method should I use to read these form variables?

TIA,
jrg

"Alvaro G Vicario" <alvaro_QUITAR_REMOVE@telecomputeronline.com> wrote in
message news:1m8vav7rs796.1aukdf45qryps$.dlg@40tude.net...
> *** jg wrote/escribió (Tue, 23 Mar 2004 11:26:57 GMT): 
>
> Try to find out:
>
> $result = msql_query($query) or die(mysql_error());
>
> 
>
> There are many ways. I normally use this, but I'm not claiming it's the
> best:
>
> if($_GET['id']!=''){
> ...
> }
>
>
> --
> --
> -- Álvaro G. Vicario - Burgos, Spain
> --



Report this thread to moderator Post Follow-up to this message
Old Post
jg
03-27-04 04:13 AM


Re: variables in mysql_query()
Perhaps your form has been submitted with the post method, check $_POST[
].
If that's not the solution try $HTTP_POST_VARS[] and $HTTP_GET_VARS[
], this
depends on your PHP version.
If you use the GET method, you should see the variable in the adressbar of
your browser (unless you use frames).


"jg" <jrg@nospam-weirdcat.com> schreef in bericht
news:MhW7c.512$c5.214@news02.roc.ny...
> Thanks Alvaro,
> That allows me to check for the existence of a variable and read a
variable
> in the querystring. I cannot however seem to access the form variables
with
> the $_GET.  What method should I use to read these form variables?
>
> TIA,
> jrg
>
> "Alvaro G Vicario" <alvaro_QUITAR_REMOVE@telecomputeronline.com> wrote in
> message news:1m8vav7rs796.1aukdf45qryps$.dlg@40tude.net... 
>
>



Report this thread to moderator Post Follow-up to this message
Old Post
John Smith
03-27-04 04:13 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PHP Language archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 03:53 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.