473,387 Members | 1,420 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

No "$results" from query on Godaddy DB.. Solved it thanks!..

bugboy
160 100+
[this problem solved already see next post]

Hi i'm a beginner at php and my simple web query page doesn't work.. i swear i had it working at one point but now i've come back to it it doesn't.

• My form works

• My DB connection works

• My query works in my client... so it should work here. It has the right DB and all the right table names... i've only changed the word = 'myword' to word = '$word' so it will use the form value instead.

• My while loop doesn't return results.. it goes to the "else { echo 'Bad Search';"... but i can't see anything wrong with it :( no error messages... I'm stumped...

[PHP]<?php

$word = $_REQUEST['word'];

echo '<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td></td>
<td><form action="find.php" method="get">
<p><font color="666666" face="Arial" size="3"><b>Find</b></font>
<input type="text" name="word" size="30" maxlenght="30" />
<input type="submit" name="Get" value="Go"/></p>
</form></td>
</tr>
</table>
';

require_once ('mysql_connect.php');

$query = "SELECT c.cid as ID, c.title as title FROM s
INNER JOIN c
ON s.cID = c.cID
AND s.wID = (SELECT wid FROM w WHERE word = '$word')";

$result = @mysql_query ($query);

if ($result) {

while ($row = mysql_fetch_array ($result, MYSQL_ASSOC)) {

echo '<table><tr><td align="left">' . $row['ID'] . '</td></tr><tr><td align="left">' . $row['title'] . '</td></tr></table>';

}

mysql_free_result ($result);

} else { echo 'Bad Search';

}

mysql_close();

?>[/PHP]
Oct 8 '07 #1
2 1811
bugboy
160 100+
Ok I've figured it out.. I'm using Godaddy so i need to specify the DB name when referencing a table or column in my query.

DB.table.column not just table.column

I don't know if this is standard or whether this is a Godaddy quirk..!?!

Thanks!
Oct 8 '07 #2
Atli
5,058 Expert 4TB
Glad you solved your problem!

Strictly speaking, all table and column references should be written: "db.tbl.col", but MySQL provides shortcuts that allow you to leave out the database name and the table name.

The mysql_select_db() function acts as a 'USE' statement, allowing you to leave out the database name in your queries. So does the fourth parameter in the mysqli_connect() function (or the mysqli class constructor).

If you do not specify a table name in you queries, MySQL will automatically try to find the table your columns belong to, but if two or more tables share a column name, the query fails with an error, that is unless you specify the table name.
Oct 8 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: joe | last post by:
Can anyone help me out by either telling me how to get to the result i need or by pointing me to some documentation about the following question: A certain query to a database give me eg 100...
10
by: ZafT | last post by:
Thanks in advance for any tips that might get me going in the right direction. I am working on a simple exercise for school that is supposed to use read to read a file (about 10 MB). I am...
3
by: Dmitry Jouravlev | last post by:
Hi, I have a number of C++ solutions in Visual Studio .NET and when i compile them using "Whole Program Optimization", certain projects report a LNK1171 error saying that c2.dll could not be...
0
by: sagarp86 | last post by:
How to lock / deactivate "Refresh" and "Back" button on browser. Problem is in voting application. Once we click for a vote application goes to next page and increament one vote in the database....
1
by: patelxxx | last post by:
How to display PERL coding "Results" on webpages? What I'm trying to do is to display the result of the following PERL code on to a webpage and its not working. What can I do? ...
6
by: Elvis123 | last post by:
I want to "merge" the results of two queries: select DATE,CUSTOMER_ID from DB1 select DATE,CUSTOMER_ID from DB2 Then I want to be able to count the number of customers for each date in the...
7
by: ankitoshniwal | last post by:
Hello, I have been having this problem for the whole day today, so even after i googled for the solution i was not able to get one, so i had to post to this forum. I had checked the solutions...
3
by: =?Utf-8?B?UGF1bCBIYWxl?= | last post by:
Moving all User Controls to a single directory has solved my problem - Thanks Eliyahu. That said, I still got one Circular ref error yesterday, rebuilt again and the build was fine? Far far...
1
by: Jenniferdb2 | last post by:
Hello All, create table a (i int); create table b(i int); insert into a values(1); ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.