![]() |
|
#1
|
|||
|
|||
Query different tables in single database with phpI have this problem with php and mysql where I query a table a database and it works fine, but then i go and query another table in the same database and it won't let me (or returns nothing). On top of that, the "or die (mysql_error())" function won't return anything but it is dying after that statement. In the past, i have moved around this problem by putting everything in it's own database. Since that is, overall, a terrible idea, I would like to know how to fix this problem weather it be a setting i need to change or a piece of code i need to include.
PHP Code:
i get nothing in $post_info ( 'user' and 'post' are both tables in 'bluefirecode') |
|||
|
#2
|
||||
|
||||
Re: Query different tables in single database with phpYes, that seems very strange.
Make sure (through an echo or something) that the $post_id actually has a value set, and that an id with that value actually exists in the table. Since the second query is not failing (at the mysql_query() call), that leads me to believe that the query executed, but there were no results (which is not an error) -- and with no results, then the 2nd 'fetch_row' call will fail because of an invalid $result2 value. Maybe add this [before the line assigning $post_info] for the 2nd query attempt to see what might be happening: PHP Code:
__________________
Use the force...read the source!! WYCIWYG -- what you code is what you get! |
|
#3
|
||||
|
||||
Re: Query different tables in single database with phpQuote:
Not letting you is alot different than returning nothing Quote:
You don't have the or die in your code snippet, but I'm guessing you have tried it their before. If you aren't getting into the OR DIE block, then it would appear that you ARE passing the DB a properly formatted query. Quote:
This is your brain . You certainly don't want to do that. What you need to do is echo some key information (as TurboPT suggested). Probably the biggie would be echoing the query. Make sure that the query is populated with the values you think should be there. If it looks like what you think it should be, simply run the query on the mysql command prompt and see what it returns. It's obviously possible that the query just doesn't return anything.__________________
If practice makes perfect and nobody's perfect... why practice? Homepage: http://www.treywhite.com Blog: http://www.treywhite.com/blog.php Web Design Company: http://www.ewebproductions.com |
|
#4
|
|||
|
|||
Re: Query different tables in single database with phpAfter following all of what you said i finally fixed the problem. As it turned out i was trying to use a different database than the one that had all the info in it. (i'm in the process of merging all the separate db's into one) So on that part thanks for walking me through my stupidity
|
|
#5
|
||||
|
||||
Re: Query different tables in single database with phpQuote:
Peanut Butter Jelly Time!!! Keep in mind that a database should only contain tables that go together. Don't just put every table you have in one database for the sole purpose of having only one database.__________________
If practice makes perfect and nobody's perfect... why practice? Homepage: http://www.treywhite.com Blog: http://www.treywhite.com/blog.php Web Design Company: http://www.ewebproductions.com |
Recent GIDBlog
Once again, no time for hobbies by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| automatically assigning a number into the database from php | markyp | MySQL / PHP Forum | 2 | 01-May-2007 10:12 |
| combining 2 fields in a single mysql select query | mrjameer | MySQL / PHP Forum | 1 | 28-Sep-2006 20:38 |
| Add/Remove Database tables dynamically from workspace | abhi | MS Visual C++ / MFC Forum | 0 | 22-Jun-2005 07:10 |
| Parsing PHP code that's stored in a database. | JdS | MySQL / PHP Forum | 3 | 13-May-2004 10:15 |
| PHP MySQL query | jgnasser | MySQL / PHP Forum | 3 | 08-Apr-2004 06:42 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The