Jump to content

fetch row slot question


calmchess

Recommended Posts

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);

}

?> 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.