Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SimpleShop
#1
Hi there,

I'm coding a simple Shop plugin to GS from existing shop. I'm stuck to situation where I'm trying to fetch data from db to gs plugin admin area and nothing gets printed...

Test code looks like this:
PHP Code:
require 'plugin/config.php';

    
$query "SELECT * from " $db_database "." $db_table "_category";
    
$result mysqli_query($db$query);

    if (
mysqli_num_rows($result)>0) {
        while (
$row mysqli_fetch_assoc($result)) {
            echo 
'<pre>';
            
print_r($row);
        }
    } 

config.php is the file where the connections are made and they are ok.

Anyone who could help me with this...?
Reply
#2
Check if there are any Results
PHP Code:
require 'plugin/config.php';

    
$query "SELECT * from " $db_database "." $db_table "_category";
    
$result mysqli_query($db$query);

// Are there any results?
echo "Count mysqli_num_rows:".mysqli_num_rows($result);

    if (
mysqli_num_rows($result)>0) {
        while (
$row mysqli_fetch_assoc($result)) {
            echo 
'<pre>';
            
print_r($row);
        }
    } 
Reply
#3
(2013-03-13, 20:43:46)timme Wrote: Check if there are any Results
PHP Code:
require 'plugin/config.php';

    
$query "SELECT * from " $db_database "." $db_table "_category";
    
$result mysqli_query($db$query);

// Are there any results?
echo "Count mysqli_num_rows:".mysqli_num_rows($result);

    if (
mysqli_num_rows($result)>0) {
        while (
$row mysqli_fetch_assoc($result)) {
            echo 
'<pre>';
            
print_r($row);
        }
    } 

Hey! Thanks for the reply. Alltough there was a minor error in config.php.

and now I have a second error Smile
While there's only one $_GET (ex. load.php?id=shop&page=category ) everything is fine. When I assign one more (ex. load.php?id=shop&page=edit&id=1 ) errors appear...

Aaarrgghh...

Thanks again Smile
Reply
#4
You have 2 ids, id is used internally for the slug or plugin.
Also are you using _get variables in your query ? That is an sql injection.
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#5
(2013-03-13, 23:12:50)shawn_a Wrote: You have 2 ids, id is used internally for the slug or plugin.
Also are you using _get variables in your query ? That is an sql injection.

Ok, thanks. I didn't know about the ids used internally. And no, I'm not using global variables in my query Smile

Thanks!
Reply
#6
id=shop&page=edit&id=1
2 ids.

probably want to use pid or something.
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply




Users browsing this thread: 1 Guest(s)