ChompGator Posted March 8, 2008 Share Posted March 8, 2008 I have a script here that lists email addresses I have stored in my database, what I want to do is separate them all with a semi colon, but Im unsure what to add to my script to get it to do that, anyone know? Heres the script: - Thanks! <?php $con = mysql_connect("***","****","****") or die('Could not connect: ' . mysql_error()); if (mysql_errno()) { echo 'Connect error: ' . mysql_error(); } mysql_select_db("login", $con); $result = mysql_query("SELECT * FROM subscribe"); if (! mysql_errno()) { while($row = mysql_fetch_assoc($result)){ echo $row['email']; } } else { echo 'Query error: ' . mysql_error(); } ?> Quote Link to comment Share on other sites More sharing options...
MikeL Posted March 8, 2008 Share Posted March 8, 2008 <?php $myEmails = new array(); while( $row = mysql_fetch_assoc($result)){ $myEmails[] = $row['email']; } echo implode(':', $myEmails); ?> is that what you're trying to do? Quote Link to comment Share on other sites More sharing options...
ChompGator Posted March 8, 2008 Author Share Posted March 8, 2008 Well Im trying to separate the email addresses with a semi-colon ';' Quote Link to comment Share on other sites More sharing options...
MikeL Posted March 8, 2008 Share Posted March 8, 2008 hahaha.... oops... well switch out the colon with the semicolon hahahaha http://us2.php.net/manual/en/function.implode.php implode joins an array of strings by a specified delimiter and returns the joined string. Quote Link to comment Share on other sites More sharing options...
ChompGator Posted March 8, 2008 Author Share Posted March 8, 2008 haha, Ok, I will Ill post here if I get any errors, 1 second. Quote Link to comment Share on other sites More sharing options...
ChompGator Posted March 8, 2008 Author Share Posted March 8, 2008 Error is: Parse error: parse error, unexpected T_ARRAY, expecting T_STRING or T_VARIABLE or '$' in d:\hosting\member\aiim\affiliates\email3.php on line 10 Here is what the new script looks like: <?php $con = mysql_connect("****","***","****") or die('Could not connect: ' . mysql_error()); if (mysql_errno()) { echo 'Connect error: ' . mysql_error(); } mysql_select_db("login", $con); $result = mysql_query("SELECT * FROM subscribe"); if (! mysql_errno()) { $myEmails = new array(); while( $row = mysql_fetch_assoc($result)){ $myEmails[] = $row['email']; } echo implode(';', $myEmails); ?> Any tips? Quote Link to comment Share on other sites More sharing options...
MikeL Posted March 8, 2008 Share Posted March 8, 2008 oops haha.. get rid of the 'new' in the array sorry i didn't really test it. Quote Link to comment Share on other sites More sharing options...
ChompGator Posted March 8, 2008 Author Share Posted March 8, 2008 Parse error: parse error, unexpected $end in d:\hosting\member\aiim\affiliates\email3.php on line 17 Problem is, there isn't 17 lines Quote Link to comment Share on other sites More sharing options...
MikeL Posted March 8, 2008 Share Posted March 8, 2008 you need to close the if statement with } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.