littlepeg Posted September 10, 2007 Share Posted September 10, 2007 Hi, everybody. :)I met a problem and hope you can help me. Any help will be appreciated. I developed my first php website on my computer and tested it by using my university web domain, and it worked fine. However, when I upload this website to the other web domain that I applied. One of my web page cannot work properly, and shows error message: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/adtsfxfg/public_html/edit_user1.php on line 236. The codes are as follows: $query = "SELECT user_name, first_name, last_name, address, postcode, tel, email, agreetolist FROM users WHERE user_id=$id"; $result = @mysql_query ($query); // Run the query. [color=red]if (mysql_num_rows($result) == 1) { // Valid user ID, show the form.[/color] // Get the user's information. $row = mysql_fetch_array ($result, MYSQL_NUM); Would you please tell me why it works on one web domain but can't work on the other web domain. And how can I solve this problems. Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/68697-solved-error-message/ Share on other sites More sharing options...
magnetica Posted September 10, 2007 Share Posted September 10, 2007 What exactly did you upload? Just the PHP file? Did you remember to setup the database and change the connection settings if necessary Quote Link to comment https://forums.phpfreaks.com/topic/68697-solved-error-message/#findComment-345335 Share on other sites More sharing options...
MadTechie Posted September 10, 2007 Share Posted September 10, 2007 change $result = @mysql_query ($query); // Run the query. to $result = mysql_query ($query) or die(mysql_error()); // Run the query. this should show a more useful error Quote Link to comment https://forums.phpfreaks.com/topic/68697-solved-error-message/#findComment-345338 Share on other sites More sharing options...
littlepeg Posted September 10, 2007 Author Share Posted September 10, 2007 I upload all the files for the website, and it connected to the database and most of the web pages works fine, except this one. :'( Quote Link to comment https://forums.phpfreaks.com/topic/68697-solved-error-message/#findComment-345340 Share on other sites More sharing options...
MadTechie Posted September 10, 2007 Share Posted September 10, 2007 can you try my post above and post the results Quote Link to comment https://forums.phpfreaks.com/topic/68697-solved-error-message/#findComment-345341 Share on other sites More sharing options...
littlepeg Posted September 10, 2007 Author Share Posted September 10, 2007 Hi MadTechie, thank you for your reply. I tried to change the code to what you suggested. The error message is the same: "Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/adtsfxfg/public_html/edit_user1.php on line 236". :'( Quote Link to comment https://forums.phpfreaks.com/topic/68697-solved-error-message/#findComment-345348 Share on other sites More sharing options...
MadTechie Posted September 10, 2007 Share Posted September 10, 2007 Humm you didn't get an extra message ie Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in also you did use exaclty what i posted (removing the @ as well) can you post what the following outputs $query = "SELECT user_name, first_name, last_name, address, postcode, tel, email, agreetolist FROM users WHERE user_id=$id"; echo $query; $result = mysql_query ($query) or die(mysql_error()); // Run the query. $x = mysql_num_rows($result); if ($x == 1) { // Valid user ID, show the form. // Get the user's information. $row = mysql_fetch_array ($result, MYSQL_NUM); Quote Link to comment https://forums.phpfreaks.com/topic/68697-solved-error-message/#findComment-345357 Share on other sites More sharing options...
MadTechie Posted September 10, 2007 Share Posted September 10, 2007 as a side note, i assume you have the <?php $link = mysql_connect("localhost", "mysql_user", "mysql_password"); mysql_select_db("db", $link); ?> above the code posted Quote Link to comment https://forums.phpfreaks.com/topic/68697-solved-error-message/#findComment-345361 Share on other sites More sharing options...
littlepeg Posted September 10, 2007 Author Share Posted September 10, 2007 Hi MadTechie, I just noticed I put the code you suggested in the wrong place. I changed it in the right place now and the error is: Unknown column 'email' in 'field list'. Quote Link to comment https://forums.phpfreaks.com/topic/68697-solved-error-message/#findComment-345366 Share on other sites More sharing options...
MadTechie Posted September 10, 2007 Share Posted September 10, 2007 check the database for the field "email", then either add it or change it to email OR change the query to the one from the database Quote Link to comment https://forums.phpfreaks.com/topic/68697-solved-error-message/#findComment-345368 Share on other sites More sharing options...
littlepeg Posted September 10, 2007 Author Share Posted September 10, 2007 Hi MadTechie, it works now. Silly mistake. Thank you very much. :) Quote Link to comment https://forums.phpfreaks.com/topic/68697-solved-error-message/#findComment-345371 Share on other sites More sharing options...
MadTechie Posted September 10, 2007 Share Posted September 10, 2007 your welcome as a note prefixing the @ omits the error (so use wisely) also the or die(mysql_error()) is VERY useful, keep them inmind, can you click solved (bottom left) if all is well Quote Link to comment https://forums.phpfreaks.com/topic/68697-solved-error-message/#findComment-345374 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.