Jump to content

sevillano665

Members
  • Posts

    7
  • Joined

  • Last visited

sevillano665's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. Hi guys! I have a little problem and it's that I get an error in a determined function where I call my connection and I don't know why. The errors are: 1) Notice: Undefined variable: conexionidiomas in C:\wamp64\www\idiomas\preguntas-frecuentes.php on line 10 2) Warning: mysqli_real_escape_string() expects parameter 1 to be mysqli, null given in C:\wamp64\www\idiomas\preguntas-frecuentes.php on line 11 This is what I have from "/Connections/conexionidiomas.php": # FileName="Connection_php_mysql.htm" # Type="MYSQL" # HTTP="true" $hostname_conexionidiomas = "p:localhost:3307"; $database_conexionidiomas = "idiomasbd"; $username_conexionidiomas = "root"; $password_conexionidiomas = "asdasdf"; $conexionidiomas = mysqli_connect($hostname_conexionidiomas, $username_conexionidiomas, $password_conexionidiomas, $database_conexionidiomas); and this in "preguntas-frecuentes.php": <?php require_once('Connections/conexionidiomas.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysqli_real_escape_string") ? mysqli_real_escape_string($conexionidiomas, $theValue) : mysqli_escape_string($conexionidiomas,$theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) { $insertSQL = sprintf("INSERT INTO tblfrecuentes (strPregunta,fchFecha) VALUES (%s,NOW())",GetSQLValueString($_POST['strPregunta'], "text")); $Result1 = mysqli_query($conexionidiomas,$insertSQL) or die(mysqli_error($conexionidiomas)); } ?> So, if someone could help me I'd appreciate it so much. Regards!
  2. Hello, I'm trying to make a method that creates objects of a parameterized type randomly, but also to store the hashCode of different objects created and if at any time the percentage of different objects is less than 50% throw an exception. This last part is where I've gotten stuck. I have created a population property where I store the different hashCodes and update it in the method adding the new hashCode from the new object. But I don't know how to do for to know if the percentage of different objects is less than 50%. See if someone can help me out. Regards!
  3. But I really want that the result text boxes of every multiplication contain "0" if I don't introduce any number, in this way the sum will be made. I have tried to put by default a "0" in the result text boxes but when I introduce some number in some text box all result text boxes shows "NaN" and the sum is not made.
  4. Here is: <script type="text/javascript"> function multiplicar() { var contador1; var contador2 = 2; var contador3 = 1; var n1; var n2; var id1; var id2; var id3; var kgTotales = 0; var precioTotal = 0; for(contador1=1; contador1 < 60; (contador1)+2){ id1="n" +(contador1); id2="n" +(contador2); id3="result" +(contador3); contador1=(contador1)+2; contador2=(contador2)+2; contador3++; n1=parseFloat(document.getElementById(id1).value); n2=parseFloat(document.getElementById(id2).value); document.getElementById(id3).value = (n1*n2); precioTotal = (precioTotal) + (n1*n2); kgTotales = (kgTotales)+n2; document.getElementById("precioTotal").value = precioTotal + " Euros"; document.getElementById("kgTotales").value = kgTotales + " Kg";}}</script> And this is the view, the column where are 3 and 6 are "kg" and its sum have to be shown in kgTotales box, and the last one is for the price. Regards!
  5. It doesn't work, the same result I realized it and I changed, but the result is the same too :S
  6. The table multiply the 2nd column and the third one and the result is shown in the fourth, when I execute and write the values, the result is correct, so it's not possible there's some error en n1 or n2 I think, and precioTotal shows the correct result too. I think I'm doing something wrong and it doesn't recognize the var as a string. Like this? parseFloat(kgTotales);kgTotales = (kgTotales+n2);
  7. Hi! My problem is that I've made a function with "var kgTotales = 0". But when I sum "kgTotales = kgTotales + 2" the result is "02", it returns a string and not a number. I use this var in a bucle so the result is "kgTotales = 02...." and next to it the next numbers I want to sum. This is the code: <script type="text/javascript"> function multiplicar() { var contador1; var contador2 = 2; var contador3 = 1; var n1; var n2; var id1; var id2; var id3; var kgTotales = 0; var precioTotal = 0; for(contador1=1; contador1 < 60; (contador1)+2){ id1="n" +(contador1); id2="n" +(contador2); id3="result" +(contador3); contador1=(contador1)+2; contador2=(contador2)+2; contador3++; n1=document.getElementById(id1).value; n2=document.getElementById(id2).value; document.getElementById(id3).value = (n1*n2); precioTotal = precioTotal + (n1*n2); kgTotales = kgTotales+n2; document.getElementById("precioTotal").value = precioTotal + " Euros"; document.getElementById("kgTotales").value = kgTotales + " Kg"; } } </script> And this is the result: I don't understand why it happens because precioTotal is a similar var and also shows a sum and works well. I hope someone could helps me. Regards!
×
×
  • Create New...