BigX Posted March 26, 2008 Share Posted March 26, 2008 Hi, I'm still learning PHP so this question is probably easy for you PHP veterans I have this piece of code: <?php $id = $_GET['id']; $organisatie = mysql_query("SELECT * FROM organisaties WHERE id=" . $id); echo "<table width='400' border='0'> <tr> <td width='400' bgcolor='#FFFFFF'>'$organisatie[Organisatie]'</td> </tr>"; ?> I only see '' on the page while I would like to see $organisatie[Organisatie]!! There is probably something really wrong with the syntax there but I don't know what!! Thanx in advance for any help!! Link to comment https://forums.phpfreaks.com/topic/97912-syntax-error-probably-easy-answer/ Share on other sites More sharing options...
ratcateme Posted March 26, 2008 Share Posted March 26, 2008 you need to fetch a mysql result array like this <?php $id = $_GET['id']; $result = mysql_query("SELECT * FROM organisaties WHERE id=" . $id); echo "<table width='400' border='0'>"; while($row = mysql_fetch_array($result)){ echo "<tr> <td width='400' bgcolor='#FFFFFF'>'$row[Organisatie]'</td> </tr>"; } ?> Scott. Link to comment https://forums.phpfreaks.com/topic/97912-syntax-error-probably-easy-answer/#findComment-500941 Share on other sites More sharing options...
darkfreaks Posted March 26, 2008 Share Posted March 26, 2008 also your query is wrong : <?php $result = mysql_query("SELECT * FROM organisaties WHERE id= '$id'");?> Link to comment https://forums.phpfreaks.com/topic/97912-syntax-error-probably-easy-answer/#findComment-500944 Share on other sites More sharing options...
BigX Posted March 26, 2008 Author Share Posted March 26, 2008 Thanks that worked!! One other short questions! The result that shows should be 'Blijf van m'n lijf' (Dutch) but it won't show the ' Instead it shows 'Blijf van m(square)n lijf' Why is this and is there any way around this?? thanks Link to comment https://forums.phpfreaks.com/topic/97912-syntax-error-probably-easy-answer/#findComment-500946 Share on other sites More sharing options...
darkfreaks Posted March 26, 2008 Share Posted March 26, 2008 try: <?php $id=mysql_real_escape_string(trim($_GET['id'])); ?> Link to comment https://forums.phpfreaks.com/topic/97912-syntax-error-probably-easy-answer/#findComment-500951 Share on other sites More sharing options...
darkfreaks Posted March 26, 2008 Share Posted March 26, 2008 you could also try <?php str_replace('square',"'",$id);?> Link to comment https://forums.phpfreaks.com/topic/97912-syntax-error-probably-easy-answer/#findComment-500967 Share on other sites More sharing options...
conker87 Posted March 26, 2008 Share Posted March 26, 2008 also your query is wrong : <?php $result = mysql_query("SELECT * FROM organisaties WHERE id= '$id'");?> Actually, that's a perfectly legal query if the field id is an integer (which considering it's an ID, it probably is) Link to comment https://forums.phpfreaks.com/topic/97912-syntax-error-probably-easy-answer/#findComment-501032 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.