-
Posts
332 -
Joined
-
Last visited
Everything posted by sasori
-
ah yes sir, am not yet on the javascript part. i need to make this work first before i jump to the js stuff.. i haven't get rid of the auto download of the chat.php file yet LOL ..btw, my hosting account is free also but they have rules as such
-
none sir, my webhosting account doesn't allow ajax chat..actually this code isn't fully complete yet, it's supposed to be an ajax stuff
-
no, i just created it today, and eventually completed it..it's the first time i tested it. and it is behaving real bad.. i know i might sound lame, but..did you try the same code in your local server sir ?
-
changing the submit button didn't helped at all .. hmmmn...any other idea ?
-
yeah, i tried in I.E(,, and it does the same thing too, i didn't alter anything in the chat.php file, only the chat.class.php but no, am 101% sure all my files got .php extension except for the test.html ofcourse. any idea now why chat.php is being downloaded when form is submitted ?
-
weird..i just commented the require_once('error_handler.php'); from the chat.class.php file then i refresh my browser and submitted the data...yeah it saves the data in the db but ff is still prompting me to download the chat.php file LOL,, anyway to solve this ?
-
ok, so I added error_reporting(0); right at the top of the chat.php file this time, when i click the submit button of the html file firefox is downloading the script LOL, wtf
-
here's the screen shot of the error I don't really know what's going on here's the chat.php code <?php require_once("chat.class.php"); $mode = $_POST['mode']; $id = 0; $chat = new Chat(); if($mode == 'SendAndRetrieveNew') { $name = $_POST['name']; $message = $_POST['message']; $color = $_POST['color']; $id = $_POST['id']; if($name != '' && $message != '' && $color != '') { $chat->postMessage($name,$message,$color); } } elseif($mode == 'DeleteAndRetrieveNew') { $chat->deleteMessages(); } elseif($mode == 'RetrieveNew') { $id = $_POST['id']; } if(ob_get_length()) ob_clean(); header('Expires: Mon, 26 July 1997 05:00:00 GMT'); header('Last-Modified: '. gmdate('D, d M Y H:i:s'). 'GMT'); header('Cache-Control: no-cache, must-revalidate'); header('Pragma: no-cache'); header('Content-Type: application/json'); echo json_encode($chat->retrieveNewMessages($id)); ?> and here's the chat.class.php <?php require_once('config.php'); require_once('error_handler.php'); class Chat { private $mMysqli; function __construct() { $this->mMysqli = new mysqli(DB_HOST,DB_USER,DB_PASS,DB_DATABASE); } public function __destruct() { $this->mMysqli->close(); } public function deleteMessages() { $query = 'TRUNCATE TABLE chat'; $result = $this->mMysqli->query($query); } public function postMessage($name,$message,$color) { $name = $this->mMysqli->real_escape_string($name); $message = $this->mMysqli->real_escape_string($message); $color = $this->mMysqli->real_escape_string($color); $query = 'INSERT INTO chat(posted_on, user_name,message,color)'; $query .= 'VALUES(NOW(),"$name","$message","$color")'; $result = $this->mMysqli->query($query); } public function retrieveNewMessages($id=0) { $id = $this->$mMysqli->real_escape_string($id); if($id>0) { $query = 'SELECT chat_id, user_name, message, color, DATE_FORMAT(posted_on, "%Y-%m-%d %H:%i:%s") AS posted on '. 'FROM chat where chat_id > '. $id . 'ORDER BY chat_id ASC'; } else { $query = 'SELECT chat_id, user_name, color, posted_on FROM'. '{SELECT chat_id, user_name, message, color, '. 'DATE_FORMAT(posted_on,"%Y-%m-%d %H:%i:%s) AS posted_on'. 'FROM chat '. 'ORDER BY chat_id DESC'. 'LIMIT 50) AS Last50'. 'ORDER BY chat_id ASC'; } $result = $this->mMysqli->query($query); $response = array(); $response['clear'] = $this->isDatabaseCleared($id); $response['messages'] = array(); if($result->num_rows) { while($row = $result->mysqli_fetch_array(MYSQLI_ASSOC)) { $message = array(); $message['id'] = $row['chat_id']; $message['color'] = $row['color']; $message['name'] = $row['user_name']; $message['time'] = $row['posted_on']; $message['message'] = $row['message']; array_push($response['messages'],$message); } $result->close(); } return $response; } private function isDatabaseCleared($id) { if($id > 0) { $check_clear = 'SELECT count(*) old FROM chat where chat_id <= $id'; $result = $this->mMysqli->query($check_clear); $row = $result->fetch_array(MYSQLI_ASSOC); if($row['old'] == 0) return 'true'; return 'false'; } return 'true'; } } ?> and here's the html page <html> <head> <title>testing chat.php</title> </head> <body> <form action="chat.php" method="post"> Mode: <input type="text" name="mode" size="50" value="SendAndRetrieveNew" /> <br /> Name: <input type="text" name="name" size="50" /> <br /> Message: <input type="text" name="message" size="50" /> <br /> Color: <input type="text" name="color" size="50" value="#000000"/> <br /> ID: <input type="text" name="id" size="50" /> <br /> <input type="submit" /> </form> </body> </html> and here's my error_handler.php <?php set_error_handler('error_handler',E_ALL); function error_handler($errNo,$errStr,$errFile,$errLine) { if(ob_get_length()) ob_clean(); $error_message = 'ERRNO: '. $errNo. chr(10). 'TEXT: '. $errStr. chr(10). 'LOCATION: '. $errFile. chr(10). ', line '. $errLine; echo $error_message; exit; } ?>
-
Hi, can someone give a sample how to delete selected checkboxes, wherein the selected checkboxes represents a file inside the same directory where the script resides. for example, I have 5 files in my directory, then I created an index.php file in order to show their names in a nice way via browser, and then I included a check box at the leftside of each name, and at the bottom is the delete button. is it possible to do that using only one single PHP file ? here's my initial code <html> <head> <meta name="robots" content="noindex" /> <meta name="googlebot" content="noindex" /> <link rel="stylesheet" type="text/css" href="http://METHODS/main.css" /> <script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"></script> <script type="text/javascript" src="http://METHODS/js.js"></script> </head> <body> <?php echo "<div><span id=\"title\">List of Files</span></div>"; ?> <table> <?php if ($handle = opendir('.')) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { if(strlen($file)-strpos($file,".swf")== 4){ echo "<tr><td><input type=\"checkbox\" name=\"box[]\"></td><td><a href=\"$file\" target=\"_blank\">$file</a></td></tr>"; } } } closedir($handle); } ?> </table> <button type="button" name="Delete" value="Delete">Delete</button> </body> </html> please tell me what to add
-
Hi, I just wanna aske if you guys know the PHP status in "Kuwait" ?, is PHP popular in that country? I mean is it widely used as a web development language ?, I checked the zce directory, there's no one listed
-
arghhh...thanks for pointing that out. I got another mistake,.it now works
-
hi, am trying to learn how php + ajax works, but this example from w3schools website doesn't work for me , i have re-written the code manually (twice) and I ended up copy pasting. but still it doesn't show any data from my db html code <html> <head> <script type="text/javascript" src="selectuser.js"></script> </head> <body> <form> Select a User: <select name ="users" onchange="showUser(this.value)"> <option value="1">Peter Griffin</option> <option value="2">Lois Griffin</option> <option value="3">Glenn Quagmire</option> <option value="4">Joseph Swanson</option> </select> </form> <br /> <div id="txtHint"><b>Person info will be listed here.</b></div> </body> </html> the ajax code var xmlhttp; function showUser(str){ xmlhttp.GetXmlHttpObject(); if(xmlhttp == null){ alert("Your browser does not support Ajax"); return; } var url = "getuser.php"; url=url+"?q="+str; url=url+"&sid="+ Math.random(); xmlhttp.onreadystatechange = stateChanged; xmlhttp.open("GET",url,true); xmlhttp.send(null); } function stateChanged(){ if(xmlhttp.readyState == 4){ document.getElementById("txtHint").innerHTML = xmlhttp.responseText; } } function GetXmlHttpRequest(){ if(window.XMLHttpRequest){ return new XMLHttpRequest(); } if(window.ActiveXObject){ return new ActiveXObject("Microsoft.XMLHTTP"); } return null; } php code <?php $q = $_GET["q"]; $con = mysql_connect('localhost','root','mypassword'); if(!$con){ die("Could not connect: " mysql_error()); } mysql_select_db('ajaxsample', $con); $sql = "SELECT * FROM user WHERE id ='".$q."'"; $result = mysql_query($sql); echo "<table border='1'> <tr> <th>Firstname</th> <th>Lastname</th> <th>Age</th> <th>Hometown</th> <th>Job</th> </tr>"; while($row = mysql_fetch_array($result)){ echo "<tr>"; echo "<td>" . $row['FirstName'] . "</td>"; echo "<td>" . $row['LastName']. "</td>"; echo "<td>" . $row['Age']. "</td>"; echo "<td>" . $row['Hometown']."</td>"; echo "<td>" . $row['Job'] . "</td>"; echo "</tr>"; } echo "</table>"; mysql_close($con); ?> :'(
-
ok sir, thanks but that's not the solutions, let me re-phrase my question. How am I gonna make the $row->title, pop its description $row->description when some random user clicks it ? <?php foreach($task->result() as $row): ?> <tr> <td><a href=#><?php echo $row->title; ?></a></td> </tr> <?php endforeach; ?>
-
need help, i have this table data (<td>) , it is being pulled from the db, and it appears like this in my code <td><?php echo $row->title; ?></td> my question is, how will combine it with javascript ,let's say when someone onclick the title, the description will pop out , this description is being pulled from db. if i will do it like this <td id="title"><?php echo $row->title; ?></td> this is for only a single table data right? but what if the time goes by and more titles are being added on db ?
-
daemn..ok sir, thanks for the info..i'll just try to re-export the dbdump from the source ..thanks.
-
- click "import" tab from the top navigation menu - click browse button and load the dbsqldump.sql file - click go an then all tables gets loaded, and boom,, root@localhost is accessed denied on information_schema
-
I am getting this error after importing my db dump from, tables are being imported but then an error appears that root@localhost is accessed denied on information_schema when all of the privileges for my root account is all set..this is weird
-
yes sir, am using the correct password. i even changed it twice, after receiving a reply notification from you
-
I don't have any idea is going on sir(s) please help me, am having trouble importing my database dump here's the first screen shot here's the second one, as you can see, all the priveleges are set
-
yes sir, i've been reading it since you posted the link. thanks alot
-
ok sir, I did what you said, but can you please tell me what are these mysterious folders are ?, they appeared after i checked-out the repository for the first time here's the screen shot
-
Hi, me and other co-noob coders are planning to have a team project for the sake of learning. problem is we don't know how to set up svn LOL I already created a project in google code I already installed tortoise in my machine what should I do next ? please help, I don't know a thing with this LOL
-
hi i got a problem, i dunno why my code deletes all the rows when I only tick 1 checkbox, i don't really get it LOL please help me with this here's my controller code public function delete() { $q = $this->input->post('delete'); if(isset($q)) { $this->member_model->delete($q); $this->members_area(); } else{ redirect('site/members_area'); } } here's my model code public function delete($url) { $this->db->where('bm_URL',$url); $q = $this->db->delete('bookmark'); return $q; } view code <tr><td><b>Bookmark</b></td><td><b>Delete</b></td></tr> <?php foreach($q->result() as $row):?> <?php echo "<tr>"; ?> <?php echo "<td>".anchor('site/delete'.$row->bm_URL,$row->bm_URL)."</td>"; ?> <?php echo "<td>".form_checkbox('delete[]',$row->bm_URL)."</td>"; ?> <?php echo "</tr>"; ?> <?php endforeach; ?> </table> <br /> <hr /> <?php echo anchor('site','Home'); ?> | <?php echo anchor('site/addbm','Add BM'); ?> | <?php echo anchor('site/delete','Delete BM'); ?> | <?php echo anchor('user/changepass','Change Password'); ?><br /> <?php echo anchor('site/recommend','Recommend URLs to me'); ?> | <?php echo anchor('user/logout','Log out'); ?><br />
-
cool, it works now. i missed the "hyphen"
-
hi, I ran this code [code=php:0] $height = 200; $width = 200; $im = imagecreatetruecolor($width,$height); $white = imagecolorallocate($im,255,255,255); $blue = imagecolorallocate($im,0,0,64); imagefill($im, 0,0,$blue); imageline($im,0,0,$width,$height,$white); imagestring($im,4,50,150,'Sales', $white); Header('Content Type: image/png'); imagepng($im); imagedestroy($im); why am I getting this ouput in browser ? ( i also tried other browsers aside from FF, and its the same stuff)