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,quantity, 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 2079
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,quantity, 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_assoc 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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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,...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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...
| |