/    Sign up×
Community /Pin to ProfileBookmark

I have developed a live help program using ajax with php.

i have got it working as i want except i’ve noticed something strange.
i can chat the the operator fine but i can’t say the same thing twice.

this is how i send the message:

[code]
function sendAdmin(idx)
{
var url = “sendAdmin.php?id=”;
var desc = document.getElementById(idx).value;
http.open(“GET”, url + idx + “&desc=” + desc, true);
http.send(null);
document.getElementById(idx).value = “”;
}
[/code]

so that is sending the id of the chat textbox and whatever it contained to sendAdmin.php

in sendAdmin i simply write the info to the db:

[code]
<?php
include(“dbinfo.inc.php”) ;

$idFull = $_GET[‘id’] ;
$desc = $_GET[‘desc’] ;

list($msg, $id, $parent) = split(‘-‘, $idFull) ;

$sql = “INSERT INTO log (LogID, ClientID, `Message`, `TimeStamp`, `Parent`) VALUES (NULL, $id, ‘$desc’, CURRENT_TIMESTAMP, ‘$parent’)”;

mysql_query($sql) ;
?>
[/code]

its pretty basic, but if i enter “hello” twice it won’t show the second time, it definately not a db problem because i changed what it is writing to the db and it can add the message no problem.
also if i write “hello” then something else and try “hello” again it still doesn’t write.

i’m pretty sure the sendAdmin function in my js file is ignoring it if it has the same desc.

can anyone shed any light?

Cheers guys

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@Sid3335authorMay 22.2006 — I changed my query to not bother putting a NULL value into the db:

from this:
<i>
</i>$sql = "INSERT INTO log (LogID, ClientID, <span><code>Message</code></span>, <span><code>TimeStamp</code></span>, <span><code>Parent</code></span>) VALUES (NULL, $id, '$desc', CURRENT_TIMESTAMP, '$parent')";


tothis:
<i>
</i>$sql = "INSERT INTO log (ClientID, <span><code>Message</code></span>, <span><code>TimeStamp</code></span>, <span><code>Parent</code></span>) VALUES ($id, '$desc', CURRENT_TIMESTAMP, '$parent')";


i then printed out the query, and the query changed for all the new messages i was inputting, but i noticed that when i put in a repeated message again, its prints the old query. so it hasn't updated.

this is really annoying me, doesn't anyone have any ideas?
×

Success!

Help @Sid3335 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...