Jump to content

Find and replace not working...WTF?


chrisis11

Recommended Posts

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

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.

<?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?

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

 

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.