AEDELGOD Posted March 25, 2010 Share Posted March 25, 2010 Fatal error: Function name must be a string in [XXX] on line 36 <? include("include/session.php"); ?> <html> <title>Dykes Publishing Group :: Data Edit</title> <head><meta http-equiv="content-type" content="text/html; charset=UTF-8"><link href="style.css" rel="stylesheet" type="text/css"></head> <body> <center> <? if(isset($_SESSION['useredit'])){ unset($_SESSION['useredit']); echo "<h1>User Account Edit Success!</h1>"; echo "<p><b>$session->username</b>, your account has been successfully updated. " ."<a href=\"index.php\">Main Page</a>.</p>"; } else{ ?> <? if($session->logged_in){ ?> <h1>User Account Edit : <? echo $session->username; ?></h1> <? if($form->num_errors > 0){ echo "<td><font size=\"2\" color=\"#ff0000\">".$form->num_errors." error(s) found</font></td>"; } ?> <?php $sql = "SELECT * FROM SR_ WHERE username = '".mysql_real_escape_string($POST['username'])."'"; $result = $msql_query($sql, $link); $row = mysql_fetch_array($result); ?> <tr><td> <?php $row['field_1']; ?> </td><td> <?php $row['field_2']; ?></td></tr> <? } } ?> </center> </body> </html> Link to comment https://forums.phpfreaks.com/topic/196523-please-help-fatal-error-function-name-must-be-a-string/ Share on other sites More sharing options...
irkevin Posted March 25, 2010 Share Posted March 25, 2010 $result = $msql_query($sql, $link); Should be $result = $mysql_query($sql, $link); What is on line 36? Link to comment https://forums.phpfreaks.com/topic/196523-please-help-fatal-error-function-name-must-be-a-string/#findComment-1031792 Share on other sites More sharing options...
AEDELGOD Posted March 25, 2010 Author Share Posted March 25, 2010 Thanks for noticing that but that did not resolve my problem, I pasted the entire file, and it gives me the same problem, that line you pointed out was line 36 yet it still throws at me Fatal error: Function name must be a string in /xxx.php on line 36. :\ Link to comment https://forums.phpfreaks.com/topic/196523-please-help-fatal-error-function-name-must-be-a-string/#findComment-1031803 Share on other sites More sharing options...
irkevin Posted March 25, 2010 Share Posted March 25, 2010 oops . instead of $result = $mysql_query($sql, $link); Just put the one below $result = mysql_query($sql, $link); There shouldn't be a dollar sign in front of mysql_query(), because it is a function Link to comment https://forums.phpfreaks.com/topic/196523-please-help-fatal-error-function-name-must-be-a-string/#findComment-1031804 Share on other sites More sharing options...
AEDELGOD Posted March 25, 2010 Author Share Posted March 25, 2010 That did something, Now I get the errors: Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /***.php on line 36 Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /***.php on line 38 :\ Link to comment https://forums.phpfreaks.com/topic/196523-please-help-fatal-error-function-name-must-be-a-string/#findComment-1031805 Share on other sites More sharing options...
irkevin Posted March 25, 2010 Share Posted March 25, 2010 Just append or die(mysql_error()) with it to get a clear explanation of what's happening.. try code below $result = mysql_query($sql, $link) or die('Error : '.mysql_error()); Link to comment https://forums.phpfreaks.com/topic/196523-please-help-fatal-error-function-name-must-be-a-string/#findComment-1031807 Share on other sites More sharing options...
AEDELGOD Posted March 25, 2010 Author Share Posted March 25, 2010 Now it shows: Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /***.php on line 36 Error : and it doesnt display any of my data i think the line: $sql = "SELECT * FROM SR_ WHERE username = '".mysql_real_escape_string($POST['username'])."'"; may be wrong is there another way i could approach that? I want to be able to display and edit the mysql information based on the username of the session. Link to comment https://forums.phpfreaks.com/topic/196523-please-help-fatal-error-function-name-must-be-a-string/#findComment-1031816 Share on other sites More sharing options...
PFMaBiSmAd Posted March 25, 2010 Share Posted March 25, 2010 Read the error - mysql_query(): supplied argument is not a valid MySQL-Link resource There is no mysql link resource (connection) in the $link variable at the time the query was executed. Either your code is not attempting to make a connection to the database server at all or it did not set the $link variable or the code that is attempting to make the connection failed. What is in the include("include/session.php"); file? Link to comment https://forums.phpfreaks.com/topic/196523-please-help-fatal-error-function-name-must-be-a-string/#findComment-1031829 Share on other sites More sharing options...
irkevin Posted March 25, 2010 Share Posted March 25, 2010 Well maybe he didnt make a connection to the database You might need to add those code $link = mysql_connect('localhost','username','password'); mysql_select_db(yourdbname',$link); Link to comment https://forums.phpfreaks.com/topic/196523-please-help-fatal-error-function-name-must-be-a-string/#findComment-1031830 Share on other sites More sharing options...
AEDELGOD Posted March 25, 2010 Author Share Posted March 25, 2010 Thanks for your help, I thought I had that declared in session.php but I guess i forgot. and wouldn't you mean: $link = mysql_connect('localhost','username','password'); mysql_select_db('yourdbname',$link); You left out a ' The only problem I have now is my data wont display. Link to comment https://forums.phpfreaks.com/topic/196523-please-help-fatal-error-function-name-must-be-a-string/#findComment-1031834 Share on other sites More sharing options...
irkevin Posted March 25, 2010 Share Posted March 25, 2010 Oops sorry, was in a hurry when typing lol.. it's 23:35 here.. guess i'm half asleep.. HAHA Link to comment https://forums.phpfreaks.com/topic/196523-please-help-fatal-error-function-name-must-be-a-string/#findComment-1031836 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.