sinista Posted April 21, 2008 Share Posted April 21, 2008 Hi guys can somone help me with this please , the problem is a cant get my php variable ($link) into the hidden input box's value, any help wold be great. <?php $host="localhost"; $username="root"; $password="sarah2004"; $db_name="user"; $tbl_name="members"; mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $result = mysql_query("SELECT * FROM $tbl_name "); while($row = mysql_fetch_array($result)) { echo "<br>"; echo $row['username']; echo"<br>"; echo $row['avatar']; echo"<br>"; $link=$row['username']; echo'<form name="form2" method="post" action="profiletemplate.php"> <input name="searchname" type="hidden" id="searchname" Value="<?php echo $link; ?> "> <label> <input type="submit" name="Submit" value="MyProfile"> </label> </form>'; echo"<br>"; } mysql_close(); ?> thanks in advance. Link to comment https://forums.phpfreaks.com/topic/102142-need-help-with-a-variable/ Share on other sites More sharing options...
monkeypaw201 Posted April 21, 2008 Share Posted April 21, 2008 PHP cannot parse variables in single quotes, flip flop it.. in HTML put single quotes and put double around HTML and it should work Link to comment https://forums.phpfreaks.com/topic/102142-need-help-with-a-variable/#findComment-522836 Share on other sites More sharing options...
jonsjava Posted April 21, 2008 Share Posted April 21, 2008 <?php $host="localhost"; $username="root"; $password="sarah2004"; $db_name="user"; $tbl_name="members"; mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $result = mysql_query("SELECT * FROM $tbl_name "); while($row = mysql_fetch_array($result)) { echo "<br>"; echo $row['username']; echo"<br>"; echo $row['avatar']; echo"<br>"; $link=$row['username']; echo"<form name='form2' method='post' action='profiletemplate.php'> <input name='searchname' type='hidden' id='searchname' Value='$link'> <label> <input type='submit' name='Submit' value='MyProfile'> </label> </form>"; echo"<br>"; } mysql_close(); ?> Link to comment https://forums.phpfreaks.com/topic/102142-need-help-with-a-variable/#findComment-522837 Share on other sites More sharing options...
sinista Posted April 21, 2008 Author Share Posted April 21, 2008 Thanks so much for the replys, that works perfectly, lol ive been trying to work that out all day the damn quotes get me everytime:)) Link to comment https://forums.phpfreaks.com/topic/102142-need-help-with-a-variable/#findComment-522842 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.