php-mysql integration script problem with wildcard

       
I have a forum  app which requires its database table(forum_users) be updated with user info and avatars from a table in a separate mysql databse(main site dbase with profile info).  The code works fine to update except in one area: the avatars.  The reason is that the avatars in the main profile dbase are updated periodically by members and are autoincermented in numeration each time. Therfore, some type of wildcard is required as far as I can tell.

The numeration for the jpg images look like this :  3_0_1.jpg

Upon incrementing, the numbers go up 3_0_2.jpg, 3_0_3.jpg etc etc

All variables from the primary dbase table is called for with a * and it calls for and updates all the other parameters correctly.

As for the avatars, I am trying to configure with a LIKE statement and wildcard.  The following combined code as follows for all parameters works fine in this context EXCEPT for the autoincrement problem. It updates only  a  x_0_1.jpg , where x is the user ID(which is called and transferred correctly).  The jpg files are stored in the main site /id_img/ directory.

mysql_query("update forum_users set user_password='".$line["Password"]."', user_joined='".$line["LastReg"]."', user_id='".$line["ID"]."', user_email='".$line["email"]."', user_avatar='/id_img/".$line["ID"]."_0_1.jpg' where user_name='".$line["NickName"]."'");
 
I am not a programmer, but have pieced this together for the avatar transfer alone, but it does not work.  

mysql_query("update forum_users set user_avatar= 'id_img/".$line["ID"].".jpg' where .jpg LIKE '_0_%.jpg' where user_name='".$line["NickName"]."'");  

Help!
Steve_NewbieAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

arantiusCommented:
Steve_Newbie,

I'm unsure what exactly your problem is?  If it is this statement:
mysql_query("update forum_users set user_avatar= 'id_img/".$line["ID"].".jpg' where .jpg LIKE '_0_%.jpg' where user_name='".$line["NickName"]."'");  

Then this phrase in it: "where .jpg LIKE" is invalid.
0
Steve_NewbieAuthor Commented:
Yes, I am sure it is. It certainly is not working.  Again, I am not a programmer and am just looking to tweak the code that IS working with a wildcard so that the transfer of jpg images will include all possible numerations in the area of the number just before the .jpg.  In other words, where I have tried to put a wildcard.  There is never a situation in which two jpg files will be in that table, exclusively only one (e.g.  3_0_1.jpg only;  not 3_0_2.jpg and 3_0_3.jpg etc. )
I hope I am making this clear.

S
0
Steve_NewbieAuthor Commented:
This may be a stupid combination of code, but this looks a lot like other pieces of similar working code that I called upon to create this ....umm....interesting combination...
S
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

arantiusCommented:
Like I said, I just can't figure out what you're trying to do.  What i

If you're trying to update the database record to contain the filename that is constantly changing, then you're going to have to get whatever that filename is into a PHP variable, then:

mysql_query("update forum_users set user_password='".$line["Password"]."', user_joined='".$line["LastReg"]."', user_id='".$line["ID"]."', user_email='".$line["email"]."', user_avatar='/id_img/".$line["ID"]."_".$FILENAMEHERE.".jpg' where user_name='".$line["NickName"]."'");

Where $FILENAMEHERE contains "X_Y' where x and y are the two numbers that seem to keep changing.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ZontarCommented:
>  where .jpg LIKE '_0_%.jpg' where user_name='".$line["NickName"]."'");

1. What's the name of the column you're trying to match against? The correct syntax for a LIKE clause is

WHERE column_name LIKE 'patterntomatch'

and I don't think .jpg is the name of the column, is it? If it is, it's not a good choice for one.

Multiple tests in the same query are connected using AND:

WHERE somecolumn LIKE 'patterntomatch' AND someothercolumn = 'value'
0
Steve_NewbieAuthor Commented:
Sorry for the delay and thanks for the help so far.  I am just a code challenged simpleton here.  I think I can explain what I need, modify by example, do the very basics in php and mysql, but certainly cannot write code de novo.

The sql collumn name from which the data is pulled is  Pic_0_addon and contains only a single integer of type  tinyint(3).....As noted the number autoincrements each time a user choosed to change that picture.  The integer is in the X position in the jpg name and is the ONLY one which changes when the user adds a new pic (basically it is the user's thumbnail avatar) :   _0_X.jpg  

As noted above, when it is upgraded, the old jpg and old jpg name is replaced....so, 2 replaces 1, 3 replaces 2, and so forth in the X integer part of the jpg name. The originating sql fields collumn (Pic_0_addon)  NEVER has more than one integer per user.  

I need to be able to capture the current integer, no matter what the X is, and update the other dbase field with the new jpg name.  The program then is able to recognize the jpg which is stored in the main site directory as noted above :  public/id_img/

As long as the user uploads a jpg and NEVER changes it, my integration code above works fine.  But they do, and that is my problem.

I hope this clarifies the mud a bit.

Thanks!
0
Steve_NewbieAuthor Commented:
Just to complete the description.  The user ID is the first part of the jpg name : so the complete jpg name is usually something like  145_0_X.jpg
0
Steve_NewbieAuthor Commented:
So, no one can help with this?  I thought it might be easier that this....or I am not making sense.

Help!

S
0
Steve_NewbieAuthor Commented:
Is this really that difficult or crazy of a question?  Hello out there.....still need help on this please.
Thanks.
SN
0
Steve_NewbieAuthor Commented:
??????
0
Steve_NewbieAuthor Commented:
Have not had time to work on this for a while, but here is the end result for those wondering at some point in the future.

I guess I was thinking in reverse with the thought that I could somehow put a wildcard '%' into something like  X_0_%.jpg such that the code asking for the avatar would pull in any file that looked like that, which would have been fine since there was only one possible file at one time in the table with that config.  So, the last integer was irrelevant...any one would work.

Whatever.....but as a I said, I am not a programmer, so the above suggestion was probably more "normal" and works fine with mods.  The final product was:

Filename Pic_0_addon was already in a variable and then,

mysql_query("update forum_users set user_password='".$line["Password"]."', user_region='".$line["City"]."', user_joined='".$line["LastReg"]."', user_id='".$line["ID"]."', user_email='".$line["email"]."', user_avatar='/id_img/".$line["ID"]."_0_".$line["Pic_0_addon"].".jpg' where user_name='".$line["NickName"]."'");

Word.

Thanks.
S  
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
MySQL Server

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.