Page 2 of 2

Re: Can you see if a DB field contains only a certain charac

Posted: Tue May 29, 2012 2:42 pm
by Celauran
You've copied it wrong.

Code: Select all

$query = "SELECT photos FROM property WHERE (photos REGEXP '^\\|+$' OR photos = '' OR photos IS NULL) AND id = '$row->id'";
You've got

Code: Select all

$query = mysql_query ("SELECT photos FROM property WHERE (photos REGEXP '^\\|+$' OR photos = '' OR photos IS NULL) AND id = '$row->id'");

Re: Can you see if a DB field contains only a certain charac

Posted: Tue May 29, 2012 2:50 pm
by simonmlewis
My bad!

Here's an example of what it produces:
[text]SELECT photos FROM property WHERE (photos REGEXP '^\|+$' OR photos = '' OR photos IS NULL) AND id = '16'[/text]
This section of the code does it if the photoprimary fields is NULL or just empty.
If it's not empty, then it just throws up the "Alert" script anyway. Basically stopping it deleting a field if an image is found.

The one I am looking at that shows no 'Delete' button at all, DOES have text in the 'photos' field:
[text]b1.jpg|b3.jpg|Bm 6 kitchen.jpg|BM 6 bedroom two.jpg[/text]
So it should be producing the "else" part

Code: Select all

 else 
          { 
          echo "<input type='button' onclick=
\"alert('You have PHOTOS stored.  Click Edit, delete all photos, then delete item.')\" 
value='Delete'>"; 
          }
.... should it not?

Re: Can you see if a DB field contains only a certain charac

Posted: Fri Jun 01, 2012 12:31 pm
by simonmlewis
Any other ideas?

Re: Can you see if a DB field contains only a certain charac

Posted: Mon Jun 04, 2012 1:58 pm
by tr0gd0rr
Don't you need 4 backslashes since you are in a php string and MySQL needs 2 backslashes?

Re: Can you see if a DB field contains only a certain charac

Posted: Tue Jun 05, 2012 3:06 pm
by simonmlewis
I do coz it's javascript inside PHP.