Jump to content

Recommended Posts

Posted

Hello All

 

I must say I am impressed with TCH. Very nice.

 

I am using php/mysql. My question involves the sql query in my .php file receiving the info passed from html file. Now this query works

 

>$result = mysql_query ("SELECT column_1
             FROM table_1
             WHERE id LIKE '".$id."'");

 

This works fine. I pass an id of 1 and the correct table row prints.

 

Now, if I am using multiple tables (see below)- I get error messages. Below is based off of what I am trying to do. I tried to replicate the code I am using as best I could- w/o actually revealing names of tables, etc.

 

>$result = mysql_query ("SELECT column 1, column 2, column 3
             FROM table 1, table 2, table 3
             WHERE id = '".$id.2"'
             AND id = '".$id.3."'
             AND id.3 = '".$1."'
             ORDER BY column 1");

 

Can PHP read spaces in table names?

Posted

It's generally a bad idea to have spaces in your tables names, but I believe it can be done by using back ticks (`) in the query.

 

>$result = mysql_query ("SELECT `column 1`, `column 2`, `column 3`
             FROM `table 1`, `table 2`, `table 3`
             WHERE id = '".$id.2"'
             AND id = '".$id.3."'
             AND id.3 = '".$1."'
             ORDER BY `column 1`");

 

You could give that a try.

Join the conversation

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

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

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