473,387 Members | 1,517 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Help with multiple queries

The second query works fine by itself, so why doesn't it work when the first query is in front of it and the else is triggered?
still spits out the print with no errors.

[PHP]
<? include("dbconnect.php");
$result = mysql_query("SELECT CTRL_NUM "
. "FROM inventory "
."WHERE CTRL_NUM = $_POST[ctrl_num] ");

$res = mysql_fetch_array($result);

if( $_POST[ctrl_num] = $res[0])
{

print ("Record could not be added."); print ("Item already exists.");

}
else
{
mysql_query ("INSERT INTO inventory (CTRL_NUM, PART_NUM, SHELF_BIN, UNIT_ISSUE, PART_TYPE, WHSE, VENDOR, MANUFACTUR, SYSTEM, DOM, SUB_SYS, validation, Repairstat, QAstat)
VALUES ('$_POST[ctrl_num]', '$_POST[part_num]', '$_POST[shelf_bin]', '$_POST[unit_issue]', '$_POST[part_type]', '$_POST[whse]', '$_POST[vendor]', '$_POST[manufactur]', '$_POST[system]', '$_POST[dom]', '$_POST[sub_sys]', '$_POST[validation]', '$_POST[repairstat]', '$_POST[qastat]')");

print ("Your record has been added.");
}
mysql_close();
?>
[/PHP]
Aug 2 '07 #1
3 1028
jx2
228 100+
the code looks fine
posible problem:
u trying to insert improper values into the table
e.g. char(asci) into integer column

try this after last query

echo mysql_error();

it will display the error - if any occur

hope that help
jx2
Aug 2 '07 #2
actually it was simply as the = statement changeing the data to be entered..i wasn't sure if == was useable in php but it seems to be.
Aug 2 '07 #3
jx2
228 100+
lol i didnt notice that eighter :-) well done
Aug 2 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Prem | last post by:
Hi, I am having many problems with inner join. my first problem is : 1) I want to know the precedance while evaluating query with multiple joins. eg. select Employees.FirstName,...
4
by: DG | last post by:
Hi, Can anyone advise how to execute multiple statements in a single query batch. For example- update customers set customer_name = 'Smith' where customer_name = 'Smyth'; select * from...
2
by: maricel | last post by:
Is there any advantage in terms of performance when activating intra-parallelism INTRA_PARALLEL = yes DFT_DEGREE = -1 for a Windows 2K, sigle (1) CPU server. The database is used for a small...
1
by: Jeremy | last post by:
I have built a form that calls queries. I have the first 2 set up as select queries, and the third set up as a make table query. When multiple users are on this application at the same time, they...
2
by: Josh Felker | last post by:
Hey everyone. I have a daily log form with my investing info. In that form I have 2 subforms, the first shows my profits on all the stocks I traded that day, the second shows my profits on...
1
by: Julia | last post by:
Hello there. I have a question somewhat related to this topic, and I don't know where else to go. I hope somebody can help. I've created a database in access, that I'd like to share with less...
4
by: Dave Edwards | last post by:
I understand that I can fill a datagrid with multiple queries, but I cannot figure out how to fill a dataset with the same query but run against multiple SQL servers, the query , table structure...
0
by: JayDawg | last post by:
If anyone is willing to provide some consulting pro-bono, or for a very small charge I would really love the asistance. If anyone can fix my problem here online that would be even better. Here...
1
by: mskapek | last post by:
I need some advise on how to best create an Access 2002 report from multiple "total" queries, each which result in 3- 5 values that I need displayed on my report. Most of the queries do simple...
14
by: Supermansteel | last post by:
My team at work uses Cognos to run multiple queries to pull in data. Then they take that data and import into Access and then usually run an Append Query to run a RND function to pull out a few...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
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,...
0
jinu1996
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.