ChompGator Posted March 7, 2008 Share Posted March 7, 2008 Hey, What I want to do is list all my users email address from the database, but separate them by a semi colon, is this the right way to do this? I didn't add in the scripting to separate them all by a semi colon, because I wasn't sure what the script was to do that? <?php $con = mysql_connect("****","****","****") or die('Could not connect: ' . mysql_error()); mysql_select_db("login", $con); $result = mysql_query("SELECT * FROM subscribe"); echo "<table border='1'> <th>Email</th> </tr>";while($row = mysql_fetch_array($result)) { echo "<td>" . $row['email'] . "</td>"; } echo "</table>";mysql_close($con); ?> Link to comment https://forums.phpfreaks.com/topic/94823-is-this-the-right-way/ Share on other sites More sharing options...
ChompGator Posted March 7, 2008 Author Share Posted March 7, 2008 Updated, I changed the script to whats below, but Im getting a parse error on line 8 unepected '}' Any suggestions on how to fix it <?php $con = mysql_connect("***","****","*****") or die('Could not connect: ' . mysql_error()); mysql_select_db("login", $con); $result = mysql_query("SELECT * FROM subscribe"); while($row = mysql_fetch_assoc($result)){ $row['email'] } ?> Link to comment https://forums.phpfreaks.com/topic/94823-is-this-the-right-way/#findComment-485664 Share on other sites More sharing options...
The Little Guy Posted March 7, 2008 Share Posted March 7, 2008 add a semi colon after: $row['email'] Link to comment https://forums.phpfreaks.com/topic/94823-is-this-the-right-way/#findComment-485668 Share on other sites More sharing options...
ChompGator Posted March 7, 2008 Author Share Posted March 7, 2008 I added the semi-colon after where you said too, now Im getting this error, Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in D:\hosting\member\aiim\affiliates\email.php on line 6 here is what the script looks like now <?php $con = mysql_connect("****","***","****") or die('Could not connect: ' . mysql_error()); mysql_select_db("subscribe", $con); $result = mysql_query("SELECT * FROM subscribe"); while($row = mysql_fetch_assoc($result)){ $row['email']; } ?> Link to comment https://forums.phpfreaks.com/topic/94823-is-this-the-right-way/#findComment-485672 Share on other sites More sharing options...
SkullzY88 Posted March 7, 2008 Share Posted March 7, 2008 I added the semi-colon after where you said too, now Im getting this error, Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in D:\hosting\member\aiim\affiliates\email.php on line 6 here is what the script looks like now <?php $con = mysql_connect("****","***","****") or die('Could not connect: ' . mysql_error()); mysql_select_db("subscribe", $con); $result = mysql_query("SELECT * FROM subscribe"); while($row = mysql_fetch_assoc($result)){ $row['email']; } ?> echo $row['email']; Link to comment https://forums.phpfreaks.com/topic/94823-is-this-the-right-way/#findComment-485686 Share on other sites More sharing options...
ChompGator Posted March 7, 2008 Author Share Posted March 7, 2008 Still the error on Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in D:\hosting\member\aiim\affiliates\email.php on line 6 Here is the script now: <?php $con = mysql_connect("mysql105.mysite4now.com","aiim","k7YuHeFv") or die('Could not connect: ' . mysql_error()); mysql_select_db("subscribe", $con); $result = mysql_query("SELECT * FROM subscribe"); while($row = mysql_fetch_assoc($result)){ $row['email']; } ?> Link to comment https://forums.phpfreaks.com/topic/94823-is-this-the-right-way/#findComment-485694 Share on other sites More sharing options...
SkullzY88 Posted March 7, 2008 Share Posted March 7, 2008 when ever i done the echo $row['email']; i giving u a hint on what u missed out copy thry this code below <?php $con = mysql_connect("******","*****","*****") or die('Could not connect: ' . mysql_error()); mysql_select_db("*****", $con); $result = mysql_query("SELECT * FROM subscribe"); //make sure you have data to show $getdata = mysql_num_rows($result); if($getdata == 0) { echo 'No information to show'; } else { while($row = mysql_fetch_assoc($result)){ echo $row['email'];//to print the results and show the information } } ?> also if this still comes up with an error change mysql_fetch_assoc to mysql_fetch_array some times that can have an affect Link to comment https://forums.phpfreaks.com/topic/94823-is-this-the-right-way/#findComment-485754 Share on other sites More sharing options...
ChompGator Posted March 7, 2008 Author Share Posted March 7, 2008 Tried that out and got this error: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in D:\hosting\member\aiim\affiliates\email.php on line 7 So I altered the code to what you see below, its not displaying errors anymore, its just displaying a blank white page, does anyone know why that is: <?php $con = mysql_connect("**","**","***") or die('Could not connect: ' . mysql_error()); mysql_select_db("login", $con); $result = mysql_query("SELECT * FROM subscribe"); if ($r = mysql_query ($result)) { while ($row = mysql_fetch_array ($r)) { echo $row['email']; } } ?> Link to comment https://forums.phpfreaks.com/topic/94823-is-this-the-right-way/#findComment-485793 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.