-
$sql_addgroup=mysql_query("insert into group (refno,name,description,type,access) VALUES ('$userref','$gn','$gd','$gt','$ga')");
-
if(!mysql_query($sql_addgroup,$con)){
-
die('error:'.mysql_error());
-
}
-
hi
all
when i run the above query its display ur query is empty. but i able to print those values b4 the query & after the query (the 2nd printing works only on after removing the query).
y i got such message?
thanks in advance
chel-1
10 1415 Atli 5,058
Recognized Expert Expert
Hi.
Read the code a little more carefully mate.
First you execute a query and assign the result to $sql_addgroup variable.
Then you execute another query using the $sql_addgroup variable, which a this point is a boolean value, which is not a valid SQL query.
thanks
its me again
my problem is "i want to check b4 insert the value is there or not?" how i solve it. that y i used the previous post way?
chel-1.
thanks
its me again
my problem is "i want to check b4 insert the value is there or not?" how i solve it. that y i used the previous post way?
chel-1.
my code is below -
-
$sql_selectUser=mysql_query("SELECT * FROM user WHERE username='$us'");
-
while($row=mysql_fetch_array($sql_selectUser)){
-
$myref=$row['refno'];
-
}
-
-
$sql_checkUser=mysql_query("SELECT refno FROM group WHERE refno='$myref'");
-
while($row=mysql_fetch_array($sql_checkUser)){
-
$userref=$row['refno'];
-
}
-
-
if((strlen($userref))>0){
-
echo "Do Something";
-
}
-
else if((strlen($userref))==0){
-
$userref=$myref;
-
-
$sql_addgroup=mysql_query("insert into group (refno,name,description,type,access) VALUES ('$userref','$gn','$gd','$gt','$ga')");
-
if(!mysql_query($sql_addgroup,$con)){
-
die('error:'.mysql_error());
-
}
-
}
-
plz correct above code 4 me.
thanks
chel-1
Atli 5,058
Recognized Expert Expert
Check what value before you insert what?
Your going to have to explain that a lot better.
The only thing I can see *wrong* with that code is what I posted earlier.
Once that is fixed the error you were talking about should be fixed.
P.S.
Please use clear English when posting.
By that I mean; don't use things like "b4", "4 me", etc...
Makes everything much much harder to read, especially in technical forums like these.
And the code tags are [code] ... [/code], not <code>...</code>.
Check what value before you insert what?
Your going to have to explain that a lot better.
The only thing I can see *wrong* with that code is what I posted earlier.
Once that is fixed the error you were talking about should be fixed.
P.S.
Please use clear English when posting.
By that I mean; don't use things like "b4", "4 me", etc...
Makes everything much much harder to read, especially in technical forums like these.
And the code tags are
, not <code>...</code>.
sorry for my mistakes. i'm still having problem. sorry
from my first query i got the user_ref_no form the table 'user'
on the second query check the above user_ref_no is available or not on the table 'group'. if not i insert the fields else update.
how can i solve it?
thanks
chel-1
sorry for my mistakes. i'm still having problem. sorry
from my first query i got the user_ref_no form the table 'user'
on the second query check the above user_ref_no is available or not on the table 'group'. if not i insert the fields else update.
how can i solve it?
thanks
chel-1
its me again
i solved checking id. now i've the error on the inserting statements.its return "QUERY WAS EMPTY"
$sql_addgroup=mysql_query("insert into group(refno,name,description,type,access)VALUES('$ user_ref','$gn','$gd','$gt','$ga')");
if(!mysql_query($sql_addgroup,$con)){
die('error:'.mysql_error());
}
how i do it? any errors on the code?
chel-1
Atli 5,058
Recognized Expert Expert -
$sql_addgroup = mysql_query("...");
-
if(!mysql_query($sql_addgroup,$con)){
-
die('error:'.mysql_error());
-
}
-
You are calling the mysql_query function twice, using the result of the first one as the SQL for the second. So, the second query is being passed a boolean value, which, as far as MySQL is concerned, is empty.
It could all be replaced by the standard: -
$result = mysql_query("...") or die(mysql_error());
-
-
$sql_addgroup = mysql_query("...");
-
if(!mysql_query($sql_addgroup,$con)){
-
die('error:'.mysql_error());
-
}
-
You are calling the mysql_query function twice, using the result of the first one as the SQL for the second. So, the second query is being passed a boolean value, which, as far as MySQL is concerned, is empty.
It could all be replaced by the standard: -
$result = mysql_query("...") or die(mysql_error());
-
thanks
well, i changed the code that follows. -
$sql_addgroup=mysql_query("insert into group(refno,name,description,type,access)VALUES('$user_ref','$gn','$gd','$gt','$ga')") or die(mysql_error());
but still having errors its return
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 'group(refno,name,description,type,access)VALUES(' 00000000030','123','1233','Frie' at line 1
what is error?
chel-1
Atli 5,058
Recognized Expert Expert
group is a reserved keyword.
If you want to use it as a database / table / column name you have to enclose it in back-ticks (`group`)
group is a reserved keyword.
If you want to use it as a database / table / column name you have to enclose it in back-ticks (`group`)
thanks
all corrects
thanks forum
chel-1
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: jaysonsch |
last post by:
Hello!
I am having some problems with a database query that I am trying to do.
I am trying to develop a way to search a database for an entry and
then edit the existing values. Upon submit, the...
|
by: shank |
last post by:
1) I'm getting this error: Syntax error (missing operator) in query
expression on the below statement. Can I get some advice.
2) I searched ASPFAQ and came up blank. Where can find the "rules"...
|
by: netpurpose |
last post by:
I need to extract data from this table to find the lowest prices of
each product as of today. The product will be listed/grouped by the
name only, discarding the product code - I use...
|
by: Harvey |
last post by:
Hi,
I try to write an asp query form that lets client search any text-string and
display all pages in my web server that contain the text. I have IIS 6.0 on a
server 2003. The MSDN site says...
|
by: Diamondback |
last post by:
I have two tables, WIDGETS and VERSIONS. The WIDGETS table has
descriptive information about the widgets while the VERSIONS table
contains IDs relating to different iterations of those widgets...
| |
by: Dave Thomas |
last post by:
If I have a table set up like this:
Name | VARCHAR
Email | VARCHAR
Age | TINYINT | NULL (Default: NULL)
And I want the user to enter his or her name, email, and age - but AGE
is optional.
...
|
by: starace |
last post by:
I have designed a form that has 5 different list boxes where the
selections within each are used as criteria in building a dynamic
query. Some boxes are set for multiple selections but these list...
|
by: jjturon |
last post by:
Can anyone help me??
I am trying to pass a Select Query variable to a table using Dlookup
and return the value to same select query but to another field.
Ex.
SalesManID ...
|
by: Stan |
last post by:
I am using MS Office Access 2003 (11.5614). My basic question is can
I run a query of a query datasheet. I want to use more that one
criteria and can not get that query to work. I thought I...
|
by: jsacrey |
last post by:
Hey everybody, got a secnario for ya that I need a bit of help with.
Access 97 using linked tables from an SQL Server 2000 machine.
I've created a simple query using two tables joined by one...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |