Home > Archive > PHP Language > March 2004 > variables in mysql_query()
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| 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
| |
| Alvaro G Vicario 2004-03-26, 11:12 pm |
| *** 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
--
| |
| Olivier Bellemare 2004-03-26, 11:12 pm |
| 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
>
>
>
>
>
| |
|
| 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[color=darkred]
> the
Am[color=darkred]
> I
>
>
| |
|
| 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
> --
| |
| John Smith 2004-03-26, 11:13 pm |
| 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...
>
>
|
|
|
|
|