Jump to content

using $action in a string


brown2005

Recommended Posts

$action = $_GET['action'];

 

$url_sql = mysql_query("SELECT * FROM z_sponsors_adverts_hits_'.$action.' WHERE sponsors_adverts_hits_'.$action.'_type='0' AND sponsors_adverts_hits_'.$action.'_user='$config_ip' AND sponsors_adverts_hits_'.$action.'_advert='$website_id'", $connection);

 

$url_rows = mysql_num_rows($url_sql);

 

echo"rows = $url_rows";

 

like that?

Link to comment
Share on other sites

a tip, when you have simple strings: $action , and having double quotations, you dont have to stop the quotation using '..', instead, simply place them like:

"SELECT * FROM z_sponsors_adverts_hits_$action WHERE sponsors_adverts_hits..."

as well as leave out the ; symbol, you dont need those in the query, it think thats about it...

 

EDITED, do you have to do this:

"SELECT * FROM {$action} WHERE {$action}_..."?

i thought $action would work with "

Ted

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.