Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2010-08-19
31
Medium Priority
?
445 Views
Last Modified: 2013-12-13
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
--------------------------------------------------------------------------------------------------------------
0
Comment
Question by:altariamx2003
  • 14
  • 11
  • 6
31 Comments
 
LVL 61

Accepted Solution

by:
HainKurt earned 1000 total points
ID: 33477994
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
 

Author Comment

by:altariamx2003
ID: 33478100
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
 
LVL 61

Expert Comment

by:HainKurt
ID: 33478217
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:altariamx2003
ID: 33478367
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
 
LVL 2

Assisted Solution

by:Tiller79188231
Tiller79188231 earned 1000 total points
ID: 33478619


$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
 
LVL 61

Expert Comment

by:HainKurt
ID: 33478820
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
 
LVL 61

Expert Comment

by:HainKurt
ID: 33478884
also remove confidential data from http://www.itssc.edu.mx/phpcode.txt ;) like dbname pw login etc...
0
 

Author Comment

by:altariamx2003
ID: 33479093
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
 
LVL 2

Expert Comment

by:Tiller79188231
ID: 33479251
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
 
LVL 61

Expert Comment

by:HainKurt
ID: 33479369
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
 
LVL 61

Expert Comment

by:HainKurt
ID: 33479388
can you please post the screen for this data (mysql), so we can have a clear picture of whats happening here...
0
 
LVL 61

Expert Comment

by:HainKurt
ID: 33479431
also remove any confidential data for

$ftpuser = "xxx";
$ftppass = "xxxxxxx";
$ftppath = "xxxxxxxxxxxxxxxx";
0
 

Author Comment

by:altariamx2003
ID: 33480713
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
 

Author Comment

by:altariamx2003
ID: 33480739
sorry this is the link for the information saved on database: http://www.itssc.edu.mx/information-saved-on-database3.jpg
0
 

Author Comment

by:altariamx2003
ID: 33480752
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
 
LVL 61

Expert Comment

by:HainKurt
ID: 33481085
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
 
LVL 61

Expert Comment

by:HainKurt
ID: 33481108
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
 
LVL 61

Expert Comment

by:HainKurt
ID: 33481128
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
 

Author Comment

by:altariamx2003
ID: 33481723
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
 

Author Comment

by:altariamx2003
ID: 33481728
As you see on the information saved on the database the data from the ny times aritcle is also incomplete

0
 
LVL 2

Expert Comment

by:Tiller79188231
ID: 33484425
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
 

Author Comment

by:altariamx2003
ID: 33485629
ok

tiller

just let me change the sintax because if I add your code as you post it always show me errors
0
 
LVL 2

Expert Comment

by:Tiller79188231
ID: 33485945
there doesn't appear to be any errors in the syntax... can you post what the error is that your getting?
0
 

Author Comment

by:altariamx2003
ID: 33485989
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
 

Author Comment

by:altariamx2003
ID: 33486040
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
 
LVL 2

Expert Comment

by:Tiller79188231
ID: 33486161
so once you made those changes it worked?
0
 

Author Comment

by:altariamx2003
ID: 33486324
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
 
LVL 2

Expert Comment

by:Tiller79188231
ID: 33486419
I would check your mysql installation, maybe reinstall and reinstall the service, with the most current version because the php is setup correctly
0
 

Author Comment

by:altariamx2003
ID: 33486483
last night I reinstall php and mysql on my local server and the problem remains
0
 

Author Comment

by:altariamx2003
ID: 33488095
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

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

963 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question