Page 1 of 1

Getting no data

Posted: Sun May 10, 2009 5:40 pm
by Todlerone
Hello all. Thank-you in advance for any help/suggestions. I can't figure-out why this won't work.

Code: Select all

$idscores=safe_output($_POST["GameScores"]);
$query = "SELECT * FROM schedule09 WHERE game_id = $idscores";
$result=mysql_query($query);
$row=mysql_fetch_array ($result,MYSQL_NUM);
$Currentdate = $row[1];
 
When I echo $idscores before the $query I get the number I'm looking for. The correct data is in the schedule09 DB.

Thanks
Todlerone

Re: Getting no data

Posted: Sun May 10, 2009 6:13 pm
by John Cartwright
You need to execute the query (mysql_query()), and fetch the results (mysql_fetch_assoc())

Re: Getting no data

Posted: Sun May 10, 2009 6:24 pm
by Todlerone
TY for your response John. I edited my original post to show more of the code. My query seems to get nothing back. The $idscores is the exact value I want and like I said the data in the DB is there under the primary value that I'm trying to extract. Is there something wrong with the query structure with the $idscores variable?

Todlerone

Re: Getting no data

Posted: Sun May 10, 2009 6:31 pm
by John Cartwright
Try running this instead to give us some more information

Code: Select all

$idscores=safe_output($_POST["GameScores"]);
$query = "SELECT * FROM _schedule09 WHERE game_id = $idscores";
 
echo 'Query: '. $query .' <br />';
 
$result=mysql_query($query);
 
if (!$result) {
   echo 'Query Failed because: '. mysql_error() .'<br>';
}
 
echo 'Number rows found: '. mysql_num_rows($result) .'<br>';
 
while ($row = mysql_fetch_assoc($result)) {
   echo 'Row data: '. print_r($row, true) .'<br>';
}

Re: Getting no data

Posted: Sun May 10, 2009 6:49 pm
by Todlerone
It's an access denied error. This is for a Joomla site that I have made. I'm using my own code via a "JUMI" module. My problem seems to be when I had my own simple coded site I had an admin section that allowed a form to be populated with MySql DB content. You could select a date to add scores then it would direct you to another page (from the action of the form) Here you would enter the scores then the DB would be updated. I'm sure I have over killed the code doing this but it worked perfectly. With Joomla the form action call outs seem to be my problem. Is there a way for me to make one form the calls itself "PHP_SELF" that would have multiple levels of forms? For example:
if date selected do this;
if date selected and scores entered do this
else show form.
I hope I'm making sense. I know there is some Javascript that would help but I don't know any Javascript and would prefer to do it with PHP as I can usually make my way around the coding (if not eventually). I currently have one form (select a date to enter scores for) that calls another form (enter the scores for selected game date) that then calls another php file that updates the DB. Can it be put into one php file or should I not try this?

TY John

Re: Getting no data

Posted: Sat May 16, 2009 8:39 pm
by John Cartwright
You are getting the access denied error because you have not provided the correct database details/credentials, and/or your user does not have permission to execute the query (likely the former).

Re: Getting no data

Posted: Thu Jun 04, 2009 10:35 pm
by enna
Todlerone wrote:Hello all. Thank-you in advance for any help/suggestions. I can't figure-out why this won't work.

Code: Select all

$idscores=safe_output($_POST["GameScores"]);
$query = "SELECT * FROM schedule09 WHERE game_id = $idscores";
$result=mysql_query($query);
$row=mysql_fetch_array ($result,MYSQL_NUM);
$Currentdate = $row[1];
 
When I echo $idscores before the $query I get the number I'm looking for. The correct data is in the schedule09 DB.

Thanks
Todlerone
try changing this
$query = "SELECT * FROM schedule09 WHERE game_id = $idscores";

to this
$query = "SELECT * FROM schedule09 WHERE game_id = '$idscores'"; -->i placed apostrophes