 |
| Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

April 18th, 2005, 02:58 PM
|
|
Authorized User
|
|
Join Date: Jan 2004
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
while($row1 = mysql_fetch_array($result1,MYSQL_ASSOC))
{
$values[] = $row1[TestScore];
}
i think it returns nothing, as i get an error message:-
Warning: Division by zero in /home/fhlinux196/a/askmultimedia.co.uk/user/htdocs/FW/website/example1.php on line 30
line 30 is:-
$column_width = $width / $columns ;
which means that $columns has nothing in it! which is set by line 17:-
$columns = count($values);
which in turn is set by the array, is there a way i could check if there is anything in the array?
My new web design domain
www.askmultimedia.co.uk
|
|

April 18th, 2005, 03:02 PM
|
|
Authorized User
|
|
Join Date: Apr 2005
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Add
print_r($values);
to check the value of $values.
Everything is temporary, some things are just more temporary than others... except for death, that seems to be pretty permanent
|
|

April 18th, 2005, 03:11 PM
|
|
Authorized User
|
|
Join Date: Apr 2005
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Everything looks ok from here. If $values is not returning anything I would put an echo $row1['TestScore']; in the while loop just to be sure the sql statment is returning what you expect. If it does not I would print_r($result1); to see what you are really getting back.
Everything is temporary, some things are just more temporary than others... except for death, that seems to be pretty permanent
|
|

April 18th, 2005, 03:11 PM
|
|
Authorized User
|
|
Join Date: Jan 2004
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
while($row1 = mysql_fetch_array($result1,MYSQL_ASSOC))
{
$values[] = $row1[TestScore];
}
print_r($values);
That shows me nothing! so im guessing the array is blank, do i need to create the array?
Sorry if im messing with your brain!lol
thanks
My new web design domain
www.askmultimedia.co.uk
|
|

April 18th, 2005, 03:13 PM
|
|
Authorized User
|
|
Join Date: Apr 2005
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
We posted at about the same time. Read my post above. "If $values is not returning anything I would put an echo $row1['TestScore']; in the while loop just to be sure the sql statment is returning what you expect. If it does not I would print_r($result1); to see what you are really getting back."
Everything is temporary, some things are just more temporary than others... except for death, that seems to be pretty permanent
|
|

April 18th, 2005, 03:15 PM
|
|
Authorized User
|
|
Join Date: Apr 2005
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
also it is good practice to enclose TestScore with a single quote such as $row1['TestScore']; Without the single quote php first looks for a defined constant of TestScore.
Everything is temporary, some things are just more temporary than others... except for death, that seems to be pretty permanent
|
|

April 18th, 2005, 03:31 PM
|
|
Authorized User
|
|
Join Date: Jan 2004
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
lol,
yeah its finally worked, it wasnt my code that was wrong, it was the querystring at the top of the code, which was blank, because i hadnt passed the value accross sucessfully!
Only by chance did i notice that! really been making me think i was a failure, in life in general!lol
Thanks for your help mate, its all fixed and working now!
cheers,
Ash
My new web design domain
www.askmultimedia.co.uk
|
|

April 18th, 2005, 03:35 PM
|
|
Authorized User
|
|
Join Date: Apr 2005
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Glad I could help. I once spent five hours to find out I had a dollar sign in the wrong place. Talk about feeling like a failure. Now if I could only fix my CSS problem that I have been working on for a week.
Everything is temporary, some things are just more temporary than others... except for death, that seems to be pretty permanent
|
|

April 18th, 2005, 03:41 PM
|
|
Authorized User
|
|
Join Date: Jan 2004
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
hey, thanks, it works now, it wasnt the code that was the problem, it was my querystring $testID variable that was blank, in turn returning a blank SQL query!lol, fixed it now tho!
Oh, one more thing, i need one value in this array to be 100, without the DB is there a way in which i could do this?
while($row1 = mysql_fetch_array($result1,MYSQL_ASSOC))
{
$values[] = $row1[TestScore];
$values[0] = 100;
}
ive tried this but it overwrights the first value from the database!
cheers
Ash
My new web design domain
www.askmultimedia.co.uk
|
|

April 18th, 2005, 03:46 PM
|
|
Authorized User
|
|
Join Date: Jan 2004
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
$i = 0;
while($row1 = mysql_fetch_array($result1,MYSQL_ASSOC))
{
$i++;
$values[$i] = $row1[TestScore];
$values[0] = 100;
}
there we go, that works, thanks again, and if i could help you with CSS i would, but trust me im terrible at that too!!
My new web design domain
www.askmultimedia.co.uk
|
|
 |