mybluehair Posted November 12, 2007 Share Posted November 12, 2007 im making a login file, and it sayes "welcome to $name chatroom". well, at setup, a admin creates a table in mysql called settings. (threw a php file ofcourse) in this table, there are 3 feilds. in order: "password chatroomname websiteaddress" well so apparently i want to make a mysql query in login.php to grab whatever is in "chatroomname". here is what i tryed: $query1="SELECT * FROM settings"; $result=mysql_query($query1); $name=mysql_result($result, '', 'chatroomname', ''); but i just get a mysql error. so how would i write that? Quote Link to comment Share on other sites More sharing options...
Branden Wagner Posted November 12, 2007 Share Posted November 12, 2007 what error did you get? it should be... $name = mysql_result($result,'1','chatroomname'); you have to have a number... as the row.. so whether its result 1,2,3 you have to use 1,2,3 Quote Link to comment Share on other sites More sharing options...
0x00 Posted November 12, 2007 Share Posted November 12, 2007 First you need to connect to the db (*use your own details here: // CONNECT TO MYSQL $conn = mysql_connect($db_host, $db_uname, $db_pass); $res = mysql_select_db($db_dbname, $conn); Then try something like this: $query1="SELECT * FROM settings"; $result=mysql_query($query1); $name=mysql_result($result, 0, ''chatroomname"); See http://uk3.php.net/manual/en/function.mysql-result.php, for details... Also, when posting it's usually good to post the actual error... Quote Link to comment Share on other sites More sharing options...
mybluehair Posted November 12, 2007 Author Share Posted November 12, 2007 First you need to connect to the db see accually im not that stupid. that was only a snipet of the code. but i still need help. here is my new code: $result = mysql_query('SELECT chatname FROM settings'); if (!$result) { die('Could not query:' . mysql_error()); } echo mysql_result($result, 2); and error: Warning: mysql_result() [function.mysql-result]: Unable to jump to row 2 on MySQL result index 3 in /home/gotdrake/public_html/tutorial/test.php on line 15 Quote Link to comment Share on other sites More sharing options...
Moon-Man.net Posted November 13, 2007 Share Posted November 13, 2007 First you need to connect to the db see accually im not that stupid. that was only a snipet of the code. We don't know that if you don't post the error do we? but i still need help. here is my new code: $result = mysql_query('SELECT chatname FROM settings'); if (!$result) { die('Could not query:' . mysql_error()); } echo mysql_result($result, 2); and error: Warning: mysql_result() [function.mysql-result]: Unable to jump to row 2 on MySQL result index 3 in /home/gotdrake/public_html/tutorial/test.php on line 15 What is line 15? Quote Link to comment Share on other sites More sharing options...
mybluehair Posted November 13, 2007 Author Share Posted November 13, 2007 ^ line 15 is echo mysql_result($result, 2); Quote Link to comment Share on other sites More sharing options...
PHP_PhREEEk Posted November 13, 2007 Share Posted November 13, 2007 Insert this code, and post back the results: $result = mysql_query('SELECT chatname FROM settings'); if (!$result) { die('Could not query:' . mysql_error()); } $row = mysql_fetch_array($result); echo "<pre"; print_r($row); die("</pre>"); PhREEEk Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.