1,076,111 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?

Posts by desup Contributing to Articles being Marked Solved

Can you please provide your mysql query?
It looks fine I think.
And if not, i've little bit strange solution.
But just for last chance.

desup
Light Poster
25 posts since Jan 2012
Reputation Points: 10
Solved Threads: 5
Skill Endorsements: 0

Okay okay, so, can you send me your whole script? I will test it on my db :)

desup
Light Poster
25 posts since Jan 2012
Reputation Points: 10
Solved Threads: 5
Skill Endorsements: 0

Oh sorry, my bad, so, error can be in brackets.
Because, inside your code, you are not defining start and the end of loop, that means, you are closing mysql connection inside.
add curly brackets.
If this will not help, add

or die(mysql_query())

after each query.

EDIT: Im not sure, but my conscience is telling me, that first query is failing. :D

desup
Light Poster
25 posts since Jan 2012
Reputation Points: 10
Solved Threads: 5
Skill Endorsements: 0

You are Inserting wrong value, because you are selecting time_attedance, and inserting time
This should work

while($row=mysql_fetch_array($result)){
$time = $row['time_attedance'];
$name = $row['name'];
mysql_query("INSERT INTO history_log(name, time) VALUES(`$name`, `$time`)");
}
mysql_close($con);

try it like that

desup
Light Poster
25 posts since Jan 2012
Reputation Points: 10
Solved Threads: 5
Skill Endorsements: 0

Try to.. Just put it to the while loop:
(If I understand, $j is something like index, (staring with 0, and getting bigger)right?
so do it like this:

$j = 0;
$count_to = count($arr_to);
$count_from = count($arr_from);
while($j !== $count_to && $j !== $count_from){
    if($dateall>=$arr_from[$j] && $dateall<=$arr_to[$j]) // something like a loop
    {
    $calendar .= '<td class="reservation"><span title="reservation" id="id'.$year.$month.$day.'">'.$day.'</span></td>';
    ...
}
$j++;
}
desup
Light Poster
25 posts since Jan 2012
Reputation Points: 10
Solved Threads: 5
Skill Endorsements: 0

Im not sure if I understand you, but:
if I do, try to make a while loop an start inserting.

$con = mysql_connect("localhost","sample","sample");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
 
mysql_select_db("logging", $con);
 
 
 
$result = mysql_query("SELECT `members`.`name`,`time_attendance`.`time` FROM members\n"
. "LEFT JOIN `log_time`.`time_attendance` ON `members`.`code` = `time_attendance`.`code` LIMIT 0, 30");
while($row=mysql_fetch_array($result)){
	$time = $row['time_attedance'];
	$name = $row['name'];
mysql_query("INSERT INTO history_log(name, time) VALUES(`$name`, `$time`)");
}

I think this will work. But I didn't test it.
NOTE: This may be really slow, because it will practically create 30 queries, there is one thing that can wok too:

Im thinking about the way how to make it quicker, I will tell you If I have found something

desup
Light Poster
25 posts since Jan 2012
Reputation Points: 10
Solved Threads: 5
Skill Endorsements: 0

Didn't tested it, but I think, you are missing quotes, try this:

$points = 5;
$query2 = "UPDATE `Cust` SET points = points + '$points' WHERE name = '$name'";
$result = mysql_query($query2);

Note: Now I have tested it, its working :)

desup
Light Poster
25 posts since Jan 2012
Reputation Points: 10
Solved Threads: 5
Skill Endorsements: 0

Again, there shouldn't be any brackets around Post Variables.
Maybe its not an error, but It doesn't make a sense.
Try to change it to:

$username= $_POST['username'];
$password= $_POST['password'];
desup
Light Poster
25 posts since Jan 2012
Reputation Points: 10
Solved Threads: 5
Skill Endorsements: 0
 
© 2013 DaniWeb® LLC
Page rendered in 0.0753 seconds using 2.56MB