sherm Posted April 10, 2008 Share Posted April 10, 2008 i have a php file that works perfectly with my hosting. however, the file now needs to be transferred to my boss's host. I transfered the file and now it doesnt work. My server is running php 4.4 and his is running 4.3. Here is the part of the script that I can't figure out how to fix: while($row = mysql_fetch_array($result)) { if ($row['status'] == 'complete') { echo('You have already taken the survey'); } } Basically, this checks to see if the user has completed the survey. If they have, it echos an error message. However, on the new server it doesn't seem to check the status. Any ideas why? Link to comment https://forums.phpfreaks.com/topic/100512-simple-while-loops-doesnt-work-on-new-server/ Share on other sites More sharing options...
trq Posted April 10, 2008 Share Posted April 10, 2008 There is nothing wrong with the code you have posted. Are you sure 4result is a result resource? Link to comment https://forums.phpfreaks.com/topic/100512-simple-while-loops-doesnt-work-on-new-server/#findComment-514025 Share on other sites More sharing options...
sherm Posted April 10, 2008 Author Share Posted April 10, 2008 I would assume that it is. The exact same script runs perfectly on my host... but his godaddy hosting seems to mess it up. Link to comment https://forums.phpfreaks.com/topic/100512-simple-while-loops-doesnt-work-on-new-server/#findComment-514027 Share on other sites More sharing options...
trq Posted April 10, 2008 Share Posted April 10, 2008 I would assume that it is. Never assume, always check. Link to comment https://forums.phpfreaks.com/topic/100512-simple-while-loops-doesnt-work-on-new-server/#findComment-514029 Share on other sites More sharing options...
sherm Posted April 10, 2008 Author Share Posted April 10, 2008 Well why would it work on one host but not the next? If the $result wasnt returning anything it wouldn't work on either host... correct? Link to comment https://forums.phpfreaks.com/topic/100512-simple-while-loops-doesnt-work-on-new-server/#findComment-514048 Share on other sites More sharing options...
PFMaBiSmAd Posted April 10, 2008 Share Posted April 10, 2008 The definition in programming of assume is: "To make an ass out of u and me" It is likely that your code has no error checking, error reporting, and error recovery logic in it to get it to tell you if it did not work, what was wrong, and to prevent any following code from blindly using a nonexistent result. You would need to post your code to get any specific help with it. Link to comment https://forums.phpfreaks.com/topic/100512-simple-while-loops-doesnt-work-on-new-server/#findComment-514072 Share on other sites More sharing options...
sherm Posted April 10, 2008 Author Share Posted April 10, 2008 <?php $con = mysql_connect("xxxx", "xxxxx", "xxxxxxx"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("jlenze", $con); mysql_query("INSERT INTO resident_name (name, status) VALUES ('$name', 'incomplete')", $con); $searchtable = "SELECT name, status FROM resident_name WHERE name='$name'"; $result = mysql_query($searchtable); while($row = mysql_fetch_array($result)) { if ($row['status'] == 'complete') { echo('You have already taken the survey'); } } mysql_close($con); ?> Link to comment https://forums.phpfreaks.com/topic/100512-simple-while-loops-doesnt-work-on-new-server/#findComment-514076 Share on other sites More sharing options...
sherm Posted April 10, 2008 Author Share Posted April 10, 2008 I'm new to php coding... So I don't really know how to do proper error checks. Also, if it helps: the $name variable is pulled from an url that is loaded from a remote program... basically, the program sends an http request to "mysite.com/connect.php?name=John Doe" ... then the php file pulls the name and adds it to the database unless they have already completed the survey Link to comment https://forums.phpfreaks.com/topic/100512-simple-while-loops-doesnt-work-on-new-server/#findComment-514089 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.