Jump to content

Help Need Assistance Not been able to connect MySQL on Windows or 000Webhost.com

- - - - -

  • Please log in to reply
No replies to this topic

#1
Juan Pluma

Juan Pluma

    Newbie

  • Members
  • Pip
  • 4 posts
Hi
Firebug messange:
<b>Warning</b>: mysql_connect() [<a href='function.mysql-connect'>function.mysql-connect</a>]: [2002] Se produjo un error durante el intento de conexion ya que la par (trying to connect via tcp://mysql11.000webhost.com:3306) in <b>C:\xampp\htdocs\process.php</b> on line <b>8</b><br />
<br />



I'm new on programming so I use only php producedural my code for the connection and posting is this:
process.php file content:
<?

$host = 'mysql11.000webhost.com';
$dbname = 'blah_blah';
$user = 'blah_blah11';
$pass = 'blah111';

$conn = mysql_connect($host, $user, $pass) or die(mysql_error());
$select_db= mysql_select_db($dbname) or die(mysql_error());

$nombre = $_POST['nombre'];
$email = $_POST['email'];
$telefono = $_POST['telefono'];
$pedido = $_POST['pedido'];

$sql = "INSERT INTO pedidos VALUES (NULL, '$nombre', '$email', '$telefono', '$pedido')";
mysql_query($sql) or die("No puedo ejecutar el query!!");


?>

My html code to trigger this is on Jquery:
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/stylo.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.js" type="text/javascript" /> </script>
<script type="text/javascript">
$(document).ready(function(){

$("#response").hide();
$("#addComment").click(function() {


$.post(

'process.php',

{
nombre:$("#nombre").val(),
email:$("#email").val(),
telefono:$("#telefono").val(),
pedido:$("#pedido").val(),
},

function(response)
{
$("#response").fadeIn('fast');
$("#response").html("Pedido Enviado!!");
$("#nombre").val('');
$("#email").val(''),
$("#telefono").val(''),
$("#pedido").val('')
}

)

return false;

});




});

</script>
<title>PEDIDO AJAX </title>
</head>
<body>

<form id="commentform">
<label for = "nombre">Nombre:</label>
<input type="text" name="nombre" id= "nombre">
<br/>
<br/>
<label for = "email">Email o correo electrónico:</label>
<input type="text" name="email" id= "email">
<br/>
<br/>
<label for = "telefono">Número de teléfono:</label>
<input type="telefono" name="telefono" id= "telefono">
<br/>
<br/>
<label for = "pedido">Ingrese su pedido:</label>
<br/>
<textarea id="pedido" name="pedido" cols="40" rows="8"></textarea>

<input type="submit" id="addComment" value="Enviar!">
</form>

<div id="response"></div>

</body>
</html>

If doing on localhost or local computer
$host = 'locahost:8080';
$dbname = 'juan';
$user = 'root';
$pass = 'blah6';
Firebug says mysql server <b>Warning</b>: mysql_connect() [<a href='function.mysql-connect'>function.mysql-connect</a>]: MySQL server has gone away in <b>C:\xampp\htdocs\process.php</b> on line <b>8</b><br />
<br />




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users