hi there i am new to php ,have been working in asp classic and access but now have switched to php and mysql,and for the practice sake i started to convert my asp and access based projects into php and mysql, i have a inventory system in which i have a stock entry Portion which has aloots of fields concerning to the codeno,partno, auto , product,quantit y, size, height and lots of other fields too but our main concern is with these two "CODENO and PARTNO
sample values for these tow are here
codeno--------part no
1000--------CSV-3345
1000--------CSV-3346
1001--------CSV-3345
by looking at the values above you can figure outsome how that the values for the code no can be repeated more than once for eg you can enter part nos for the CODENO=1000 as many times as u want lets say partno=CSV-3345 but you cannot enter the existing partno for the codeno=1000 twice means the partno=csv-3345 can not be entered twice under codeno=1000 but the same partno=CSV-3345 can be entered for another code no say
"1001"in asp and access what i did for checking if the record exists this is what i did -
sqlf="SELECT Stk_items.Prt_no from Stk_items where Stk_items.Code_no="&lngcodeno
-
rf.Open sqlf, connf, 3
-
foundit=False
-
do until rf.EOF OR foundit //runs until foundit becomes true
-
if (StrComp(rf.Fields("Prt_no"), partno, vbTextCompare) = 0) then foundIt=True //assign true to foundit
-
else
-
rf.MoveNext //else move to next record
-
End if
-
Loop
-
rf.Close
-
set rf = Nothing
-
set connf= Nothing
-
this runs accurately perfect foor asp and access but in php the case is different what i have done in my php code is here -
$hostname="localhost";
-
$username="root";
-
$password="66456";
-
$database="db1";
-
-
$conn_stk = mysql_pconnect($hostname, $username, $password) or
-
trigger_error(mysql_error(),E_USER_ERROR);
-
mysql_select_db($database, $conn_stk);
-
-
$codeno=$_POST["code_no"];
-
$prtno=$_POST["prt_no"];
-
$prd=$_POST["prd"];
-
$brand=$_POST["brand"];
-
$auto=$_POST["auto"];
-
$uprc=$_POST["unit_price"];
-
$qtty=$_POST["qtty"];
-
$sroom=$_POST["show_room"];
-
$st1=$_POST["store_1"];
-
$st2=$_POST["store_2"];
-
$st3=$_POST["store_3"];
-
$size=$_POST["size"];
-
$height=$_POST["height"];
-
$od1=$_POST["out_d1"];
-
$od2=$_POST["out_d2"];
-
$id1=$_POST["in_d1"];
-
$id2=$_POST["in_d2"];
-
$trep=$_POST["t_rep"];
-
$rp1=$_POST["rp_no1"];
-
$rp2=$_POST["rp_no2"];
-
$rp3=$_POST["rp_no3"];
-
$rp4=$_POST["rp_no4"];
-
$rp5=$_POST["rp_no5"];
-
$rp6=$_POST["rp_no6"];
-
-
-
$sqlf="select Prt_no from stk_items where Code_no='$codeno'";
-
$rs=mysql_query($sqlf) or die(mysql_error().'<br />'.$sqlf);
-
-
$foundit=false;
-
-
if(mysql_num_rows($rs))
-
{
-
while($f=mysql_fetch_array($rs));
-
{
-
$ret=strcmp($f['Prt_no'],$prtno);
-
if($ret==0)
-
{
-
$foundit=true;
-
}
-
else
-
{}
-
}
-
}
-
BUT THE PROB IS THAT IF I ENTER THE PART NO WHICH ALREADY EXISTS IT TELLS THAT THE VALUE EXISTS BUT IF I ENETER ANY OTHER PART NO THAT DOESNOT EXIST IT JUST HANKS
ANY SUGGESTIONS WOULD BE HIGHLY APPRECIATED
REGARDS,
OMER
1 2099 dlite922 1,584
Recognized Expert Top Contributor
hi there i am new to php ,have been working in asp classic and access but now have switched to php and mysql,and for the practice sake i started to convert my asp and access based projects into php and mysql, i have a inventory system in which i have a stock entry Portion which has aloots of fields concerning to the codeno,partno, auto , product,quantit y, size, height and lots of other fields too but our main concern is with these two "CODENO and PARTNO
sample values for these tow are here
codeno--------part no
1000--------CSV-3345
1000--------CSV-3346
1001--------CSV-3345
by looking at the values above you can figure outsome how that the values for the code no can be repeated more than once for eg you can enter part nos for the CODENO=1000 as many times as u want lets say partno=CSV-3345 but you cannot enter the existing partno for the codeno=1000 twice means the partno=csv-3345 can not be entered twice under codeno=1000 but the same partno=CSV-3345 can be entered for another code no say
"1001"in asp and access what i did for checking if the record exists this is what i did -
sqlf="SELECT Stk_items.Prt_no from Stk_items where Stk_items.Code_no="&lngcodeno
-
rf.Open sqlf, connf, 3
-
foundit=False
-
do until rf.EOF OR foundit //runs until foundit becomes true
-
if (StrComp(rf.Fields("Prt_no"), partno, vbTextCompare) = 0) then foundIt=True //assign true to foundit
-
else
-
rf.MoveNext //else move to next record
-
End if
-
Loop
-
rf.Close
-
set rf = Nothing
-
set connf= Nothing
-
this runs accurately perfect foor asp and access but in php the case is different what i have done in my php code is here -
$hostname="localhost";
-
$username="root";
-
$password="66456";
-
$database="db1";
-
-
$conn_stk = mysql_pconnect($hostname, $username, $password) or
-
trigger_error(mysql_error(),E_USER_ERROR);
-
mysql_select_db($database, $conn_stk);
-
-
$codeno=$_POST["code_no"];
-
$prtno=$_POST["prt_no"];
-
$prd=$_POST["prd"];
-
$brand=$_POST["brand"];
-
$auto=$_POST["auto"];
-
$uprc=$_POST["unit_price"];
-
$qtty=$_POST["qtty"];
-
$sroom=$_POST["show_room"];
-
$st1=$_POST["store_1"];
-
$st2=$_POST["store_2"];
-
$st3=$_POST["store_3"];
-
$size=$_POST["size"];
-
$height=$_POST["height"];
-
$od1=$_POST["out_d1"];
-
$od2=$_POST["out_d2"];
-
$id1=$_POST["in_d1"];
-
$id2=$_POST["in_d2"];
-
$trep=$_POST["t_rep"];
-
$rp1=$_POST["rp_no1"];
-
$rp2=$_POST["rp_no2"];
-
$rp3=$_POST["rp_no3"];
-
$rp4=$_POST["rp_no4"];
-
$rp5=$_POST["rp_no5"];
-
$rp6=$_POST["rp_no6"];
-
-
-
$sqlf="select Prt_no from stk_items where Code_no='$codeno'";
-
$rs=mysql_query($sqlf) or die(mysql_error().'<br />'.$sqlf);
-
-
$foundit=false;
-
-
if(mysql_num_rows($rs))
-
{
-
while($f=mysql_fetch_array($rs));
-
{
-
$ret=strcmp($f['Prt_no'],$prtno);
-
if($ret==0)
-
{
-
$foundit=true;
-
}
-
else
-
{}
-
}
-
}
-
BUT THE PROB IS THAT IF I ENTER THE PART NO WHICH ALREADY EXISTS IT TELLS THAT THE VALUE EXISTS BUT IF I ENETER ANY OTHER PART NO THAT DOESNOT EXIST IT JUST HANKS
ANY SUGGESTIONS WOULD BE HIGHLY APPRECIATED
REGARDS,
OMER
Use mysql_fetch_ass oc instead of array.
or change it to access it like $f[0]
also change $ret==0 to $ret===0 (check type)
then try again.
PS, you don't need that extra else.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: dave |
last post by:
Hello there,
I am at my wit's end ! I have used the following script succesfully to
upload an image to my web space. But what I really want to be able to do is
to update an existing record in a table in MySQL with the path & filename to
the image.
I have successfully uploaded and performed an update query on the database,
but the problem I have is I cannot retain the primary key field in a
variable which is then used in a SQL update...
|
by: Mike Chirico |
last post by:
Interesting Things to Know about MySQL
Mike Chirico (mchirico@users.sourceforge.net)
Copyright (GPU Free Documentation License) 2004
Last Updated: Mon Jun 7 10:37:28 EDT 2004
The latest version of this document can be found at:
http://prdownloads.sourceforge.net/souptonuts/README_mysql.txt?download
|
by: Sam White |
last post by:
I have set up a MySQL db on one server, IIS 6.0 on another. Using
Frontpage I created some forms to input data. On a test page I made, I
have 4 fields. First is the ID which is autonumber (I leave alone). The
second is marked as TEXT, the third is MEDIUMTEXT, and the fourth is
DATE. This is just an example though, the problem exists in no matter
what manner I create the form.
Now here is the issue. In the TEXT fields nothing is saved...
|
by: alf |
last post by:
Hi,
is it possible that due to OS crash or mysql itself crash or some e.g.
SCSI failure to lose all the data stored in the table (let's say million
of 1KB rows). In other words what is the worst case scenario for MyISAM
backend?
Also is it possible to not to lose data but get them corrupted?
|
by: kd8con |
last post by:
Ok, I am writing an application in which - a user enters data into a field, then when leaving this field and going to the next field, I need to do a search on the access database for that data and pop up a window if it exists giving specific data from that record in the database.
Setting up the database connection is done, since it is the same database - what I'm having a problem with is performing this action during a field entry. Also I...
| |
by: paulq182 |
last post by:
PLEASE HELP ME WITH MY CODE??
import java.sql.*;
import java.io.*;
class min_filmdb_rel_mysql {
public static void main (String args )
throws SQLException, IOException {
|
by: Atli |
last post by:
This is an easy to digest 12 step guide on basics of using MySQL. It's a great refresher for those who need it and it work's great for first time MySQL users.
Anyone should be able to get through this without much trouble. Programming knowledge is not required.
Index
What is SQL?
Why MySQL?
Installing MySQL.
Using the MySQL command line interface
|
by: Atli |
last post by:
You may be wondering why you would want to put your files “into” the database, rather than just onto the file-system. Well, most of the time, you wouldn’t.
In situations where your PHP application needs to store entire files, the preferred method is to save the file onto the server’s file-system, and store the physical location of the file in your database. This is generally considered to be the easiest and fastest way to store files.
...
|
by: ssnaik84 |
last post by:
Hi Guys,
Last year I got a chance to work with R&D team, which was working on DB scripts conversion..
Though there is migration tool available, it converts only tables and constraints..
Rest of things (stored procedures, functions).. we have to manually edit.
That time, we face some interesting challenges.. I failed to document all of them, but whatever I can share with u.. I will try.. :)
...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |