calmchess Posted December 23, 2007 Share Posted December 23, 2007 I'm trying to fetch data from a row using a return statment......see code below.....but the column data doesn't become available for me to use .......what am i doing wrong?. BTW I need to use the return statment because my script is making multiple calls to the mySQL server based on what function gets called also once selected i need to pass the $newRef data that was processed to another function hence the test1() function call below.....will somebody plz help me learn this?? <?php function test(){ $query = "SELECT refNum FROM login WHERE username = 'admin'"; $row = mysql_fetch_row($query); $newRef = $row[0]+=1; echo $newRef; global $conn test1($newRef); return mysql($query,$conn); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/82961-fetch-row-slot-question/ Share on other sites More sharing options...
nevesgodnroc Posted December 23, 2007 Share Posted December 23, 2007 could you be more specific about what you are trying to do? the code you posted is a little confusing as to what its purpose is. are to trying to dynamically generate a query to run in another section of code? Quote Link to comment https://forums.phpfreaks.com/topic/82961-fetch-row-slot-question/#findComment-422006 Share on other sites More sharing options...
calmchess Posted December 23, 2007 Author Share Posted December 23, 2007 well there are 3 functions that fire depending on whether or not the user was allowed to login....on successful login i need to query a specific slot in the database so i can do some processing on the stored value then update that value after the processing is complete all inserts updates queries .etc are fired when the function returns some query values.....I don't have a problem updating and inserting information from function to function but i do have a problem using mysql_fetch_row to fetch already exsisting data that i want to pass between functions. I have it working by using mysql_fetch_row from the root of the application but its fetching that data long before It needs to be used ....I was hoping to fetch data when a specific function fires without having to create a brand new connection to the mysql server hence the need to fetch data using return parameters. Quote Link to comment https://forums.phpfreaks.com/topic/82961-fetch-row-slot-question/#findComment-422031 Share on other sites More sharing options...
calmchess Posted December 24, 2007 Author Share Posted December 24, 2007 *bump* Quote Link to comment https://forums.phpfreaks.com/topic/82961-fetch-row-slot-question/#findComment-422337 Share on other sites More sharing options...
nevesgodnroc Posted December 29, 2007 Share Posted December 29, 2007 sorry it took me so long to get back to you, holidays can be quite demanding around my house. it sounds like what you are saying is that depending on how your processing turns out on that variable/variables that you retrieved in the succesful login query you would like to process another query that is dependent on those values or rather the outcome of your processing script. If this is so then it sounds like you could use a a main function that contains your always processed query upfront and set up a switch case staement after that that is dependent on your returned value. this way your returned value from your first query will already be inside the function and be redily available to be passed to your conditional function list inside the switch statement. Hope this helps otherwise you could post your code with some remarks better detailing what you are tring to do. But hopefully you already figured it out. since it took so long for me to reply. Quote Link to comment https://forums.phpfreaks.com/topic/82961-fetch-row-slot-question/#findComment-425549 Share on other sites More sharing options...
PFMaBiSmAd Posted December 30, 2007 Share Posted December 30, 2007 The posted code has no mysql_query() in it. When learning php, developing php code, or troubleshooting php code, check your web server log for errors or turn on full php error reporting to get php to help you. In this case, the mysql_retch_row() function call is generating an error that would have helped you find that no query was being executed. Quote Link to comment https://forums.phpfreaks.com/topic/82961-fetch-row-slot-question/#findComment-425562 Share on other sites More sharing options...
nevesgodnroc Posted December 30, 2007 Share Posted December 30, 2007 yeah your right I guess I didnt see that before I was to cought up on figuring out exactly what was trying to be achieved in the script. also I have had problems with the fetch_row function and I use the fetch_array instead. then you can return the array of field values. Quote Link to comment https://forums.phpfreaks.com/topic/82961-fetch-row-slot-question/#findComment-426042 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.