Jump to content

Search the Community

Showing results for tags 'undefined'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • W3Schools
    • General
    • Suggestions
    • Critiques
  • HTML Forums
    • HTML/XHTML
    • CSS
  • Browser Scripting
    • JavaScript
    • VBScript
  • Server Scripting
    • Web Servers
    • Version Control
    • SQL
    • ASP
    • PHP
    • .NET
    • ColdFusion
    • Java/JSP/J2EE
    • CGI
  • XML Forums
    • XML
    • XSLT/XSL-FO
    • Schema
    • Web Services
  • Multimedia
    • Multimedia
    • FLASH

Calendars

  • Community Calendar

Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Languages

Found 7 results

  1. Class Variable Declaration

    BACKGROUND: I am now running with PHP 5.5.38, and things are nearly back to normal. My error messages have returned, and things that once worked, now function well again. This said, I wish to make good on the pain and disappointment that I suffered and am requesting your help to do so. REQUEST: Please find below a PHP class that I created in order to gather data from my database. It works fine in my current PHP environment and produces the expected results. It has been upgraded to handle multiple languages and editions of the same letter number. In addition, I have included a list of suspect variables -- namely, variables whose undeclared status may have been a source of difficulty while running in my previous PHP 5.6.33 environment. class Newsletter { public $letter_no; public $letter_lang; public $mysqli_obj; public $letter_ed; public $pc_total; public $podcasts; public function __construct($letter_no, $letter_lang, $mysqli_obj, $letter_ed = 1) { $this->letter_no = $letter_no; $this->letter_lang = $letter_lang; $this->mysqli_obj = $mysqli_obj; $this->letter_ed = $letter_ed; } public function get_letter_data() { $sql = "SELECT letter.*, qa.* FROM sevengates_letter AS letter JOIN sevengates_qa AS qa ON letter.letter_no = qa.letter_no WHERE letter.letter_no = ? AND letter.letter_lang = ? ORDER BY letter.letter_ed DESC"; $mysqli_stmt = $this->mysqli_obj->stmt_init(); $mysqli_stmt->prepare($sql); $mysqli_stmt->bind_param('is', $this->letter_no, $this->letter_lang); $mysqli_stmt->execute(); $meta = $mysqli_stmt->result_metadata(); while ($field = $meta->fetch_field()) { $params[] = &$row[$field->name]; } call_user_func_array(array($mysqli_stmt, 'bind_result'), $params); while ($mysqli_stmt->fetch()) { foreach($row as $key => $val) { $c[$key] = $val; } $prelim_result[] = $c; } foreach ($prelim_result as $arr) { foreach ($arr as $name => $value){ $letter_results[$name] = $value; } } return $letter_results; } public function get_nextletter_data() { $next_letter_no = $this->letter_no + 1; $sql = "SELECT letter_no, letter_title, letter_abstract FROM sevengates_letter WHERE letter_no = ?"; $mysqli_stmt = $this->mysqli_obj->stmt_init(); $mysqli_stmt->prepare($sql); $mysqli_stmt->bind_param('i', $next_letter_no); $mysqli_stmt->execute(); $meta = $mysqli_stmt->result_metadata(); while ($field = $meta->fetch_field()) { $params[] = &$row[$field->name]; } call_user_func_array(array($mysqli_stmt, 'bind_result'), $params); while ($mysqli_stmt->fetch()) { foreach($row as $key => $val) { $c[$key] = $val; } $prelim_result[] = $c; } $mysqli_stmt->free_result(); foreach ($prelim_result as $arr) { foreach ($arr as $name => $value){ $nextletter_results[$name] = $value; } } return $nextletter_results; } public function get_podcasts() { $sql = "SELECT podcast_ref FROM sevengates_podref WHERE letter_no = ?"; $mysqli_stmt = $this->mysqli_obj->stmt_init(); $mysqli_stmt->prepare($sql); $mysqli_stmt->bind_param('i', $this->letter_no); $mysqli_stmt->execute(); $meta = $mysqli_stmt->result_metadata(); while ($field = $meta->fetch_field()) { $params[] = &$row[$field->name]; } call_user_func_array(array($mysqli_stmt, 'bind_result'), $params); while ($mysqli_stmt->fetch()) { foreach($row as $key => $val) { $c[$key] = $val; } $prelim_result[] = $c; } $i = 1; foreach ($prelim_result as $arr) { foreach ($arr as $name => $value) { $name = $name . '_' . $i; $podcasts[$name] = $value; } $i++; } $this->pc_total = count($podcasts); return $podcasts; } public function get_podcasts_data($podcasts) { $this->podcasts = $podcasts; $prelim_result = []; $c = []; $row = []; $podcast_results = []; foreach ($podcasts as $name => $value) { $params = []; $mysqli_stmt = $this->mysqli_obj->stmt_init(); $sql = "SELECT item_podtype, podcast_no_item, item_title, item_description, item_guid FROM rss2_podcast_item WHERE podcast_no_item = ?"; $mysqli_stmt->prepare($sql); $mysqli_stmt->bind_param('i', $value); $mysqli_stmt->execute(); $meta = $mysqli_stmt->result_metadata(); while ($field = $meta->fetch_field()) { $params[] = &$row[$field->name]; } call_user_func_array(array($mysqli_stmt, 'bind_result'), $params); while ($mysqli_stmt->fetch()) { foreach($row as $key => $val) { $c[$key] = $val; } } $prelim_result[] = $c; $mysqli_stmt->free_result(); } foreach ($prelim_result as $arr) { foreach ($arr as $name => $value){ $pc_result[$name] = $value; } $podcast_results[] = $pc_result; } return $podcast_results; } public function get_pc_total() { return $this->pc_total; } } LIST OF SUSPECT VARIABLES $params = []; $prelim_result = []; $c = []; $letter_results = []; $next_letter_results = []; $row = []; $podcast_results = []; DISCUSSION I feel fairly comfortable with handling certain kinds of variables, but very uncomfortable handling others. In fact, I am not at all sure why the above class works, as it took a lot of guess work to make it function. Guess work is inefficient. QUESTION: How does one properly declare class variables that are not related to the arguments of the constructor function? Please provide examples from the list and code provided. Roddy
  2. Pop-up box returns "undefined"

    I have this as one of my switch statements as the default: default: document.getElementById("default2").innerHTML = window.alert("I don't know that color."); break; The pop-up box appears and says the message, but when I click "ok" the word "undefined" shows up on the screen. How do I make it so the box pops up, and when you click "ok" nothing shows up on the screen?
  3. Error querying sql (undefined var)

    See my code first <?php include(dirname(dirname(__FILE__)) . "/pathdefiner.php"); include_once (BASEPATH . INC . "logged.php"); if (!isLoggedIn()) { include ("templates/login.html.php"); exit(); } if (isset($_GET['addp'])) { $title = "Add post"; $desc = "Type down what your post want to be"; $action = "?addpost"; $id = ''; $titlepost = ''; $button = 'Add post'; $editmode = FALSE; include "templates/form.html.php"; die(); } if (isset($_GET['addpost'])) { if (empty($_POST['post']) || empty($_POST['title'])) { echo 'Please fill and set the post entry' . '<br>' . '<p><a href=".">Go Back</a></p>'; die(); } include_once (BASEPATH . INC . "connect.php"); try { $sql = "INSERT INTO `posts` SET `title` = :title, `posttext` = :post, `posttime` = :time"; $s = $pdo->prepare($sql); $s->execute( array( ':title' => $_POST['title'], ':post' => $_POST['post'], ':time' => time() ) ); } catch(PDOException $e) { die("Error adding post. Error: " . $e->getMessage()); } header('Location: .'); die(); } include "templates/admin.html.php"; include "templates/logout.inc.html.php"; After executed, it generates an error that the $pdo variable is not set... But, if i change the include_once to include, it will work well... And, if i change the $pdo variable in my connect.php to a global scope, it will work well too... Can you tell me why this happens? Why if i change include_once to include, it will work ? Why if i set the $pdo variable to global, it will work ? Which's better ? Change include_once to include or set the global scope for $pdo ? This is my connect.php <?php require_once (dirname(__FILE__) . '/config.php'); define("DSN", 'mysql:host=' . DB_HOST . ';dbname=' . DB_NAME); try { $pdo = new PDO(DSN, DB_UN, DB_PW); $pdo->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION); $pdo->exec('SET NAMES "utf8"'); } catch (PDOException $e) { echo DB_PW . "<br>"; die('Error: ' . $e->getMessage()); }
  4. return responseText = undefined?

    <script>function ajax(){xmlhttp = (window.XMLHttpRequest) ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP") ? new ActiveXObject("Msxml2.XMLHTTP") : null ;xmlhttp.onreadystatechange = function(){ var jsonData = eval("("+xmlhttp.responseText+")"); return (this.readyState == 4 && this.status == 200) ? jsonData[1][1] : null ;}xmlhttp.open("GET","json.json",true);xmlhttp.send(null);} window.onload function func(){document.getElementById(elem).innerHTML = ajax(); // return undefined}</script> Is there a syntax mistake that produces the undefined result?
  5. Function to check for undefined?

    <form name="form" action="enter.php" method="post"> First Name: <input type="text" name="first" /><br /> Last Name: <input type="text" name="last" /><br /> <input type="checkbox" name="c1" value="1" onclick="showSubmit()" /> <input type="checkbox" name="c1" value="1" onclick="showSubmit()" /> <input type="checkbox" name="c3" value="1" onclick="showSubmit()" /> <!-- SUBMIT BUTTON HERE --> </form> If I only check the 1st and the 3rd checkbox and press the submit button, but in my enter.php, I made it check print out each of the inputs like so: <?php echo $_POST["first"];echo $_POST["last"];echo $_POST["c1"]; echo $_POST["c2"]; echo $_POST["c3"];?> I will get a warning/error claiming that the c2 is undefined. Is there a built in function that checks if something is undefined ? That way I can use a if and else statement: if is it undefined, it will print something, and if it is checked (defined), make it print something else.
  6. Undefined Cookie return

    Hi I have finaly managed to get a cookie to save the data i want it to. I now have a problem that it saves it with Undefined after it. and when i try and pull the information out i will either get Undefined displayed in my webpage or the information i saved with the word undefined after it. how do i define the code i am putting in to the cookie as text. i am using the code from the following website www.jslab.dk.
  7. Need Help On "undefined"

    var i = -1;var arr;function wordScroller(){clearTimeout(display);arr = str.split(" ");i+=1;document.getElementById("div").innerHTML += str.substr(str.indexOf(arr[i]),arr[i].length) + " ";if(i<arr.length){ var display = setTimeout(wordScroller,1000) } else { clearTimeout(display); }} <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>JS: Word Scroller</title><script type="text/javascript" src="wordScroller.js"></script><script>window.onload = function(){str = "These are pretty girls";wordScroller();}</script></head><body><div id="div"></div></body></html> The word scroller works fine in both IE9 and FF5 but one problem is that FF Console reports after the animation finishes that arr is undefined.How could I possibly fix it? I have no idea coz I bet I ain't very sure about the "undefined" issue.
×