gevensen
-
Posts
206 -
Joined
-
Last visited
Posts posted by gevensen
-
-
can move_uploaded_file be used to move a image from one location on the server to another
or what would be a better way?
-
ok repeat after me DOYYYYYYYYYY
i had the query right originally but used 90 DAYS instead of 90 DAY
It didnt work with days do i came up with the next query which i posted
thanks for the help
-
Im looking to search back 90 days for example but it only returns say the last 2 weeks, if i increase it i see other records but still not the full number
any ideas?
SELECT * FROM sc_income WHERE full_name = 'Smith, John' AND date >= CURRENT_DATE - '90'
-
i usually do it like this
<b>Upload successful</b><span class =span3></span><br /><a href=\"http://www.privatechatnow.com/currentwebsite/activation/activate?id=<?php echo $id; ?> \">Back</a></div>
-
Cheers for that, it has certainly tidied up my code, though if I wanted to take that information that I have got from that field and manipulate it how would I do that.
For instance. it's used to judge how many tokens someone has. If they buy 10 more tokens I need to manipulate the data to add 10 more to the total.
Is $result the variable I need to do this?
if you want the records returned use for example $num=mysql_num_rows($result); that gives you the number of rows returned
i f($num>10){ //whatever }
or even
if(mysql_num_rows($result)>10){ //whatever }
-
1st all in your query i do it like this for clarity, and if you use `` you have to use it on all not partially
hope this sends you in the right direction
$query="SELECT `Tokens` FROM `tokens` WHERE `CompNumber` ='2' "; $result = mysql_query($query); if($result) { while($row=mysql_fetch_array($result)) { echo $row[0]."<br />"; } echo "all done!<br />"; }
-
that why i printed my data to the screen i usually catch errors easily that way but it didnt show the additional whitespace
it just showed for example 'account' which looked normal not 'account
' which would look abnormal
but thanks for the heads up you mentioned it early on but i didnt have problems with any other reports for whatever reason
thanks again
-
ok i figured it out
i changed $account=$row['account']; to $account=trim($row['account']);
i guess there are newlines, it hasnt effected any other report except the SUM
thanks for the help
-
i added trim to $account=trim($row['account']);
-
I have a query that works fine on myphpadmin but does not return a value using mysql_query in php
its is a SUM function
the field is a decimal 10,2
index is set
is there something in the mysql setup i could be doing wrong it should be working
mysql_connect($servername, $dbusername, $dbpassword) or die(mysql_error()); $dbname=$_SESSION['db']; mysql_select_db($dbname) or die("CANNOT SELECT DATABASE - ". mysql_error()); $year='2009'; //$_SESSION['ytd_year']; $query="SELECT * FROM sc_business_report "; $result=mysql_query($query) or die(mysql_error()); if($result){ while($row=mysql_fetch_array($result)){ $fund=$row['fund']; $account=$row['account']; $query2="SELECT SUM( `split_amount` )AS `total` FROM `sc_expenses_transactions` WHERE `fund` = '$fund' AND `account` = '$account' AND YEAR ( `date_of_split` ) = '$year' "; $result2=mysql_query($query2) or die(mysql_error()); if($result2){ $row2=mysql_fetch_assoc($result2); echo $query2."<br />"; echo "<br />VAR DUMP<br />"; var_dump($row2); echo "<br />VAR DUMP<br />"; echo $row2['total']."<br />"; } // eof result2 mysql_free_result($result2); }// eof while } //eof result
-
TOAD free
-
i do appreciate the help i have written a number of reports on this database using the fund and account and it works?
But using sum it doesnt
I was thinking maybe a i have a localhost mysql problem but i uploaded it to my server and off wamp and i still get the same results
-
$row2=mysql_fetch_row($result2)or die(mysql_error());
FIXED
VAR DUMP
array(1) { ["total"]=> NULL }
VAR DUMP
No other error codes
ini_set("display_errors", "1"); error_reporting(E_ALL);
I pulled out the session and changed to to '2009'
The or die(mysql_error()); on the mysql_fetch_row() line of code has no meaning because mysql_fetch_row does not set a mysql_error(). The only result you would get from the or die() would be for your code to stop execution with nothing being output by that statement. Remove the or die() -
$row2=mysql_fetch_row($result2)or die(mysql_error());
It would sure help if you posted the output you are getting. What does print_r($row2); actually show? What does the following show right after the line where $query2 is being set -
var_dump($query2);
What does adding the following two lines of code immediately after your first opening <?php tag on the page show -
ini_set("display_errors", "1"); error_reporting(E_ALL);
And since you happen to be using $_SESSION variables (it pays to show us everything you are doing on the page as it can be relevant to problems you are having on a page), what does a phpinfo() statement show for the register_globals setting? And if register_globals are ON, do any of your $_SESSION variables have the same name as any of your program variables.
-
Example of output for
$result2=mysql_query($query2) or die(mysql_error()); if($result2){ $row2=mysql_fetch_assoc($result2); echo $query2."<br />"; echo "<br />VAR DUMP<br />"; var_dump($row2); echo "<br />VAR DUMP<br />"; echo $row2['total']."<br />"; } // eof result2
Sample of actual output should be 7219.35
SELECT SUM( `split_amount` )AS `total` FROM `sc_expenses_transactions` WHERE `fund` = 'General' AND `account` = '2007 Debt ' AND YEAR ( `date_of_split` ) = '2009'
VAR DUMP
array(1) { ["total"]=> NULL }
VAR DUMP
-
i rewrote a smaller portion same problem
this is the whole code
in phpmyadmin the query displays a sum
but print_r($row2); shows an empty array
if i use echo $row2[0]; i get null also
any takers?
mysql_connect($servername, $dbusername, $dbpassword) or die(mysql_error()); $dbname=$_SESSION['db']; mysql_select_db($dbname) or die("CANNOT SELECT DATABASE - ". mysql_error()); $year=$_SESSION['ytd_year']; $query="SELECT * FROM sc_business_report "; $result=mysql_query($query) or die(mysql_error()); if($result){ while($row=mysql_fetch_array($result)){ $fund=$row['fund']; $account=$row['account']; $query2="SELECT SUM( split_amount ) FROM sc_expenses_transactions WHERE fund = '$fund' AND account = '$account' AND YEAR ( date_of_split ) = '$year' "; $result2=mysql_query($query2) or die(mysql_error()); if($result2){ $row2=mysql_fetch_row($result2)or die(mysql_error()); print_r($row2); } // eof result2 mysql_free_result($result2); }// eof while } //eof result
-
and no error messages it just passes an empty value even though when i run the query on phpmyadmin i get an amount
-
its the actual code.
i am displaying results on mys screen to troubleshoot the results
It is inside that loop, which must be causing the problem because if i take it outside the loop it works
I posted the actual loop and i dont see why it shouldnt work
-
i get a result of one return row but it doesnt pass to the array for some reason?
-
yes it is but i have renamed them all??
$query="SELECT * FROM `sc_business_report` "; $result=mysql_query($query)or die(mysql_error()); while($row=mysql_fetch_assoc($result)) { $fund=$row['fund']; $account=$row['account']; print_r($row); echo "<br />"; echo $fund."-".$account."<br />"; $income_amount=0.00; $expense_amount=0.00; $query2="SELECT SUM(`amount`) FROM `sc_income_data` WHERE `fund` = '$fund' AND `account` = '$account' AND YEAR(`date`) = '$year' "; echo "INCOME QUERY : ".$query2."<br />"; $result2=mysql_query($query2)or die("error a :".mysql_error()); if($result2){ $income_row=mysql_fetch_array($result2); $income_amount=$income_row[0]; echo "Income Amount :".$income_amount."<br />"; } $query3="SELECT SUM(`split_amount`) FROM `sc_expenses_transactions` WHERE `fund` = '$fund' AND `account` = '$account' AND YEAR(`date_of_split`) = '$year' "; echo "EXPENSE QUERY : ".$query3."<br />"; $result3=mysql_query($query3)or die("error b :".mysql_error()); if($result3){ $expense_row=mysql_fetch_array($result3); $expense_amount=$expense_row[0]; } $query4="UPDATE `sc_business_report` SET `income` = '$income_amount' , `expense` = '$expense_amount' WHERE ( `fund` = '$fund' AND `account` = '$account' ) "; mysql_query($query4)or die(mysql_error()); }
-
shows 1 result i did that already
-
nope gets a error message
Notice: Undefined index: total
-
The mysql query is good
It returns a sum in phpmyadmin
but i cant seem to get the sum over to $expense_amount
the $expense_row=mysql_fetch_array($result3); comes up with an empty array?
what am i doing wrong?
$query3="SELECT SUM(`split_amount`) FROM `sc_expenses_transactions` WHERE `fund` = '$fund' AND `account` = '$account' AND YEAR(`date_of_split`) = '$year' "; $result3=mysql_query($query3)or die("error b :".mysql_error()); if($result3){ $expense_row=mysql_fetch_array($result3); $expense_amount=$expense_row[0]; }
-
Sorry I meant . . .
DELETE FROM `locations` WHERE `Apple`;
for example
DELETE FROM `locations` WHERE `word` = `Apple`;
-
theres a freeware called toad that makes complex queries for you
i find it very helpful
move_uploaded_file
in PHP Coding Help
Posted
i spoke too soon i just found copy also THANKS!