Jump to content

Recommended Posts

Hi,

 

I am having problem with a very very simple code.

I use it alot and it never caused me this much of trouble. Its been like 2-3 hours that I am trying to figure it out...

:facewall: :facewall: :facewall:

 

Ok here is the code:

		$result = mysql_query("SELECT * FROM history ORDER BY `id` DESC LIMIT 0,5",$link);
		while($row = mysql_fetch_array($result))
{
$history = "" .$row['history']. "";
$playerid = substr($history, 0, 4);

$getp = mysql_query("SELECT * FROM `players`  WHERE `id` = '$playerid' ",$link);
$player_name = mysql_fetch_array($getp) or die(mysql_error());
$Player = "" .$player_name['name']. "";

echo "$Player $history<br/>";
}
?>

 

 

I echoed $playerid, alone and it shows it well...

I tried running the Select sql, in PHP MyAdmin, it works..

 

Its only:

$player_name = mysql_fetch_array($getp) or die(mysql_error());

 

That seems to be bugging, but I have no idea why....

 

 

Thanks, for your help,

Ara

Link to comment
https://forums.phpfreaks.com/topic/170984-solved-help-with-a-simple-code/
Share on other sites

Hey there,

 

Go to the first line of your script and add the following code:

 

<?
error_reporting(E_ALL);

... 
. 
.

?>

 

This will help you to get an idea of what went wrong.

 

I think it is - sorry, it could be something about your myassoc-request method and your way

to request the data, but i am not sure .

Hi,

MadTechie, there is no error... The code just stops.... The rest is blank....

 

dirtynight, I added it but, it is still blank....

 

I dont know whats going wrong...

 

I tried running the code alone on php my admin, and is able to find the data....

okay try this and report back the errors

<?php
$result = mysql_query("SELECT * FROM history ORDER BY `id` DESC LIMIT 0,5",$link) or die(mysql_error());
while($row = mysql_fetch_array($result))
{
$history = $row['history'];
$playerid = substr($history, 0, 4);

$SQL = "SELECT * FROM `players` WHERE `id` = '$playerid' ";
$getp = mysql_query($SQL,$link) or die($SQL.mysql_error());
$player_name = mysql_fetch_array($getp);
$Player = $player_name['name'];

echo "$Player $history<br/>";
}
?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.