0

I tried to get some data from my function but I couldn't, Can any one help me

I have some data in functions file, from this page into my index page

public function selectData($table, $where = null, $wheree = null, $where1 = null, $wheree1 = null) {

    $QUERY = mysql_query("SELECT * FROM " . $table . " WHERE '" . $where . "' = '" . $wheree . "' && '" . $where1 . "' = '" . $wheree1 . "'");
    $Fetch_Assoc = mysql_fetch_assoc($QUERY);
    $Num_Rows = mysql_num_rows($QUERY);
    $Fetch_Array = mysql_fetch_array($QUERY);
    $Fetch_Object = mysql_fetch_object($QUERY);

but when I want extract data from my database using mysql_fetch_assoc in index file, it doesn't work, you'll find what I want to do in the data below

<?php include 'files/header.php';

$getData = $user->selectData('newpost');

$QUERY->Fetch_Assoc;

echo $Fetch_Assoc['P_id'];

can any one help me plzz

3
Contributors
6
Replies
32
Views
2 Years
Discussion Span
Last Post by broj1
0

I presume $user is the object instatntiated from the class that contains the selectData method. I am guessing that this class stores the results (array, object...) into some properties. Now, you should use correct operators to address those properties, such as:

echo $user->aarrayResultProperty['P_id'];
...

And also:

$QUERY->Fetch_Assoc;

I do not think you can access the $QUERY variable from outside the method.

0

I hope you din not just copy the code above since it is just a guess (and also contains a typo) - it won't work. Please post the code for the class and how you instantiate it.

0

no, there is no why, I found the solution, thank you so much :)

0

no, there is no why, I found the solution, thank you so much :)

I hope it wasn't using deprecated mysql_* functions as in your original example.

0

Please mark the thread as solved if no more questions. And yes, do not use deprecated mysql_* functions in production. Happy coding.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.