Paldo Posted May 19, 2009 Share Posted May 19, 2009 Hi I would like to ask how to select only one thing from database co I can use it later on. I have a databaze containing name, login, password, account number, balance. What I need is get only account number and store it to variable, for example $balance. How can I do this. Thanks Link to comment https://forums.phpfreaks.com/topic/158776-php-mysql-selec-help-needed/ Share on other sites More sharing options...
JD* Posted May 19, 2009 Share Posted May 19, 2009 $result = mysql_query("SELECT account_number FROM database") or die(mysql_error()); $balance = mysql_result($result, 0, "account_numer"); echo $balance Link to comment https://forums.phpfreaks.com/topic/158776-php-mysql-selec-help-needed/#findComment-837415 Share on other sites More sharing options...
Paldo Posted May 19, 2009 Author Share Posted May 19, 2009 Well tahnks I did this: $result = mysql_query("SELECT account_number FROM database") or die(mysql_error()); $balance = mysql_result($result, 0, "account_numer"); echo $balance and it's working. BUT one last thing I would like to ask. What is a correct way to send value of this $balance to another page so I can use it there???? I tried : echo'<a href="http://parobek.euweb.cz/transfer.php?t=$balance">Prevody</a>'; but when I echo t on second page it prints $balance not the value of it. Thanks Link to comment https://forums.phpfreaks.com/topic/158776-php-mysql-selec-help-needed/#findComment-837444 Share on other sites More sharing options...
JD* Posted May 19, 2009 Share Posted May 19, 2009 If you pass it through the url, you need to do this: $balance = $_GET['t']'; echo $balance Link to comment https://forums.phpfreaks.com/topic/158776-php-mysql-selec-help-needed/#findComment-837447 Share on other sites More sharing options...
Paldo Posted May 19, 2009 Author Share Posted May 19, 2009 Hey! Shame on me that I'm putting this question on you, but I just cant solve it and I'm realy desprete by now... it says: Parse error: parse error, expecting `','' or `';'' in /3w/euweb.cz/p/parobek/welcome.php on line 31 <html> <body> <?php if ($name=="admin" && $password=="adnddnd" ) { print "welcome Admin /n"; echo'<a href="http://parobek.euweb.cz/new.php">Creating new customer</a>'; echo'<a href="http://parobek.euweb.cz/zmena.php">Information update</a>'; echo'<a href="http://parobek.euweb.cz/odstran.php">to delete a customer</a>'; } else { $con = mysql_connect("mysql.webzdarma.cz","parobek","adnddnd"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("parobek", $con); $result = mysql_query("SELECT * FROM Customers WHERE Login='$meno' AND pasword='$heslo'"); while($row = mysql_fetch_array($result)) { echo $row['Name'] . " " . $row['Login']. " " . $row['Password']. " " . $row['accountID']. " " . $row['balance']; echo "<br />"; $resul = mysql_query("SELECT stav FROM Customers WHERE Login=$name ") or die(mysql_error()) ; $balance = mysql_result($resul, 0, "balance"); echo'<a href="http://parobek.euweb.cz/transfer.php?t='$balance'">Transfers</a>'; } echo $balance; mysql_close($con); } ?> </body> </html> Link to comment https://forums.phpfreaks.com/topic/158776-php-mysql-selec-help-needed/#findComment-837531 Share on other sites More sharing options...
JD* Posted May 19, 2009 Share Posted May 19, 2009 This line: echo'<a href="http://parobek.euweb.cz/transfer.php?t='$balance'">Transfers</a>'; should be echo'<a href="http://parobek.euweb.cz/transfer.php?t=$balance">Transfers</a>'; you don't need quotes around url variables Link to comment https://forums.phpfreaks.com/topic/158776-php-mysql-selec-help-needed/#findComment-837537 Share on other sites More sharing options...
Paldo Posted May 19, 2009 Author Share Posted May 19, 2009 Well thanks that worked well. I moved a bit further... Yet something always not working. As I try to finaly use the transfered variable on a target site it says: Parse error: parse error in /3w/euweb.cz/p/parobek/transfer.php on line 16 <html> <head> </head> <body> <font size="12" color="red" face="Arial, Helvetica">Zadajte cislo uctu kam previest zdroje</font> <form action="http://www.parobek.euweb.cz/transferconfirm.php" method="post"> Cislo uctu: <input type="int" name="cisuctu" /><br /> Ciastka k prevodu: <input type="int" name="prevod" /> <input type="submit" /> </form> <?php $balance = $_GET['t']'; echo $balance; ?> </body> </html> I realy don't know whats wrong with it... If you have a minute to ceck it out I would be thankfull... Link to comment https://forums.phpfreaks.com/topic/158776-php-mysql-selec-help-needed/#findComment-837554 Share on other sites More sharing options...
JD* Posted May 19, 2009 Share Posted May 19, 2009 You have an extra ' at the end of your balance variable Link to comment https://forums.phpfreaks.com/topic/158776-php-mysql-selec-help-needed/#findComment-837557 Share on other sites More sharing options...
Paldo Posted May 19, 2009 Author Share Posted May 19, 2009 Great! Thanks! But why its printig $balance instead of value a was trying to transfer from first page? Link to comment https://forums.phpfreaks.com/topic/158776-php-mysql-selec-help-needed/#findComment-837573 Share on other sites More sharing options...
JD* Posted May 19, 2009 Share Posted May 19, 2009 Sorry, I didn't see in your original code that you were echoing your link with single quotes. Change this: echo'<a href="http://parobek.euweb.cz/transfer.php?t='$balance'">Transfers</a>'; to this: echo'<a href="http://parobek.euweb.cz/transfer.php?t='.$balance.'">Transfers</a>'; Link to comment https://forums.phpfreaks.com/topic/158776-php-mysql-selec-help-needed/#findComment-837584 Share on other sites More sharing options...
Paldo Posted May 19, 2009 Author Share Posted May 19, 2009 Wow man you are some kind of genius or what ?!? Thanks a lot. A LOT! Link to comment https://forums.phpfreaks.com/topic/158776-php-mysql-selec-help-needed/#findComment-837597 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.