Jump to content

etsted

Members
  • Posts

    274
  • Joined

  • Last visited

Everything posted by etsted

  1. etsted

    js validator

    and this: ajax.send("action="+action+"&type="+type+"&user="+user+"&data="+data+"&document="+document); ====^ lint warning: missing semicolon. that line of code belongs to the function postStatus();
  2. etsted

    js validator

    i have been testing my js script. and got some errors telling me that my function does not always return a value. the two where function postToStatus(action,type,user,ta,document){ // store the value of the thread var data = _(ta).value; if(data === ""){ alert("Type something first"); return false; } _("statusBtn").disabled = true; var ajax = ajaxObj("POST", "php_parsers/status_system2.php"); ajax.onreadystatechange = function() { if(ajaxReturn(ajax) === true) { // split the incoming string, to get the last inserted id var datArray = ajax.responseText.split("|"); if(datArray[0] === "post_ok"){ // the inserted id var sid = datArray[1]; data = data.replace(/</g,"<").replace(/>/g,">").replace(/n/g,"<br />").replace(/r/g,"<br />"); // holds all the threads and replies var currentHTML = _("statusarea").innerHTML; _("statusarea").innerHTML = '<div id="status_'+sid+'" class="status_boxes"><div><b>Posted by you just now:</b> <span id="sdb_'+sid+'"><a href="#" onclick="return false;" onmousedown="deleteStatus(''+sid+'','status_'+sid+'');" title="DELETE THIS STATUS AND ITS REPLIES">delete status</a></span><br />'+data+'</div></div><textarea id="replytext_'+sid+'" class="replytext" onkeyup="statusMax(this,250)" placeholder="write a comment here"></textarea><button id="replyBtn_'+sid+'" onclick="replyToStatus('+sid+','<?php echo $u; ?>','replytext_'+sid+'',this)">Reply</button>'+currentHTML; _("statusBtn").disabled = false; _(ta).value = ""; } else { alert(ajax.responseText); } } } ajax.send("action="+action+"&type="+type+"&user="+user+"&data="+data+"&document="+document);}; // new functionfunction replyToStatus(sid,user,ta,btn,document){ // sid holds the id that associate each thread with all of its replies // get the values inside the textarea var data = _(ta).value; if(data === ""){ alert("Type something first"); return false; } // select the buttons id _("replyBtn_"+sid).disabled = true; var ajax = ajaxObj("POST", "php_parsers/status_system2.php"); ajax.onreadystatechange = function() { if(ajaxReturn(ajax) === true) { var datArray = ajax.responseText.split("|"); if(datArray[0] === "reply_ok"){ // contains the last inserted id to the DB var rid = datArray[1]; // sanitize the data, the user wrote in data = data.replace(/</g,"<").replace(/>/g,">").replace(/n/g,"<br />").replace(/r/g,"<br />"); // contains the reply _("status_"+sid).innerHTML += '<div id="reply_'+rid+'" class="reply_boxes"><div><b>Reply by you just now:</b><span id="srdb_'+rid+'"><a href="#" onclick="return false;" onmousedown="deleteReply(''+rid+'','reply_'+rid+'');" title="DELETE THIS COMMENT">remove</a></span><br />'+data+'</div></div>'; _("replyBtn_"+sid).disabled = false; // empty the textarea _(ta).value = ""; } else { alert(ajax.responseText); } } } ajax.send("action=status_reply&sid="+sid+"&user="+user+"&data="+data+"&document="+document);}
  3. etsted

    weird error

    i've tried to change it. when i post a new thread, no error occurs. if i try to delete a thread, an errror occurs, it tells me that $_POST['document'] is undefined. Take a look. $check_document = $_SERVER['PHP_SELF']; if($check_document == "/watch.php") { $DB_table = "comments"; } else if($check_document == "/user.php") { $DB_table = "status"; }// this is then button they will press to submit a threadif($check_document == "/watch.php") { if($user_status == true){ $status_ui = '<textarea id="statustext" onkeyup="statusMax(this,250)" placeholder="Hi '.$log_username.'"></textarea>'; $status_ui .= '<button id="statusBtn" onclick="postToStatus('status_post','c',''.$u.'','statustext',''.$DB_table.'')">Post</button>'; } }// so this button should contain "comments", bcz i am trying at watch.php, but i also tried it at user.php, and got the same error...// the comment i am trying to delete looks like this in "view source".<!-- holds the textarea to write in --><textarea id="statustext" onkeyup="statusMax(this,250)" placeholder="Hi jacop"></textarea><button id="statusBtn" onclick="postToStatus('status_post','c','george','statustext','comments')">Post</button></div>// this is how the ajax looks like:function deleteStatus(statusid,statusbox,document){ var ajax = ajaxObj("POST", "php_parsers/status_system2.php"); ajax.onreadystatechange = function() { if(ajaxReturn(ajax) == true) { if(ajax.responseText == "delete_ok"){ // remove the div all of the tekst is inside, the textarea and the reply button _(statusbox).style.display = 'none'; _("replytext_"+statusid).style.display = 'none'; _("replyBtn_"+statusid).style.display = 'none'; } else { alert(ajax.responseText); } } } ajax.send("action=delete_status&statusid="+statusid+"&document="+document);}// this is how status_system2.php looks likeif (isset($_POST['action']) && $_POST['action'] == "delete_status" && isset($_POST['document'])){ if(!isset($_POST['statusid']) || $_POST['statusid'] == ""){ echo "status id is missing"; exit(); } // sanitize the inserted status id $statusid = preg_replace('#[^0-9]#', '', $_POST['statusid']); // check to see which page the user is on, then give different variables that contain different DB tables // check to see whether or not the user replied to a status from user.php or watch.php if($_POST['document'] == "comments") // this means the user replied within watch.php { $DB_table = "comments"; } else if($_POST['document'] == "status") // this mean that the user replied within user.php { $DB_table = "status"; }else{ echo 'Error: this is an unexpected situation. What is happening? ' . $_POST['document']; } // Check to make sure the person deleting this reply is either the account owner or the person who wrote it if($DB_table == null){ echo 'Can't look up nuthin';}else{ // Check to make sure the person deleting this reply is either the //account owner or the person who wrote it $sql = "SELECT account_name, author FROM $DB_table WHERE id='$statusid' LIMIT 1"; $query = mysqli_query($con, $sql); while ($row = mysqli_fetch_array($query, MYSQLI_ASSOC)) { $account_name = $row["account_name"]; $author = $row["author"]; }} // delete the thread and it replies with the same osid if ($author == $log_username || $account_name == $log_username) { $sql = "DELETE FROM $DB_table WHERE osid='$statusid'"; mysqli_query($con, $sql); echo "delete_ok"; exit(); }}
  4. etsted

    weird error

    okay so i have tried to echo $_POST['document'] and its value is "watch", then i tried to echo $DB_table and it says "comments", but when i echo the $sql its gives me something completly different it says "SELECT account_name, author FROM status WHERE id='53' LIMIT 1" when really it should say "SELECT account_name, author FROM comments WHERE id='53' LIMIT 1" // fires of when the someone deletes a threadif (isset($_POST['action']) && $_POST['action'] == "delete_status" && isset($_POST['document'])){ if(!isset($_POST['statusid']) || $_POST['statusid'] == ""){ echo "status id is missing"; exit(); } // sanitize the inserted status id $statusid = preg_replace('#[^0-9]#', '', $_POST['statusid']); // check to see which page the user is on, then give different variables that contain different DB tables // check to see whether or not the user replied to a status from user.php or watch.php if(isset($_POST['document']) && $_POST['document'] == "watch") // this means the user replied within watch.php { $DB_table = "comments"; } else if($_POST['document'] == "") // this mean that the user replied within user.php { $DB_table = "status"; }else{ echo 'Error: this is an unexpected situation. What is happening? ' . $_POST['document']; } echo $DB_table; // Check to make sure the person deleting this reply is either the account owner or the person who wrote it if($DB_table == null){ echo 'Can't look up nuthin'; exit(); }else{ // Check to make sure the person deleting this reply is either the //account owner or the person who wrote it $sql = "SELECT account_name, author FROM $DB_table WHERE id='$statusid' LIMIT 1"; echo $sql; $query = mysqli_query($con, $sql); while ($row = mysqli_fetch_array($query, MYSQLI_ASSOC)) { $account_name = $row["account_name"]; $author = $row["author"]; } } // delete the thread and it replies with the same osid if ($author == $log_username || $account_name == $log_username) { mysqli_query($con, "DELETE FROM $DB_table WHERE osid='$statusid'"); echo "delete_ok"; exit(); }}
  5. etsted

    weird error

    got this... Error: this is an unexpected situation. What is happening?Can't look up nuthin<br /> // the custom error msg and Notice: Undefined variable: author in C:wampwwwphp_parsersstatus_system2.php on line <i>196</i> what could possible be wrong?
  6. etsted

    weird error

    i have a script that kinda works. Let me explain. This function is supposed to delete any post, but when i write a post, and then tries to delete it i get an error message. i says that i have an undefined variable $DB_table at line 180, then i close the error box, and click on "delete post" again, and then suddently the post is deleted from the DB //this if statements give delete button to specified users// allows the author to delete threads they have made and the page owner to delete all threads if($check_document == "/watch.php") { if($author == $log_username || $account_name == $log_username ){ $statusDeleteButton = '<span id="sdb_'.$statusid.'"><a href="#" onclick="return false;" onmousedown="deleteStatus(''.$statusid.'','status_'.$statusid.'','watch');" title="DELETE THIS STATUS AND ITS REPLIES">delete status</a></span> '; } } else if ($check_document == "/user.php") { if($author == $log_username || $account_name == $log_username ){ $statusDeleteButton = '<span id="sdb_'.$statusid.'"><a href="#" onclick="return false;" onmousedown="deleteStatus(''.$statusid.'','status_'.$statusid.'');" title="DELETE THIS STATUS AND ITS REPLIES">delete status</a></span> '; } }note: the first "$statusDeleteButton" has a function called deleteStatus with 4 parameters, but the second $statusDeleteButton's deleteStatus function only has 3 parameters.// Then i use ajax to comunicate with the server:function deleteStatus(statusid,statusbox,document=""){ var ajax = ajaxObj("POST", "php_parsers/status_system2.php"); ajax.onreadystatechange = function() { if(ajaxReturn(ajax) == true) { if(ajax.responseText == "delete_ok"){ // remove the div all of the tekst is inside, the textarea and the reply button _(statusbox).style.display = 'none'; _("replytext_"+statusid).style.display = 'none'; _("replyBtn_"+statusid).style.display = 'none'; } else { alert(ajax.responseText); } } } ajax.send("action=delete_status&statusid="+statusid+"&document="+document);}// this is from status_system2.phpif(isset($_POST['document']) && $_POST['document'] == "watch") // this means the user replied within watch.php { $DB_table = "comments"; } else if(!isset($_POST['document'])) // this mean that the user replied within user.php { $DB_table = "status"; } // Check to make sure the person deleting this reply is either the account owner or the person who wrote it $query = mysqli_query($con, "SELECT account_name, author FROM $DB_table WHERE id='$statusid' LIMIT 1"); while ($row = mysqli_fetch_array($query, MYSQLI_ASSOC)) { $account_name = $row["account_name"]; $author = $row["author"]; } // this is the error i get: Notice: Undefined variable: DB_table in C:wampwwwphp_parsersstatus_system2.php on line <i>180</i>
  7. etsted

    mysqli IN clause

    this is the script that takes in several post elements $errors = array(); if(empty($_POST['to'])) { $errors = "fill out the to input<br>"; } else if( preg_match("%^[a-z, 0-9]+$%i", $_POST['to']) == 0) { $errors = "the list of names you gave is not valid<br>"; } else { // seperate each user by the "," $user_name = explode(",", $_POST['to']); // trim each user for extra white space foreach($user_name as &$name) { $name = trim($name); } // this is the function that goes wrong $user_ids = fetch_user_id($user_name); if(count($user_ids) != count($name) ) { $errors = "the following user could not be found " . implode(', ', array_diff($user_name, array_keys($user_ids) ) ) . "<br>"; } } if(empty($_POST['subject'])) { $errors .= "fill out the subject input <br>"; } if(empty($_POST['body'])) { $errors .= "fill out the body input <br>"; } if ( isset($errors) ) { if ( empty($errors) ) { echo "<div class='msg success'> your message has been sent <a href='index2.php?page=inbox'>Return to your inbox</a> </div>"; } else { echo "<div class='msg error'>" . $errors . "</div>"; } } and here is the function i have set // check to see if multiple users existfunction fetch_user_id($user_name){ global $con; foreach ($user_name as &$name) { $name = mysqli_real_escape_string($con, $name); } $sql = "SELECT user_id, user_name FROM users WHERE user_name IN ('". implode("','", $user_name) ."')"; $result = mysqli_query($con, $sql); $names = array(); while ( ($row = mysqli_fetch_assoc($result)) != false) { $names[$row['user_name']] = $row['user_id']; } return $names;} the script i have at top i supposed to display any person that was typed in to the $_POST['to'] variable, that does not exist in the DB, on to the screen. If i type in a user that does not exist, then the correct error message is displayed, but as soon as i type in a user that does exist, it displays a message telling me that "your message has been sent", which is what it is not supposed to do
  8. etsted

    uploadify

    i am having trouble with uploadify script. this lais inside uploadify/uploads.php $verifyToken = md5('unique_salt' . $_POST['timestamp']);if (!empty($_FILES) && $_POST['token'] == $verifyToken) { $tempFile = $_FILES['Filedata']['tmp_name']; // this makes every file name unique $fileName = $_FILES['Filedata']['name']; $kaboom = explode(".",$fileName); $ext = ""; $ext = end($kaboom); $ext = strtolower($ext); $fileName = date("YmdjzHhisu") . rand(10000000,99999999) . ".$ext"; // defines what the ext can be $imageTypes = array('jpg','jpeg','gif','png'); $videoTypes = array('mp4','webm','ogg'); $audioTypes = array('mp3','ogg','wav'); $tittel = $_POST['tittel']; $description = $_POST['description']; $username = $_POST['username']; // include DB connection include_once ("../connect.php"); // use the pathinfo to match the ext of the uploaded file $fileParts = pathinfo($_FILES['Filedata']['name']); $fileParts = $fileParts['extension']; $fileParts = strtolower($fileParts); if (in_array($fileParts,$imageTypes)) { // this is for images // insert into DB $sql = "INSERT INTO images VALUES('', '$tittel', '$description', '$username', '$fileName' , NOW())"; $query = mysqli_query($con, $sql); move_uploaded_file($tempFile, "u_image/" . $fileName); echo '1'; } else if(in_array($fileParts, $videoTypes)){ // this is for videos // insert into DB $sql = "INSERT INTO videos VALUES('', '$tittel', '$description', '$username', '$fileName' , NOW())"; $query = mysqli_query($con, $sql); move_uploaded_file($tempFile, "videos/" . $fileName); echo '1'; } else if(in_array($fileParts,$audioTypes)){ // this is for audios // insert into DB $sql = "INSERT INTO mp3 VALUES('', '$tittel', '$description', '$username', '$fileName' , NOW())"; $query = mysqli_query($con, $sql); move_uploaded_file($tempFile, "audio/" . $fileName); echo '1'; } else { echo "Invalid file."; }}?> i have tried to copy everything to another file, then make a temporary form tag within that file, and it worked, what am i missing out here? And i doesnt display any errors the input form i am currently using: uploads.php <?php // this is the upload form $uploadForm = "<h1>Upload</h1>"; $uploadForm .= "<form action='' method='post' id='uploadForm' enctype='multipart/form-data'>"; $uploadForm .= "Tittel: <input type='text' name='tittel' size='55' id='tittel'> <br>"; $uploadForm .= "Description: <textarea rows='5' id='description' cols='55' name='description'></textarea> <br><br>"; $uploadForm .= "<input style='display:none;' type='text' name='username' id='username' value='$u'>"; $uploadForm .= "<div id='queue'></div>"; $uploadForm .= "<input id='file_upload' name='file_upload' type='file'>"; $uploadForm .= "</form>"; ?> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js" type="text/javascript"></script> <script src="uploadify/jquery.uploadify.min.js" type="text/javascript"></script> <link rel="stylesheet" type="text/css" href="uploadify/uploadify.css"> <style type="text/css"> body { font: 13px Arial, Helvetica, Sans-serif; } #uploadForm > #tittel{ margin-left: 37px; } </style> <script type="text/javascript"> <?php $timestamp = time();?> $(function() { $('#file_upload').uploadify({ 'formData' : { 'timestamp' : '<?php echo $timestamp;?>', 'token' : '<?php echo md5('unique_salt' . $timestamp);?>' }, 'multi' : false, 'swf' : 'uploadify/uploadify.swf', 'uploader' : 'uploadify/uploads.php', 'onUploadStart' : function(file) { $("#file_upload").uploadify("settings", "formData", {"tittel": $("#tittel").val(), "description": $("#description").val(), "username": $("#username").val()} ); }, 'debug' : true }); }); </script> </head> <div style="margin-left:30%;"><?php echo $uploadForm;?></div>
  9. etsted

    audio tag

    Is it possible to increase the width of the audio format?
  10. etsted

    DB selection

    bcz this script works only if the selected type is not "register"
  11. etsted

    DB selection

    if(isset($_GET['submit']) && !empty($_GET['s']) OR !empty($_GET['pn']) ) { include_once ("connect.php"); // this contains the information the user has typed in $search = trim($_GET['s']); $search = mysqli_real_escape_string($con, $search); // this is the table the user wishes to do a search in $type = preg_replace("%[^a-z0-9]%i", "", $_GET['type']); if(!preg_match("%(images|mp3|videos|register)%", $type)) { echo "something went wrong"; exit; } // searches for a macht in the DB, with what the user typed in, and selected //makes sure that only u_name is present, when the user selects the register type, bcz the register table should only search for usernames function which_type($type, $search){ if($type == "register") { // if the selected type was register $sqlCommand = "SELECT * FROM $type WHERE u_name LIKE '%$search%' "; } else { // if the selected type was not equal to register $sqlCommand = "SELECT * FROM $type WHERE description LIKE '%$search%' OR username LIKE '%$search%' OR tittel LIKE '%$search%' "; } return $sqlCommand; } // this will register what the selected type was from the search bar $sqlCommand = which_type($type, $search); // check to see if there are any results in the DB $query = mysqli_query($con, $sqlCommand) or die(mysqli_error($con)); $count = mysqli_num_rows($query); if($count > 1){ // okey procced } else { // something went wrong } } when i select a type that is not equal to "register" and search something from the DB, i get files displayed from the DB and when i echo the sql result, it looks like this SELECT * FROM images WHERE description LIKE '%g%' OR username LIKE '%g%' OR tittel LIKE '%g%' but if i were to select "register", then the "else statement" will display telling me "no resulst were found" even though i have searched something from the DB
  12. etsted

    oblique

    i want the divs to be stacked vertically in a straight line, so when the line they are on doesnt have any more room, they will jump down to the next line, but insted of stacking in a straight vertical line the somehow go down, little by little, i mean the first divs has the right position, but then the next div will start at a position 20 extra px from the top, then the div after that will start at 40 extra px from the top, and so on
  13. etsted

    not sure...

    i want "tittel LIKE '%$search%' OR" to be a part of the $sql statement if the $type variable of the "which_type" function is not equal to register. The error i get when i try to run this script is: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') { tittel LIKE '%g%' OR } ' at line 2 So im guessing that it is not recieving the input from the $search variable, but i dont know why. $sqlCommand = ""; $type = $_GET['type']; // stores the selected type, from a select drop down box $search = $_GET['s']; // stores the input, the user has typed in // this contains the information the user has typed in $search = trim($_GET['s']); $search = mysqli_real_escape_string($con, $search); // this is the table the user wishes to do a search in $type = preg_replace("%[^a-z0-9]%i", "", $_GET['type']); if(!preg_match("%(images|mp3|videos|register)%", $type)) { echo "something went wrong"; exit; } // searches for a macht in the DB, with what the user typed in function which_type($type, $search){ $sqlCommand = "SELECT * FROM $type WHERE if($type != 'register') { tittel LIKE '%$search%' OR } description LIKE '%$search%' OR username LIKE '%$search%'"; return $sqlCommand; } $sqlCommand = which_type($type, $search); $query = mysqli_query($con, $sqlCommand) or die(mysqli_error($con));
  14. etsted

    oblique

    my divs are stacking oblique, any known reason to that?
  15. etsted

    json

    I fixed it as usual
  16. etsted

    oblique

    <div id="middleDiv"><div><h2>images files: <strong>8</strong></h2><p style='border:2px red solid;'>page <strong>1</strong> of <strong>1</strong></p><div class='files' id='file_10'><a href='watch.php?f=C:/wamp/www//u_image/2014042727116170529180000006231689.MP4'><img src='images/avatardefault.png' height='60' width='60' alt='123'> Click here</a><br><span style=' text-overflow:ellipsis; '>Tittel: 123</span><br><span>Uploaded by: <a href='user.php?u=george'>george</a></span><br><br><div style='width: 298px; text-overflow:ellipsis;'>Description: ewq</div><br><span >Upload date: 2014-04-27</span><br><br></div><br> <br><div class='files' id='file_11'><a href='watch.php?f=C:/wamp/www//u_image/2014042727116180632040000003145629.png'><img src='images/avatardefault.png' height='60' width='60' alt=''> Click here</a><br><span style=' text-overflow:ellipsis; '>Tittel: </span><br><span>Uploaded by: <a href='user.php?u=george'>george</a></span><br><br><div style='width: 298px; text-overflow:ellipsis;'>Description: </div><br><span >Upload date: 2014-04-27</span><br><br></div><br> <br><div class='files' id='file_12'><a href='watch.php?f=/u_image '><img src='images/avatardefault.png' height='60' width='60' alt=''> Click here</a><br><span style=' text-overflow:ellipsis; '>Tittel: </span><br><span>Uploaded by: <a href='user.php?u=george'>george</a></span><br><br><div style='width: 298px; text-overflow:ellipsis;'>Description: </div><br><span >Upload date: 2014-04-29</span><br><br></div><br> <br><div class='files' id='file_13'><a href='watch.php?f=/u_image '><img src='images/avatardefault.png' height='60' width='60' alt=''> Click here</a><br><span style=' text-overflow:ellipsis; '>Tittel: </span><br><span>Uploaded by: <a href='user.php?u=george'>george</a></span><br><br><div style='width: 298px; text-overflow:ellipsis;'>Description: </div><br><span >Upload date: 2014-04-29</span><br><br></div><br> <br><div class='files' id='file_14'><a href='watch.php?f=/u_image '><img src='images/avatardefault.png' height='60' width='60' alt=''> Click here</a><br><span style=' text-overflow:ellipsis; '>Tittel: </span><br><span>Uploaded by: <a href='user.php?u=george'>george</a></span><br><br><div style='width: 298px; text-overflow:ellipsis;'>Description: </div><br><span >Upload date: 2014-04-29</span><br><br></div><br> <br><div class='files' id='file_15'><a href='watch.php?f=Array'><img src='images/avatardefault.png' height='60' width='60' alt=''> Click here</a><br><span style=' text-overflow:ellipsis; '>Tittel: </span><br><span>Uploaded by: <a href='user.php?u=george'>george</a></span><br><br><div style='width: 298px; text-overflow:ellipsis;'>Description: </div><br><span >Upload date: 2014-04-29</span><br><br></div><br> <br><div class='files' id='file_16'><a href='watch.php?f=/u_image/20140429291181212413500000075324707.gif'><img src='images/avatardefault.png' height='60' width='60' alt=''> Click here</a><br><span style=' text-overflow:ellipsis; '>Tittel: </span><br><span>Uploaded by: <a href='user.php?u=george'>george</a></span><br><br><div style='width: 298px; text-overflow:ellipsis;'>Description: </div><br><span >Upload date: 2014-04-29</span><br><br></div><br> <br><div class='files' id='file_17'><a href='watch.php?f=C:/wamp/www//u_image/20140429291181212520300000080238342.png'><img src='images/avatardefault.png' height='60' width='60' alt=''> Click here</a><br><span style=' text-overflow:ellipsis; '>Tittel: </span><br><span>Uploaded by: <a href='user.php?u=jacop'>jacop</a></span><br><br><div style='width: 298px; text-overflow:ellipsis;'>Description: </div><br><span >Upload date: 2014-04-29</span><br><br></div><br> <br><div></div></div></div>
  17. etsted

    json

    i validted the json code, and it had no errors, but i still get 4 errors when i run the code. TypeError: vendor is undefined hotels.php:1174 The character encoding of the HTML document was not declared. The document will render with garbled text in some browser configurations if the document contains characters from outside the US-ASCII range. The character encoding of the page must be declared in the document or in the transfer protocol. json_tutorial.htmlTypeError: results is undefined json_tutorial.html:19TypeError: vendor is undefined my json_script.htm <!DOCTYPE html><html><head><script type="text/javascript">function ajax_get_json() {var results = document.getElementById("results"); var hr = new XMLHttpRequest(); hr.open("GET", "mylist.json", true); hr.setRequestHeader("Content-type", "application/json", true); hr.onreadystatechange = function() { if(hr.readyState == 4 && hr.status == 200) { var data = JSON.parse(hr.responseText); var results = document.getElementById(data); console.log(data); results.innerHTML = data.user; } } hr.send(); results.innerHTML = "requesting...";}</script></head><body><div id="results"></div><script type="text/javascript">ajax_get_json();</script></body></html> my mylist.json { "user":"John", "age":"22", "country":"United States" }
  18. etsted

    oblique

    my keeps staking oblique, any special reasion? $files .= "<div class='files' id='file_".$id."'>n <a href='watch.php?f=$file_url'><img src='$avatar' height='60' width='60' alt='$tittel'> Click here</a> <br> <span style=' text-overflow:ellipsis; '>Tittel: $tittel</span>n <br> <span>Uploaded by: <a href='user.php?u=$username'>$username</a></span> <br><br> <div style='width: 298px; text-overflow:ellipsis;'>Description: $description</div>n <br> <span >Upload date: $upload_date</span> <br> <br> </div>n <br> <br>n"; <style type="text/css"> .files{ float: left; width:200px; } /* style the links inside where we store the files */ .files > a{ color: #004000; text-decoration: none; } .files > span > a{ color: #004000; text-decoration: none;margin-left: 10px; } </style> <p><?php echo $files;?></p>
  19. etsted

    php

    $username = $row['u_name']; $avatar = $row['avatar']; $gender = $row['gender']; $lastlogin = $row['lastlogin']; // count all of their videos, images and audios function select_images($tabell){ global $username; $sql = "SELECT COUNT(id) FROM $tabell WHERE username='$username'"; } $num_images = select_images("images"); causes Cannot redeclare select_images() (previously declared in C:wampwwwsearch.php:165)
  20. etsted

    text shrink

    this div "<div style='border:1px red solid;width: 298px; text-overflow:ellipsis;'>Description: $description afdfdsafdasfdsdafdfdsdddfssdffdsdfsdfdfsfdsafdsdfddsf</div>" will only make the tekst go beyond the border, instead of starting on a new line
  21. etsted

    text shrink

    when content overflows a div i want i text to be able to be able to continue on the next line automaically if the width of the div is to small. I am not talking about the overflow property.
  22. etsted

    audio tag

    this audio tag keeps duplicating my mp3 files $mp3 = ""; // get all the mp3 files from the DB $sql = "SELECT * FROM mp3"; $query = mysqli_query($con, $sql); while($row = mysqli_fetch_array($query) ) { $id = $row['id']; $tittel = $row['tittel']; $description = $row['description']; $username = $row['username']; $file_url = $row['file_url']; $upload_date = $row['upload_date']; $mp3 .= "<audio width='320' height='240' controls>n <source src='$file_url' type='audio/mpeg'>n </audio>n"; echo "$mp3"; } i only have 4 mp3 files in the DB, but wheni run this code it shows me 10 different mp3 files, i have checked the file source, and the print_r, but there is nothing wrong, i think, it just stands that some of my mp3 are being duplicated, why?
  23. etsted

    json

    it says it is expecting SyntaxError: JSON.parse: expected property name or '}'
  24. etsted

    json

    what do you mean "networks tab to inspect the request / response?" how i can i allow the console.log to work?
×
×
  • Create New...