Why the record on my database is incomplete??????

First of all

Thanks for all your help, you guys are incredible and a huge help for me.

Im doing the administrative section to add new articles for the news section for http://www.itssc.edu.mx.

In this this page (the administrative) the user can add new articles with a main photo and if he wants a gallery also.

The administrative part for http://www.itssc.edu.mx is located in the local server (localhost), let me explain why is there and not in the remote server.

Sometimes the user wants to add a gallery to the article, to avoid the problem of the size of the images, I dedice to storage this part in localhost to resize the images for the gallery to smallest sizes and after that send them by ftp to my remote server.

And here is the problem, after the last image is send to our remote server by ftp I connect the remote database (In the same page) to add the new article but when I check if the information of the article was successfully saved in my database the data are incomplete.

I would like to know why everytime that I want to add a new article to my database the information is saved but incomplete.

I made a little example about this problem

I hope you can help me.
--------------------------------------------------------------------------------------------------------------
1.- In this link you can see the information to upload. http://www.itssc.edu.mx/information-to-upload.jpg
--------------------------------------------------------------------------------------------------------------
2.- In this link you can see the information saved in our database.  http://www.itssc.edu.mx/information-saved-on-database.jpg
--------------------------------------------------------------------------------------------------------------
3.- In this link you can see the estructure of my database.   http://www.itssc.edu.mx/database-estructure.jpg
--------------------------------------------------------------------------------------------------------------
Also I you need in this two last link are the phpcode and the form that I use for this page
http://www.itssc.edu.mx/form.txt
http://www.itssc.edu.mx/phpcode.txt
--------------------------------------------------------------------------------------------------------------
altariamx2003Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

HainKurtSr. System AnalystCommented:
are you sure data is not stored in db correctly?
maybe it is stored but you have issues when fetching or displaying...
did you check page source from browser to see the actual code?
did you check the table what is stored?

what is happening if you remove this line

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
altariamx2003Author Commented:
Hi HainKurt

yes im sure that the data is not stored correctly.

In this link you can see what Im try to upload: http://www.itssc.edu.mx/information-to-upload.jpg

In this link you can see the information storaged in my db:  http://www.itssc.edu.mx/information-saved-on-database.jpg, as you can see the information is incomplete.

look this is how you see in the news section on itssc.edu.mx: http://www.itssc.edu.mx/noticias/detalle.php?recordID=471101120

I think the code is Ok, because I upload the same page but on http://www.itssc.edu.mx not in localhost and the record was storage ok.

I remove the line that you suggest and nothing change the record is storage incomplete: http://www.itssc.edu.mx/noticias/detalle.php?recordID=471101254
0
HainKurtSr. System AnalystCommented:
maybe the tool that you use to view data is not showing properly... do you have any other tool to browse the database? can you update the record from the tool that you are using? put the same values and update from tool and see the data from your page...
0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

altariamx2003Author Commented:
This is how it look the information after that I update it using phpmyadmin: http://www.itssc.edu.mx/noticias/detalle.php?recordID=471101254

In this link you can see the information upated on phpmyadmin: http://www.itssc.edu.mx/information-saved-on-database2.jpg
----------------------------------------------------------------------------------------------------------------------------
let me show you the data of other article storage using the same code but with the page located on http://www.itssc.edu.mx

this is the information on my database using phpmyadmin (provided by hostgator): http://www.itssc.edu.mx/information-saved-on-database1.jpg. As you can see the problem is not my phpadmin because this new record was storaged ok.

And this is how this new record look in the news section of itssc.edu.mx: http://www.itssc.edu.mx/noticias/detalle.php?recordID=8
-----------------------------------------------------------------------------------------------------------------------------
0
Tiller79188231Commented:


$insertSQL = "INSERT INTO noticias (clave, titulo, fecha, lugar, resumen, cuerpo, foto, galeria) VALUES ("
.mysql_real_escape_string($_POST['clave'])"., "
.mysql_real_escape_string($_POST['titulo'])"., "
.mysql_real_escape_string($_POST['fecha'])"., "
.mysql_real_escape_string($_POST['lugar'])"., "
.mysql_real_escape_string($_POST['resumen'])"., "
.mysql_real_escape_string$_POST['cuerpo'])"., "
.mysql_real_escape_string$_POST['foto'])"., "
.mysql_real_escape_string$_POST['galeria'])".")";
               
$rs = mysql_query($insertSQL, $dbnotes) or die(mysql_error());
0
HainKurtSr. System AnalystCommented:
can you please post the value of $insertSQL before these lines

>>>> print the value of $insertSQL somehow at this point with a sample data
mysql_select_db($database_dbnotes, $dbnotes);
$Result1 = mysql_query($insertSQL, $dbnotes) or die(mysql_error());

so we can see what is wrong...
0
HainKurtSr. System AnalystCommented:
also remove confidential data from http://www.itssc.edu.mx/phpcode.txt ;) like dbname pw login etc...
0
altariamx2003Author Commented:
this is the result:

INSERT INTO noticias (clave, titulo, fecha, lugar, resumen, cuerpo, foto, galeria) VALUES ('471101425', 'Arturo Chávez defiende figura del arraigo', '2010-08-19', 'ciudad de mexico', 'El procurador Arturo Chávez asegura que este instrumento legal con mucha frecuencia da mayor eficacia al trabajo de la dependencia', 'El procurador Arturo Chávez Chávez defendió la figura del arraigo y los testigos protegidos ante las criticas de Carlos Navarrete (PRD) presidente del Senado.\r\n\r\nDurante los Diálogos por la Seguridad, encabezados por el presidente Felipe Calderón, en el Campo Militar Marte, el legislador cuestionó el abuso y a utilización equivocada de estos instrumentos legales.\r\n\r\nEl titular de la Procuraduría General de la República (PGR) dijo que la figura del arraigo con mucha frecuencia da mayor eficacia al trabajo de esta dependencia.\r\n\r\nDijo que del total de arraigos obtenidos por la PGR, el 90% es consignado ante un juez. De ellos, al 90% se le libra orden de aprehensión, y de esta cifra, al menos al 90% le es dictado auto de formal prisión.\r\n\r\nSin embargo, cuando Navarrete le preguntó que a final cuántas resultan sentenciadas, el procurador admitió no tener la cifra, además de que hay caso a que todavía están en litigio en tribunales. ', 'IMG_6731.JPG', '0')
0
Tiller79188231Commented:
just a hunch... but are you setting the  CHARACTER SET  to latin1_spanish ?.. because the data is being truncated whenever it hits one of those characters
0
HainKurtSr. System AnalystCommented:
so no issue with query ;) good... so problem should be character sets... do you have any other tool to run this query and see if it is stored in db correctly?
INSERT INTO noticias (clave, titulo, fecha, lugar, resumen, cuerpo, foto, galeria) 
VALUES (
'471101425', 
'Arturo Chávez defiende figura del arraigo', 
'2010-08-19', 
'ciudad de mexico', 
'El procurador Arturo Chávez asegura que este instrumento legal con mucha frecuencia da mayor eficacia al trabajo de la dependencia', 
'El procurador Arturo Chávez Chávez defendió la figura del arraigo y los testigos protegidos ante las criticas de Carlos Navarrete (PRD) presidente del Senado.\r\n\r\nDurante los Diálogos por la Seguridad, encabezados por el presidente Felipe Calderón, en el Campo Militar Marte, el legislador cuestionó el abuso y a utilización equivocada de estos instrumentos legales.\r\n\r\nEl titular de la Procuraduría General de la República (PGR) dijo que la figura del arraigo con mucha frecuencia da mayor eficacia al trabajo de esta dependencia.\r\n\r\nDijo que del total de arraigos obtenidos por la PGR, el 90% es consignado ante un juez. De ellos, al 90% se le libra orden de aprehensión, y de esta cifra, al menos al 90% le es dictado auto de formal prisión.\r\n\r\nSin embargo, cuando Navarrete le preguntó que a final cuántas resultan sentenciadas, el procurador admitió no tener la cifra, además de que hay caso a que todavía están en litigio en tribunales. ', 
'IMG_6731.JPG', 
'0'
)

Open in new window

0
HainKurtSr. System AnalystCommented:
can you please post the screen for this data (mysql), so we can have a clear picture of whats happening here...
0
HainKurtSr. System AnalystCommented:
also remove any confidential data for

$ftpuser = "xxx";
$ftppass = "xxxxxxx";
$ftppath = "xxxxxxxxxxxxxxxx";
0
altariamx2003Author Commented:
ok

this is the new example:

information to upload: http://www.itssc.edu.mx/information-to-upload1.jpg

information saved on database: http://www.itssc.edu.mx/information-saved-on-database2.jpg

if you enter to itssc.edu.mx the article looks incomplete: http://www.itssc.edu.mx/noticias/detalle.php?recordID=471101430

0
altariamx2003Author Commented:
sorry this is the link for the information saved on database: http://www.itssc.edu.mx/information-saved-on-database3.jpg
0
altariamx2003Author Commented:
I think that is not the CHARACTER SET, I save the page directly on itssc.edu.mx and generate a new record

and this is the result:

link for the information saved on the database: http://www.itssc.edu.mx/information-saved-on-database4.jpg

link to see the article on itssc.edu.mx: http://www.itssc.edu.mx/noticias/detalle.php?recordID=1
0
HainKurtSr. System AnalystCommented:
so you say, if you save data correctly, it will display correctly.
and the tool to insert /update record directly is working fine...

then the only issue is my_sql is cutting the values when inserting into table
is this correct? when I say character set, I mean when you connect to mySQL, maybe there is a setting to say "I will work with spanish" so it can handle special characters properly...
0
HainKurtSr. System AnalystCommented:
one more test... instead of spanish character, can you please add just plain english like this one

This is a plain text!.. This is a plain text!.. This is a plain text!.. This is a plain text!.. This is a plain text!.. This is a plain text!.. This is a plain text!.. This is a plain text!.. This is a plain text!.. This is a plain text!.. This is a plain text!.. This is a plain text!.. This is a plain text!.. This is a plain text!.. This is a plain text!.. This is a plain text!.. This is a plain text!.. This is a plain text!.. This is a plain text!.. This is a plain text!.. This is a plain text!.. This is a plain text!.. This is a plain text!.. This is a plain text!.. This is a plain text!.. This is a plain text!.. This is a plain text!.. This is a plain text!.. This is a plain text!.. This is a plain text!.. This is a plain text!.. This is a plain text!.. This is a plain text!.. This is a plain text!.. This is a plain text!..

and see if it is stored correctly.
0
HainKurtSr. System AnalystCommented:
check this

http://www.saiweb.co.uk/mysql/mysql-forcing-utf-8-compliance-for-all-connections

looks like you are using some old drivers or need to set something after connection is established...
0
altariamx2003Author Commented:
Hi

I took this info from the new york times

information to upload: http://www.itssc.edu.mx/information-to-upload2.jpg

information saved on database: http://www.itssc.edu.mx/information-saved-on-database5.jpg

informaiton on itssc.edu.mx:http://www.itssc.edu.mx/information-on-itssc.jpg

0
altariamx2003Author Commented:
As you see on the information saved on the database the data from the ny times aritcle is also incomplete

0
Tiller79188231Commented:
can you please refer to my earlier post about the structure of the sql insert statement??
GetSQLValueString doesn't properly escape characters.. which is why your having this problem
0
altariamx2003Author Commented:
ok

tiller

just let me change the sintax because if I add your code as you post it always show me errors
0
Tiller79188231Commented:
there doesn't appear to be any errors in the syntax... can you post what the error is that your getting?
0
altariamx2003Author Commented:
Hi tiller I change you a little bit your code and I made an example and this is the result:

information to upload: http://www.itssc.edu.mx/information-to-upload3.jpg

information saved on database: http://www.itssc.edu.mx/information-saved-on-database6.jpg

informaiton on itssc.edu.mx:http://www.itssc.edu.mx/information-on-itssc1.jpg

I took the data from the nytimes: http://www.nytimes.com/2010/05/20/science/earth/20noaa.html?_r=1&hp
$clave1 = mysql_real_escape_string($_POST['clave']);
  $titulo1 = mysql_real_escape_string($_POST['titulo']);
  $fecha1 = mysql_real_escape_string($_POST['fecha']);
  $lugar1 = mysql_real_escape_string($_POST['lugar']);
  $resumen1 = mysql_real_escape_string($_POST['resumen']);
  $cuerpo1 = mysql_real_escape_string($_POST['cuerpo']);
  $foto1 = mysql_real_escape_string($_POST['foto']);
  $galeria1 = mysql_real_escape_string($_POST['galeria']);
  
  
  
 $insertSQL = "INSERT INTO noticias (clave, titulo, fecha, lugar, resumen, cuerpo, foto, galeria) VALUES ('$clave1','$titulo1','$fecha1','$lugar1','$resumen1','$cuerpo1','$foto1','$galeria1')";

Open in new window

0
altariamx2003Author Commented:
this is the error that I have If I use your code just like that:

Parse error: parse error in C:\wamp\www\noticias\altas_test4.php on line 124

the line 124 is: $insertSQL = "INSERT INTO noticias (clave, titulo, fecha, lugar, resumen, cuerpo, foto, galeria) VALUES (".mysql_real_escape_string($_POST['clave'])"., ".mysql_real_escape_string($_POST['titulo'])"., ".mysql_real_escape_string($_POST['fecha'])"., ".mysql_real_escape_string($_POST['lugar'])"., ".mysql_real_escape_string($_POST['resumen'])"., ".mysql_real_escape_string$_POST['cuerpo'])"., ".mysql_real_escape_string$_POST['foto'])"., ".mysql_real_escape_string$_POST['galeria'])".")";
0
Tiller79188231Commented:
so once you made those changes it worked?
0
altariamx2003Author Commented:
nop, the record isnt complete

this is the result of the example that I made using mysql_real_escape_string

information to upload: http://www.itssc.edu.mx/information-to-upload3.jpg

information saved on database: http://www.itssc.edu.mx/information-saved-on-database6.jpg

informaiton on itssc.edu.mx:http://www.itssc.edu.mx/information-on-itssc1.jpg

I took the data from the nytimes: http://www.nytimes.com/2010/05/20/science/earth/20noaa.html?_r=1&hp
0
Tiller79188231Commented:
I would check your mysql installation, maybe reinstall and reinstall the service, with the most current version because the php is setup correctly
0
altariamx2003Author Commented:
last night I reinstall php and mysql on my local server and the problem remains
0
altariamx2003Author Commented:
I test an alternative solution and it works!!!

I move the part when I connect the database  and when I add the new article to a new php file, this new php file is located in itssc.edu.mx.

The php variables from the form in php file located in localhost I send them by POST using curl to the PHP file located in my remote server

I know this is not the best solution but at leat it works
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.