Hi guys, I'm having a problem with a php script. here's the code below. $sql= mysql_query("SELECT username FROM `ulmundo`.`users` where userid =$cookie_uid"); $result1= mysql_result($sql); //add comment $q ="INSERT INTO `comments` (article_id, poster_id, page, date, time, username, ip, comment) VALUES ($global_user_id, $cookie_uid, '".$_POST['page']."', '".$_POST['date']."', '".$_POST['time']."', $result1 , '".$_SERVER['REMOTE_ADDR']."','".addslashes($_POST['comment'])."')"; PHP: I'm trying to insert the string username taken form the user table and insert it into the comments page. I'm getting an sql error when this code is executed. The error is telling me that mysql_result is wrong parameter count. The code works perfectly until i try to insert the value $result1 Any help would be great thanks
If it's only erroring when you try to insert the $result1, then I'm going to point out the first error I saw: $result1 holds the username, correct? It's text, so it has to be enclosed in single quotes the same way all your other variables are: '".$result1."' (just setting it up same way you have your other vars)
Hi, I've changed it to as you said, there is now no error but it is not entering the username into the field in the database. is this statement wrong??? $result1=mysql_result($sql); The field in the database remains blank thanks for any help
Sorry i am getting an error here it is Warning: Wrong parameter count for mysql_result() in C:\AppServ\www\view_profile.php on line 211
When you originally connected to the database, you stored the connection in a variable, right? You need to pass that variable as the second parameter. $connect_var = mysql_connect(blah,blah,blah); //your other stuff $result1=mysql_result($sql,$connect_var);