0

I can use the following mySQL query to get the AUTO_INCREMENT Value.

SELECT AUTO_INCREMENT  FROM information_schema.tables WHERE table_name = 'node_revision'  and table_schema = 'myDatabase'

But I can't get it using php. please help. I want solution for mysqli

PHPMy Admin Shows the Auto Increment Value

Here PHP code:

$OBdb = new MySQLDB(DBHost, DBUser, DBPassword, DBName);
$sql= "SELECT AUTO_INCREMENT  FROM information_schema.tables WHERE table_name = 'node_revision'  and table_schema = 'mydatabase'";
$result =$OBdb->query($sql);
var_dump($result);
Dharman
  • 30,962
  • 25
  • 85
  • 135
barnamah
  • 39
  • 4
  • 9
  • 1
    _But I can't get it using php_ Can't get it how? – AbraCadaver Jul 08 '21 at 20:16
  • 1
    Why can't you run that same SQL from PHP? – Barmar Jul 08 '21 at 20:21
  • i don't get anything. that's why I posted question here. I am not inserting anything. I just want to get it. – barnamah Jul 08 '21 at 20:23
  • @barnamah What exactly do you mean by "I don't get anything". Does the `var_dump()` gets executed? Do you get error messages? – Progman Jul 08 '21 at 20:25
  • 1
    You are not fetching any value – Dharman Jul 08 '21 at 20:25
  • Wondering : MySQLDB class comes from what ? What error messages are you getting when running this php `program` ? – YvesLeBorg Jul 08 '21 at 20:30
  • when running the code it print bool(false) – barnamah Jul 08 '21 at 21:08
  • 1
    [How to get the error message in MySQLi?](https://stackoverflow.com/a/22662582/1839439) – Dharman Jul 08 '21 at 21:15
  • who posted that top "the question answered"? it is NOT. I am looking for "Auto Increment" ID which is not in that page. Also I am not looking to insert and get ID. – barnamah Jul 08 '21 at 21:40
  • @Dharman you didn't read or saw the image above. MYSQL has no issue. the exact query which retunes result using phpMyAdmin, I can't get the same thing using php code. – barnamah Jul 08 '21 at 21:41
  • Your question isn't clear. You didn't address our comments. What is `MySQLDB`? Are you actually using mysqli? If so, do you fetch the results of the query anywhere? Do you have mysqli error reporting enabled? Just because phpMyAdmin can execute the query doesn't mean that your application can too. – Dharman Jul 08 '21 at 21:46

0 Answers0