General Community > Scripting Help
SMF1 Trying to get Auto_increment value.
MrMorph:
This is my code :
--- Code: ---global $db_prefix, $db_name;
$result = db_query("
SHOW TABLE STATUS
FROM $db_name
LIKE '{$db_prefix}my_table'"
, false, false);
$row = mysql_fetch_assoc($result);
--- End code ---
But when run $row['Auto_increment'] contains nothing.
When I do this :
--- Code: ---global $db_prefix, $db_name;
$result = db_query("
SHOW TABLE STATUS
FROM $db_name
LIKE 'my_table'"
, false, false);
$row = mysql_fetch_assoc($result);
--- End code ---
It returns a value. The only difference is that the $db_prefix is left off.
Anyone see what I have done wrong please ?
Yoshi:
What's the real table called?
MrMorph:
Hi,
merc_message_log
MrMorph:
I just noticed something. I am using SSI.php to connect to SMF.
My database does not have a prefix. My database is named smf1
I echoed out $db_prefix on a regular forum page and it returns an empty string as expected.
When I echo out $db_prefix on my page that uses SSI.php I get this (quotes included) :
--- Code: ---`smf1`.
--- End code ---
This is from this code :
--- Code: ---<?php
require_once('SSI.php');
global $db_prefix;
echo $db_prefix;
?>
--- End code ---
Is that right ? Funny thing is all my other queries work fine, it's just this LIKE expression as posted above.
Shouldn't $db_prefix always be empty if there is no prefix ?
MrPhil:
The database name and the SMF prefix are two entirely different things. The name is what your MySQL installation and phpMyAdmin see, and is defined in Settings.php. The prefix (separately defined in Settings.php) is tacked on to the beginning of each table name and is seen by everyone using this database (e.g., smf_messages).
Looking in your site control panel and/or phpMyAdmin, you will see your database name. On some systems, the name you give to PHP applications (such as in Settings.php) might have your account name and an _ tacked on to the front of the real database name. Looking inside the database in phpMyAdmin, you'll see an SMF prefix (default smf_) tacked on to table names such as messages (smf_messages) and members (smf_members). This is because some hosts only permit one database for an entire site, and you want to be able to install multiple applications without them stepping on each other's tables. It's certainly possible to make an SMF installation with a '' prefix, but why bother?
Navigation
[0] Message Index
[#] Next page
Go to full version