mbester Posted September 24, 2007 Share Posted September 24, 2007 Hi I'm new with PHP and have a small database that return data. I have working templates for certain sections of my website but found the following problem using a database column named Style_No of VARCAR(60). The problem is that I get the following error: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource PHP $DetailResult = mysql_query("Select Silhouette, Neckline, SleeveLength, SleeveStyle, Fabric, Embellishments, Colour_Description, Style_No from juniormaid_eden_info where Style_No = $Style_No"); while($row = mysql_fetch_array($DetailResult )) { $Style_No = $row['Style_No']; $Silhouette = $row['Silhouette']; $Neckline = $row['Neckline']; $SleeveLength = $row['SleeveLength']; $SleeveStyle = $row['SleeveStyle']; $Fabric = $row['Fabric']; $Embellishments = $row['Embellishments']; $Colour_Description = $row['Colour_Description']; }; However, this is the same code that works for another database table that are only populated with numerical values. The problem goes away when I populate the column "Style_No" with only numerical values, i.e. Style_No = 1234 but as soon as I add alphanumerical values I get the above error, e.g. Style_No = JM1234 It also doesnt work if I for example, change the value as follows Style_No = JM It seems as if the code doesnt like the alphanumerical values. Is there a problem using the above PHP code and using a value that consist of both numerical and alphanumerical values? Any help will be greatly appreciated. Thanks Mari Quote Link to comment https://forums.phpfreaks.com/topic/70435-varchar-and-warning-mysql_fetch_array-supplied-argument/ Share on other sites More sharing options...
jitesh Posted September 24, 2007 Share Posted September 24, 2007 Try this $DetailResult = mysql_query("Select Silhouette, Neckline, SleeveLength, SleeveStyle, Fabric, Embellishments, Colour_Description, Style_No from juniormaid_eden_info where Style_No = '" .$Style_No."'"); Quote Link to comment https://forums.phpfreaks.com/topic/70435-varchar-and-warning-mysql_fetch_array-supplied-argument/#findComment-353833 Share on other sites More sharing options...
mbester Posted September 24, 2007 Author Share Posted September 24, 2007 Hi I tried that line of code and get the following error now: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING Quote Link to comment https://forums.phpfreaks.com/topic/70435-varchar-and-warning-mysql_fetch_array-supplied-argument/#findComment-353846 Share on other sites More sharing options...
mbester Posted September 24, 2007 Author Share Posted September 24, 2007 Hi jitesh Sorry, I had some finger trouble and it is now working after I copied and paste exactly as you had it. THANK YOU, I really appreciate it. Best regards Mari Quote Link to comment https://forums.phpfreaks.com/topic/70435-varchar-and-warning-mysql_fetch_array-supplied-argument/#findComment-353848 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.