Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 15-12-2009
Member
 
Join Date: Nov 2009
Posts: 518
Mysql problem

Hi
I have problem in my mysql database. I have posted my code below. Please check below
Code:
global $mys;
$st = $mys->prepare('SELECT user_name from `user_details` where user_email = ?');
$st->bind_param('s', $var);
$st->execute() or $this->myerror[] = $st->error;
echo $st->affected_rows;
$st->affected_rows returns '-1' which would indicate a error but i dont see why it would error.
Reply With Quote
  #2  
Old 15-12-2009
Member
 
Join Date: Oct 2005
Posts: 2,389
Re: Mysql problem

Hi
Surely there is any error in your code. I am not sure how you script works, but I think you should try to print out the $this->myerror array and see if there are any errors in your script and verify what the error was. Besides this I think that sql look fine, that is rest of the program look fine to me. Try the above command and then post back if you have any more problems.
Reply With Quote
  #3  
Old 15-12-2009
Member
 
Join Date: May 2008
Posts: 2,293
Re: Mysql problem

Hello
you can try the above, optionally even you can try the following part of code
Code:
mysqli_stmt->affected_rows does this -
This will return you the number of rows which are affected by insert, delete and update query.
If you like to use the select query, you can use the following
Code:
$st->num_rows
Hope this may help you.
Reply With Quote
  #4  
Old 15-12-2009
Member
 
Join Date: Oct 2005
Posts: 2,389
Re: Mysql problem

Hi
I think i should start to learn mysql thoroughly now. Even i do not have much experience in mysql. I have decided to start learning mysql thoroughly. Some time you know most of the things, but one simple wrong function spoils the whole code. If you do not learn mysql thoroughly, no use to use the mysql as a database.
Reply With Quote
  #5  
Old 15-12-2009
Member
 
Join Date: Nov 2009
Posts: 518
Re: Mysql problem

Hi
This is my modified code, please check. I am not sure this is the way of correct programming. Please check and advice me for the same.
Code:
<?php
$mys = new mys("localhost","",,"");
if(mys_connect_errno() > 0)
{
printf("detail: %s.\n", mys_connect_error());
exit();
}
$mys->autocommit(0);
global $mys;
?>
Please help.
Reply With Quote
  #6  
Old 15-12-2009
Member
 
Join Date: May 2008
Posts: 2,293
Re: Mysql problem

Hi
I think you are using the prepared statements, it would be better if you use
Code:
mysqli->affected_rows 
mysqli->affected_rows 
$stmt->affected_rows
Hope this will help you. For any more query do post back.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Mysql problem"
Thread Thread Starter Forum Replies Last Post
MySQL 9.04 to 9.10 problem Flacos Operating Systems 5 24-04-2010 05:31 AM
php/mysql select problem Fragman Software Development 3 30-11-2009 02:52 PM
Mysql Error : Can't connect to local mysql server through socket ' var lib mysql mysql.sock' 2 roshan45 Software Development 3 07-11-2009 09:36 PM
Problem connecting to mysql db Wagan-rave Software Development 3 21-03-2009 10:57 AM
problem with php / mysql under ubuntu T TelDa Networking & Security 3 01-11-2008 01:37 PM


All times are GMT +5.5. The time now is 09:52 AM.