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(); } ?> Link to comment https://forums.phpfreaks.com/topic/95094-semi-colons/ 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? Link to comment https://forums.phpfreaks.com/topic/95094-semi-colons/#findComment-487089 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 ';' Link to comment https://forums.phpfreaks.com/topic/95094-semi-colons/#findComment-487092 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. Link to comment https://forums.phpfreaks.com/topic/95094-semi-colons/#findComment-487095 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. Link to comment https://forums.phpfreaks.com/topic/95094-semi-colons/#findComment-487097 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? Link to comment https://forums.phpfreaks.com/topic/95094-semi-colons/#findComment-487100 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. Link to comment https://forums.phpfreaks.com/topic/95094-semi-colons/#findComment-487105 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 Link to comment https://forums.phpfreaks.com/topic/95094-semi-colons/#findComment-487110 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 } Link to comment https://forums.phpfreaks.com/topic/95094-semi-colons/#findComment-487155 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.