Menu

#13 Problem trying to edit/delete records

open
nobody
None
5
2004-03-07
2004-03-07
Anonymous
No

Hello,

I am very interested in using (and developments) of this
package. After installation and configuration of db I use
with another admin (i developped myself), I always get
this message when editing/deleting records in my (only)
registered db.

Error : DB Error: no such table

remarks :
- everything is working fine for the main database
(phpfriendlyadmin)
- displaying & printing records is ok
- tables are defined
- fields are defined
- adding a record is ok
- thishappens for

I added some "pointers" in the code & this is the point
where the error arrives (when trying to EDIT a record of
the 'user' db):

file : main_classes/Edit.php

$sql query = "select * from [my first registered db]
where id_field = '8' (which is the correct id i would like
to edit/erase)
This query should be ok. but apparently pointing to a
bad db ???!

//NAME: requireeditid
//PURPOSE: Makes sure that delete page has a

editid defined, otherwise sends user back to browse
tables
function requireeditid($maindb) {
$db = $maindb->constring();
$sql = "SELECT * FROM " . $this-
>currenttable->dbtablename . " WHERE " . $this-
>currenttable->findid() . " = '" .
phpFriendlyAdmin::validateurlvars($_GET['editid']) . "'";
$result = $db->query($sql);
if (DB::isError($result))
die ("Error : " . $result-
>getMessage() . "\n");

    if \($result->numRows\(\) \!= 1\)
        $found = false;
    else
        $found = true;

    if \(\(phpFriendlyAdmin::validateurlvars

($_GET['editid']) === false) ||
(phpFriendlyAdmin::validateurlvars($_GET['editid'])
== "") || ($found == false)) {
$location = "Location:
index.php?currenttable=" .
phpFriendlyAdmin::validateurlvars($_GET
['currenttable']) . "&" . SID;
header($location);
exit;
}
}

Thanks forany help !

Jack

pfa@jackanova.net

Discussion

  • Nobody/Anonymous

    Logged In: NO

    *********************************************

    Everything going fine IF my registered db is the same as the
    main db (all tables in the same db)

    is it normal ? or is it required to use only 1 db ?

    Thanks !

    *********************************************

     
  • Martijn

    Martijn - 2004-07-07

    Logged In: YES
    user_id=1078591

    Hi, I had the exact same problem, you can solve it by
    changing some lines in the main_classes/User.php file.
    Change this:

        $sql = "SELECT \* FROM " . $currenttable->dbtablename . "
    

    WHERE " . $currenttable->findid() . " = '" . $primarykey . "'";

        $result = $db->query\($sql\);
    

    into this:

        $sql = "SELECT \* FROM " . $currenttable->dbtablename . "
    

    WHERE " . $currenttable->findid() . " = '" . $primarykey . "'";

        $regdb = $currenttable->database->constring\(\);
        $result = $regdb->query\($sql\);
    

    the problem was that it was always using the main database
    to find the table you were working on. This also solves the
    same problem when trying to use the trashcan icon too!

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.