...

View Full Version : undefine function



Kev0121
03-22-2009, 04:50 PM
Im trying to do something with my profile.php and im getting


Fatal error: Call to undefined function mysql_fech_assoc() in /home/youronli/public_html/profile.php on line 76

basically, im trying to make a query that gets the id and then it checks the database to see if the active field is set to 1, and if it is it should display an online message if not should display an offline message

here is my code



<hr color='silver' width='100%'/>
<?php

$new = "SELECT * FROM `users` WHERE `id` = '".$_GET['id']."'";
$new_res = mysql_query($new) or die(mysql_error());
$new_row = mysql_fech_assoc($new_res);

if($new_row['active'] == 1) {
echo "<b> '".$new_row['name']."' is Scott is <font color=green>online.</font></b>";
}

?>

Kev0121
03-22-2009, 05:00 PM
Im trying to do something with my profile.php and im getting


Fatal error: Call to undefined function mysql_fech_assoc() in /home/youronli/public_html/profile.php on line 76

basically, im trying to make a query that gets the id and then it checks the database to see if the active field is set to 1, and if it is it should display an online message if not should display an offline message

here is my code



<hr color='silver' width='100%'/>
<?php

$new = "SELECT * FROM `users` WHERE `id` = '".$_GET['id']."'";
$new_res = mysql_query($new) or die(mysql_error());
$new_row = mysql_fech_assoc($new_res);

if($new_row['active'] == 1) {
echo "<b> '".$new_row['name']."' is Scott is <font color=green>online.</font></b>";
}
?>

steelaz
03-22-2009, 05:04 PM
It's mysql_fetch_assoc(), not mysql_fech_assoc().

Kev0121
03-22-2009, 05:06 PM
Omg, how obvious. lmao thanks alot mate :)

djm0219
03-22-2009, 05:06 PM
You missed the T in fetch


$new_row = mysql_fetch_assoc($new_res);

oesxyl
03-22-2009, 06:39 PM
Im trying to do something with my profile.php and im getting



basically, im trying to make a query that gets the id and then it checks the database to see if the active field is set to 1, and if it is it should display an online message if not should display an offline message

here is my code



<hr color='silver' width='100%'/>
<?php

$new = "SELECT * FROM `users` WHERE `id` = '".$_GET['id']."'";
$new_res = mysql_query($new) or die(mysql_error());
$new_row = mysql_fech_assoc($new_res);

if($new_row['active'] == 1) {
echo "<b> '".$new_row['name']."' is Scott is <font color=green>online.</font></b>";
}

?>
you post in the wrong place, ask a moderator to move your post, don't post again, please.
use mysql_result if you want to fetch a single field, don't use * in query in that case and check to have only one row in result.

http://www.php.net/manual/en/function.mysql-result.php

if you want to fetch multiple fields and/or rows use a while with mysql_fetch_assoc.

best regards

Fou-Lu
03-22-2009, 09:26 PM
While oesxyl actually posted the solution, this one is a little more specific for you're actual error:
mysql_fech_assoc() doesn't exist, its a typo. You're missing the 't' in fetch.

oesxyl
03-22-2009, 09:42 PM
While oesxyl actually posted the solution, this one is a little more specific for you're actual error:
mysql_fech_assoc() doesn't exist, its a typo. You're missing the 't' in fetch.
good catch, :) I didn't see the missing 't', :)

best regards

oesxyl
03-22-2009, 10:19 PM
Omg, how obvious. lmao thanks alot mate :)
that's why cross posting is not allow on cf:

http://www.codingforums.com/showpost.php?p=796588&postcount=3

regards

Fou-Lu
03-23-2009, 04:51 AM
Hmm, I thought it would let me choose how to merge these.
Oh well, solution gained, even though the thread looks terrible now >.<



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum