Jump to content

[SOLVED] Syntax help Needed should be simple.. Please help


spdwrench

Recommended Posts

I am having some trouble with mysql sytanx

 

I need to update a table..

 

the table is phpbb3_config

 

it has 3 fields

 

config_name

 

config_value

 

is_dynamic

 

I need to use a

 

sql=" >>>>>"

 

how would I insert a variable called $user into config_value where config_name is newest_user

 

also need to insert newest user ID from a variable $newid

 

need to insert the user id into config_value where config_name is newest_user_id

 

Please help me with the syntax I am new to mysql but understand a bit...

 

the table and fields already exist I just need to write the new values from the variables.

 

can I do this with one querry?

 

thanks for any help on this in advance..

 

Paul

Link to comment
Share on other sites

Yes you can

 

 

INSERT INTO phpbb3_config (
'User_Id',
`config_name` ,
`config_value` ,
`is_dynamic`
)
VALUES (
'$newid','' , '$user', ''
) WHERE config_name='newest_user' AND config_id='new_userid';

 

This is the way to insert but your values are confusing, same value in 2 fields  ??? please check

Link to comment
Share on other sites

thanks for the help

 

guys I got it working

 

and your right the 2 values should not be the same

 

but I cheated a little because it is only a totaly member count and does not need to be exact..

 

Paul

 

this is what I ended up doing

 

$sql="UPDATE phpbb3_config SET config_value ='$login'  WHERE config_name ='newest_username' ";
		q($sql);
		$sql="UPDATE phpbb3_config SET config_value ='$phpbb_userid'  WHERE config_name ='num_users' ";
		q($sql);
		$sql="UPDATE phpbb3_config SET config_value ='$phpbb_userid'  WHERE config_name ='newest_user_id' ";
		q($sql);

 

if you have some better code to put it all into one query please post... I am a little unpolished but I got it to work :)

 

Paul

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.