Why dont save in mysql

software development

#1

Hi,
my site works perfectly in local, but i upload, i change the mysql conection settings and the site show the records in the tables, but no update and no insert new records, and no show any error.
this the way i use:
file: sconexion.php

<?php $hostname_conn = "--";//servidor donde corre mysql $database_conn = "--";//base de datos $username_conn = "--";//usuario de mysql $password_conn = "--";//pass del usuario de mysql //la conexion $conn = mysql_connect($hostname_conn, $username_conn, $password_conn) or die(mysql_error()); ?>

file: saveNoticia.php

<?php $id = $_POST["id"]; $titulo = $_POST["titulo"]; $texto = $_POST["texto"]; @require_once('..\default.php'); $titulo = fixMagicQuotes($titulo); $texto = fixMagicQuotes($texto); $fecha = $_POST["fecha"]; require_once('../phps/sconexion.php'); // Convert spanish date to mysql date $fecha = guardarFechaMySQL($fecha); mysql_select_db($database_conn, $conn); $texto = mysql_real_escape_string($texto); if($id==0){ $query="INSERT INTO noticias (titulo,texto,fecha) VALUES ('$titulo','$texto','$fecha')"; }else{ $query="UPDATE noticias SET titulo='$titulo', texto='$texto', fecha='$fecha' WHERE id=$id"; } $resultado = mysql_query($query); if(!($resultado)){ $respuesta = mysql_error(); echo "$respuesta"; exit; }else{ $respuesta = ""; } ?>

thank’s for your help


#2

First Please remove your hostname, table name, username, and password.

If anything is wrong with my sql query, I always echo the query to check. You can first try to echo $query before it executes and see whether it is what you expect.

It is so strange that you do not see any error message. Is it possible that your text color is same as your background color. If so, you can see the text by pressy Ctr A to highlight all texts on the page.

Save $97 (MAX Discount) with code: [color=#CC0000]97YES[/color] Sign Up NOW or More Codes Here


#3

ty, but nothing is incorrect in the query, in fact, in localhost works perfectly.

if i use the files in my computer and the conection to mysql in the server works again, ( localhost\miweb ), but fail if i use the files in the web server ( www.midominio.com ).

if i use IE work but no save changes and no insert new records, if i use Firefox then said the folow error:
Service Temporarily Unavailable

The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.

???


#4

Where is this file located? Is it inside “yourdomain.com” folder?

Save $97 (MAX Discount) with code: [color=#CC0000]97YES[/color] Sign Up NOW or More Codes Here


#5

yes, this file is in the web server inside midomain.com, conexions works because i can see the data in the tables of db, only thing that i can’t do is update, insert and delete records.


#6

This is so strange. If it is not working, you should see some error messages at least. Can you run a phpinfo() to see whether display_error_message is on?

Save $97 (MAX Discount) with code: [color=#CC0000]97YES[/color] Sign Up NOW or More Codes Here


#7

Hi patricktan,

display_errors On On
display_startup_errors Off Off

this is the information showed by phpinfo(),
i see that the version of mysql client api in the web server is 5.0.16, in the webserver phpMyAdmin show a message that said:
Your library version of PHP MySQL 5.0.16 is distinct of the server version of MySQL 5.0.24a. This can provide inesperated results.

Sorry for my english.


#8

@require_once(’…\default.php’); What is this?

Why don’t we see any error message!@#)(*@#$

Can you post a test link for us to analyze? If we still can’t figure it out, I think the last solution is to send a ticket to DH support. :frowning:

Save $97 (MAX Discount) with code: [color=#CC0000]97YES[/color] Sign Up NOW or More Codes Here


#9

default.php its a general store for functions that i use in much proyects (convert dates from spanish to mysql, …)

try it in www.ytalipeluqueros.com/pasarin/admin, push the “Noticias” button.

Try it with IE and with Firefox.
???


#10

Does it affect the result if default.php is not loaded? I’m not sure whether it should be require_once("…/default.php"); or not.

your site is very slow to me. It takes a very very long time to load the page using FireFox. I am able to load it using IE but with “error on page” at the bottom left corner.

When I tried to click Eliminar, I saw an error message “Access denied for user xxxxx”. When I tried to click Guardar, I saw a blank page with “error on page”.

Save $97 (MAX Discount) with code: [color=#CC0000]97YES[/color] Sign Up NOW or More Codes Here


#11

@require_once(’…\default.php’); <-- this wont work at DH as it’s in windows format. Linux paths are marked with forward slashes “/” not back slashes.

No error is shown because using “@” at the start of the line hides all errors. It’s bad practice to code hiding errors. It makes things harder to debug as you have just found out. Also if things go wrong you should use proper error handling to deal with it, not just suppress the error and carry on with the script


#12

ty ecvej
the slash i have in the server is in Linux format, changed this friday, but i copy the lines from my local pc. The problem isn’t this one. I know that @ hides all errors, and i tested the page removing all @, but no error showed.
Now it show an error that said “Interfaz no compatible” when click in save “Guardar” button.


#13

Try the script in its simplest form to get it working. IE feed it values rather than determine them. This will narrow down where the problem is.

Also please confirm you are using a DH SQL server and that you have granted insert and update permission to the database user?