|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
SELECT error: No such field - BUT query works in PHPmyadmin
So this is confusing the heck out of me and I could really use some help.
I have a MYSQL query that works when I open phpmyadmin and run the query. However when I run the query in my php page it generates the following: "DB Error: no such field" Code:
echo "SELECT * FROM Videos WHERE ShortTitle like \"$video\"<BR>";
$result =& $conn->query ("SELECT * FROM Videos WHERE ShortTitle like \"$video\"");
if (DB::isError ($result))
die ("SELECT failed: " . $result->getMessage () . "\n");
}
So my sql would be something like this: Code:
SELECT * FROM Videos WHERE ShortTitle like "settingup-using-crazyegg" Normally that works. I have about 20 records in this table that work fine, however this sql statement is no longer working from within PHP. From within SQL it works fine. I can put this SQL statement in, and run it and it works. Thanks in advance for your help! |
|
#2
|
|||
|
|||
|
This will tell you more about the problem:
die ("SELECT failed: " . $result->getMessage() . ', ' . $result->getDebugInfo() . "\n"); |
|
#3
|
|||
|
|||
|
That line of code is not working.
All I get still is: SELECT failed: DB Error: no such field There is no additional data being output and no additional data in my php error log. |
|
#4
|
|||
|
|||
|
It may be a bit newbish to suggest it but since it works in phpmyadmin and not in code... have you selected the correct database after connecting to the mysql server?
IE:mysql_select_db($dbname); Also, I'm not familiar with way you're calling queries and such but I would write it: Code:
$query = "SELECT * FROM Videos WHERE ShortTitle LIKE '$video';
$result = mysql_query($query) or die("ERROR: " . mysql_error());
Note: May be '$video%' (I don't use LIKE much :s) Seeing that your result is being checked, your error (DB Error: no such field) may refer to the result having no fields (the \" not escaping out properly?). Referring to the query itself, since it's referencing 'field' it might be worth checking the case on 'ShortTitle' as it may be giving the error as there is no such field ShortTitle to compare from. I haven't had a lot of MySQL experience yet but I hope this helps some. Makkura |
![]() |
| Viewing: Codewalkers Forums > PHP Related > PEAR Packages > SELECT error: No such field - BUT query works in PHPmyadmin |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|