Hi
a quickie :
If i insert some information into a database table with mysql_query(INSERT) is there a simple function that enables me to check that the entry has been made correctly without running a mysql_query(SELECT) function ?
If not, is it possible to put a mysql_query(INSERT) followed directly by a mysql_query(SELECT) within the same mysql_connect()?
I've been trying to do this but it doesn't work and i'm not sure if it is actually possible to do this.....
thanks
Cody d*l*b
a function to check if a mysql_query has happened properly
Moderator: General Moderators
-
VisionsOfCody
- Forum Commoner
- Posts: 30
- Joined: Sat Mar 01, 2003 1:19 pm
- Location: France
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
-
VisionsOfCody
- Forum Commoner
- Posts: 30
- Joined: Sat Mar 01, 2003 1:19 pm
- Location: France
thanks - i had a look at the manual entry
sorry to appear a bit dim but i need to check if i've got this - can i do this to turn the result into a variable?:
mysql_query("INSERT into password (login,password,type,name,trad,email) values ('$login','$password','$client','$name','$trad','$email')");
$rows=mysql_affected_rows();
then check if $rows is 1 or 0 to be sure that the data has been entered into the table??
thanks for your patience
Cody d*l*b
sorry to appear a bit dim but i need to check if i've got this - can i do this to turn the result into a variable?:
mysql_query("INSERT into password (login,password,type,name,trad,email) values ('$login','$password','$client','$name','$trad','$email')");
$rows=mysql_affected_rows();
then check if $rows is 1 or 0 to be sure that the data has been entered into the table??
thanks for your patience
Cody d*l*b
-
pootergeist
- Forum Contributor
- Posts: 273
- Joined: Thu Feb 27, 2003 7:22 am
- Location: UK
-
VisionsOfCody
- Forum Commoner
- Posts: 30
- Joined: Sat Mar 01, 2003 1:19 pm
- Location: France
Re: a function to check if a mysql_query has happened proper
Unless I'm mistaken MySQL should throw an error if the information is not entered correctly ..VisionsOfCody wrote:If i insert some information into a database table with mysql_query(INSERT) is there a simple function that enables me to check that the entry has been made correctly without running a mysql_query(SELECT) function
Code: Select all
$query = "Place your query here";
$result = mysql_query($query) or die("Error executing $query <br /> MySQL reported: " . mysql_error());
while ($row = mysql_fetch_array($query)) {-
VisionsOfCody
- Forum Commoner
- Posts: 30
- Joined: Sat Mar 01, 2003 1:19 pm
- Location: France
oooh - i like that!
that way i can put up a message to contact the administrator if the efforts to upload a file fail.
Thanks
Thanks