chrisis11 Posted January 3, 2010 Share Posted January 3, 2010 Guys, why is this not working? <?php // Make a MySQL Connection $conn = mysql_connect("localhost", "username", "password") or die(mysql_error()); UPDATE _email SET email_list_subscribers = REPLACE(email_list_subscribers, '0' , '1'); ?> I get a parse error on line 4? Ignore the _admin, it did have my domain on the begining, but wasn't sure if it was allowed, so I removed it... I don't see anything wrong with this... Link to comment https://forums.phpfreaks.com/topic/187062-find-and-replace-not-workingwtf/ Share on other sites More sharing options...
RaythMistwalker Posted January 4, 2010 Share Posted January 4, 2010 you didnt actually send the MySQL query. <?php // Make a MySQL Connection $conn = mysql_connect("localhost", "username", "password") or die(mysql_error()); $qry="UPDATE _email SET email_list_subscribers = REPLACE(email_list_subscribers, '0' , '1')"; $result=mysql_query($qry); if (!$result) { echo "Query Failed"; } ?> Try that and if it doesn't work it will return the Query Failed. Link to comment https://forums.phpfreaks.com/topic/187062-find-and-replace-not-workingwtf/#findComment-987821 Share on other sites More sharing options...
chrisis11 Posted January 4, 2010 Author Share Posted January 4, 2010 Query Failed I got a Query Failed What does this mean is going wrong? Chris Link to comment https://forums.phpfreaks.com/topic/187062-find-and-replace-not-workingwtf/#findComment-987823 Share on other sites More sharing options...
RaythMistwalker Posted January 4, 2010 Share Posted January 4, 2010 <?php ini_set('display_errors', 'on'); error_reporting(E_ALL); // Make a MySQL Connection $conn = mysql_connect("localhost", "username", "password") or die(mysql_error()); $qry="UPDATE _email SET email_list_subscribers = REPLACE(email_list_subscribers, '0' , '1')"; $result=mysql_query($qry) or trigger_error('Query error! Query: <pre>'.$qry.'</pre>Reason: ' . mysql_error()); if (!$result) { echo "Query Failed"; } ?> What does this return? Link to comment https://forums.phpfreaks.com/topic/187062-find-and-replace-not-workingwtf/#findComment-987825 Share on other sites More sharing options...
chrisis11 Posted January 4, 2010 Author Share Posted January 4, 2010 Notice: Query error! Query: UPDATE #hidden#_email SET email_list_subscribers = REPLACE(email_list_subscribers, '0' , '1') Reason: No database selected in /home/#hidden#/public_html/test.php on line 7 Query Failed Thats what your code returned. I don't understand though, there is a database being selected Chris Link to comment https://forums.phpfreaks.com/topic/187062-find-and-replace-not-workingwtf/#findComment-987830 Share on other sites More sharing options...
RaythMistwalker Posted January 4, 2010 Share Posted January 4, 2010 ok found it here: <?php ini_set('display_errors', 'on'); error_reporting(E_ALL); // Make a MySQL Connection $conn = mysql_connect("localhost", "username", "password") or die(mysql_error()); @mysql_select_db(DATABASE HERE) or die( "Unable to select database"); $qry="UPDATE _email SET email_list_subscribers = REPLACE(email_list_subscribers, '0' , '1')"; $result=mysql_query($qry) or trigger_error('Query error! Query: <pre>'.$qry.'</pre>Reason: ' . mysql_error()); if (!$result) { echo "Query Failed"; } ?> You were selecting table but not database. Change DATABASE HERE to database name Link to comment https://forums.phpfreaks.com/topic/187062-find-and-replace-not-workingwtf/#findComment-987833 Share on other sites More sharing options...
chrisis11 Posted January 4, 2010 Author Share Posted January 4, 2010 Ahhh I had got myself into the muddle, I removed that earlier, becuase I had put it in the UPDATE code, but then i had put the table in the feild placeholder and so on, and oh my dear god it was a mess, All my fault Thankyou for pointing it out though. Chris Link to comment https://forums.phpfreaks.com/topic/187062-find-and-replace-not-workingwtf/#findComment-987840 Share on other sites More sharing options...
RaythMistwalker Posted January 4, 2010 Share Posted January 4, 2010 no problem glad to help ~Rayth Link to comment https://forums.phpfreaks.com/topic/187062-find-and-replace-not-workingwtf/#findComment-987841 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.