Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7741197
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T08:57:50+00:00 2026-06-01T08:57:50+00:00

I am rewriting a php file which gets persons and their details from an

  • 0

I am rewriting a php file which gets persons and their details from an MYSQL DB and layering it (to protect from hacking, etc…)

PHP file that I’m editing currently goes like this:

<div id='idLeft'>
<?php
@session_start();
$_SESSION['auth'] = 'ok';
$db_server = "localhost";
$db_user = "username";
$db_pass = "******";
$db_database = "mydatabase";
    $db_con = @mysql_connect($db_server, $db_user, $db_pass);
if(!$db_con) die("Database error!");
if(!@mysql_select_db($db_database, $db_con)) die("Database error!");
mysql_query("SET NAMES UTF8");

$query = "SELECT osobaID,ime,prezime FROM ssa_osoba";
$rs = mysql_query($query);
$i=0;
while( $row = mysql_fetch_assoc($rs)) {
?>
<div class='osoba'>
    <div class="brojosobe">
    <span class="otekst"><?php echo $i++.'.'; ?></span>
    </div>
    <div class ="imeprezime">
    <span class="otekst"><?php echo $row['ime'].' '.$row['prezime'];?></span>
    </div>
        <div class='hidden'><?php echo $row['osobaID'];?></div>
</div>
<?php
}
?>

I rewrote it like this:

 <?php
@session_start();
try
{   
    require "inc/func.php"; 
    require_once("db/db.php");
    $db = db_layer::get();
    $DBCONNECTION = $db->getHandle();
}
catch( Exception $Ex )
{
    exit();
    //die ( $Ex->getMessage() );
    //echo $Ex;
}

And the part that should output it goes like this.

    <?php
    $i=0;
while( $row = get_osoba() ) {
    ?>
<div class='osoba'>
    <div class="brojosobe">
    <span class="otekst"><?php echo$i++.'.'; ?></span>
    </div>
    <div class ="imeprezime">
    <span class="otekst"><?php echo $row['ime'].' '.$row['prezime'];?></span>
    </div>
<?php
}
?>

My functions are in /inc folder (one file functions.php)
I have these functions in it:

function osoba_query()
{
$query ="SELECT osobaID,ime,prezime FROM ssa_osoba";
return mysql_query($query);
}
function get_osoba()
{
$rs =  osoba_query();
static $row = mysql_fetch_assoc($rs);
return $row;
}

But it always outputs only the first row.
mysql_fetch_assoc should move the pointer to the next row, but in this case it doesn’t.

What should I do?

EDIT1:

If i do this:

$query ="SELECT osobaID,ime,prezime FROM ssa_osoba";
$rs = mysql_query($query);
function get_osoba()
{
global $rs;
$row = mysql_fetch_assoc($rs);
return $row;
}

PHP outputs:
Warning: mysql_fetch_assoc() expects parameter 1 to be resource, null given in D:\Xampp\htdocs\ssa\ilayer\inc\func.php on line 7

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T08:57:51+00:00Added an answer on June 1, 2026 at 8:57 am

    You’re re-running the query every time osoba_query() is called, which resets everything.

    Don’t do that.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am retriving a .php file which json_encodes the results from a recordset. it
I have me .htaccess file happily rewriting things like /conferences/details/21 to /index.php?pages=conferences&var1=details&var2=21 . I
I am updating a php app, which currently does not use url rewriting. The
I have an htaccess file that is supposed to be redirecting any non-existing files/folders/etc
I need help rewriting online.php to -> /users/online and profile.php?id=3426 to -> /users/3426 and
I'm trying to learn Regex & URL Rewriting in PHP. How can I create
I used to have PHP websites and using url rewriting on picture to have
I am trying to extend a PHP class without rewriting the whole thing. Here
I'm going to start a new project - rewriting an existing system (PHP +
I've got my htaccess rewriting on the following rules: RewriteRule ^([a-zA-Z0-9\-]*)/([0-9]*)/([a-zA-Z0-9\-_]*)$ /content.php?a=$1&b=$2&c=$3 RewriteRule ^([a-zA-Z0-9\-]*)/([0-9]*)$

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.