Sorrow Posted November 22, 2006 Share Posted November 22, 2006 I am Displaying all those variable properly until i get to ( echo "<td>" . $row['Adresse'] . "</td></tr>";) it is diplaying (echo "<tr><td>Adresse : </td>) but not the database value.if you wanna see here is the website : [url=http://www.pirate-production.com/webrencontre/profil.php]http://www.pirate-production.com/webrencontre/profil.php[/url][code]<?php$con = mysql_connect("","","");if (!$con) { die('Could not connect: ' . mysql_error()); }mysql_select_db("jplegris_pirate", $con);$result = mysql_query("SELECT * FROM Usagers");while($row = mysql_fetch_array($result)) {echo "<table border='0'><tr><td>Nom Usager : </td>"; echo "<td>" . $row['Username'] . "</td></tr>"; echo "<tr><td>Nom : </td>"; echo "<td>" . $row['Nom'] . "</td></tr>"; echo "<tr><td>Prenom : </td>"; echo "<td>" . $row['Prenom'] . "</td></tr>"; echo "<tr><td>Âge : </td>"; echo "<td>" . $row['Age'] . "</td></tr>"; } echo "<tr><td>Adresse : </td>"; echo "<td>" . $row['Adresse'] . "</td></tr>";echo "</table>";?>[/code] Link to comment https://forums.phpfreaks.com/topic/28040-weird-behavior-of-my-select-query/ Share on other sites More sharing options...
DaviDJ Posted November 22, 2006 Share Posted November 22, 2006 edit out your mysql_connect details, and also is that the correctly spelt field name?Double check it is and also double check there is a value set for the row(s) you are looking at Link to comment https://forums.phpfreaks.com/topic/28040-weird-behavior-of-my-select-query/#findComment-128285 Share on other sites More sharing options...
hitman6003 Posted November 22, 2006 Share Posted November 22, 2006 you also have a lot of extra echo statements that are unnecessary.[code]$con = mysql_connect(***, ***, ***) or die(mysql_error());mysql_select_db("database", $con);$result = mysql_query("SELECT * FROM Usagers");while($row = mysql_fetch_array($result)) { echo " <table border='0'> <tr> <td>Nom Usager : </td> <td>" . $row['Username'] . "</td> </tr> <tr> <td>Nom : </td> <td>" . $row['Nom'] . "</td> </tr> <tr> <td>Prenom : </td> <td>" . $row['Prenom'] . "</td> </tr> <tr> <td>Age : </td> <td>" . $row['Age'] . "</td> </tr> <tr> <td>Adresse : </td> <td>" . $row['Adresse'] . "</td> </tr> </table>";}[/code] Link to comment https://forums.phpfreaks.com/topic/28040-weird-behavior-of-my-select-query/#findComment-128286 Share on other sites More sharing options...
Sorrow Posted November 22, 2006 Author Share Posted November 22, 2006 ty very much it is working now but is there a way to use a $_POST['Username'] in a select query like[code]$result = mysql_query("SELECT * FROM Usagers where Username = "$_Post['Username']);[/code] Link to comment https://forums.phpfreaks.com/topic/28040-weird-behavior-of-my-select-query/#findComment-128296 Share on other sites More sharing options...
hitman6003 Posted November 22, 2006 Share Posted November 22, 2006 Use the concatenation operator ( . - a period):[code]$result = mysql_query("SELECT * FROM Usagers where Username = " . $_Post['Username']);[/code] Link to comment https://forums.phpfreaks.com/topic/28040-weird-behavior-of-my-select-query/#findComment-128299 Share on other sites More sharing options...
Sorrow Posted November 22, 2006 Author Share Posted November 22, 2006 It still gives me an error : mysql_fetch_array(): supplied argument is not a valid MySQL result resource in [code]mysql_select_db("jplegris_pirate", $con);$result = mysql_query("SELECT * FROM Usagers where Username = " . $_Post['Username']);while($row = mysql_fetch_array($result)) { echo " <table border='0' align='center'> <tr> <td>Nom Usager : </td> <td>" . $row['Username'] . "</td> </tr> <tr> <td>Nom : </td> <td>" . $row['Nom'] . "</td> </tr> <tr> <td>Prenom : </td> <td>" . $row['Prenom'] . "</td> </tr> <tr> <td>Age : </td> <td>" . $row['Age'] . "</td> </tr> <tr> <td>Sexe : </td> <td>" . $row['Sexe'] . "</td> </tr> <tr> <td>Adresse : </td> <td>" . $row['Adresse'] . "</td> </tr> <tr> <td>Ville: </td> <td>" . $row['Ville'] . "</td> </tr> <tr> <td>Province: </td> <td>" . $row['Province'] . "</td> </tr> <tr> <td>Pays: </td> <td>" . $row['Pays'] . "</td> </tr> <tr> <td>Adresse : </td> <td>" . $row['Adresse'] . "</td> </tr> <tr> <td>No. de Tel. : </td> <td>" . $row['NoTel'] . "</td> </tr> <tr> <td>Taille Physique : </td> <td>" . $row['TaillePhysique'] . "</td> </tr> <tr> <td>Fumeur : </td> <td>" . $row['Fumeur'] . "</td> </tr> <tr> <td>Buveur : </td> <td>" . $row['Buveur'] . "</td> </tr> <tr> <td>Ethnie : </td> <td>" . $row['Ethnie'] . "</td> </tr> <tr> <td>Courriel : </td> <td>" . $row['Courriel'] . "</td> </tr> </table>";}?>[/code] Link to comment https://forums.phpfreaks.com/topic/28040-weird-behavior-of-my-select-query/#findComment-128303 Share on other sites More sharing options...
hitman6003 Posted November 22, 2006 Share Posted November 22, 2006 It's a string so you have to put it in single quotes:[code]$result = mysql_query("SELECT * FROM Usagers where Username = '" . $_Post['Username']) . "'";[/code] Link to comment https://forums.phpfreaks.com/topic/28040-weird-behavior-of-my-select-query/#findComment-128304 Share on other sites More sharing options...
Sorrow Posted November 22, 2006 Author Share Posted November 22, 2006 Ive edited the string a little [code]$result = mysql_query("SELECT * FROM Usagers where Username = '" . $_Post['Username']. "'") ;[/code]but still not working Link to comment https://forums.phpfreaks.com/topic/28040-weird-behavior-of-my-select-query/#findComment-128305 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.