ruano84 Posted November 2, 2006 Share Posted November 2, 2006 Hi,I am having throuble with a temporary table. I cant create it, fill it and even select it, but every time i access it, the data is corrupted. This is the code to create it:(The query is supposed to be ?sec=xx&art=yy&cant=zz)[code]<?php$ref=apache_request_headers();setcookie("origen",$ref['Referer']);setcookie("query",$_SERVER['QUERY_STRING']);session_start();if(!isset($_SESSION["nombre"])){ session_write_close(); header("location:ingresar.php"); //To the registration page}else{ $dbh=mysql_pconnect ("localhost", "interglo_admin") or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db("interglo_Users"); $id=session_id(); parse_str($_COOKIE["query"]); mysql_query("CREATE TEMPORARY TABLE IF NOT EXISTS cart$id (cat char(255),id int, cantidad int)"); mysql_query("INSERT INTO cart$id (cat,id,cantidad) VALUES ('$sec','$art','$cant')"); header("location:".$_COOKIE["origen"]);}?>[/code]And this is the code for access it:[code]<?phpsession_start();if($err==0){ $_SESSION["nombre"]=$row[0]." ".$row[1]; $_SESSION["cedula"]=$row[2]; $_SESSION["fijo"]=$row[3]."-".$row[4]; $_SESSION["cel"]=$row[5]."-".$row[6]; $_SESSION["direccion"]=$row[7]; $_SESSION["email"]=$row[8]; if(isset($_COOKIE["query"])) header("location:add.php?".$_COOKIE["query"]);} if($_SERVER['QUERY_STRING']=="sec=v_cart"){ $dbh=mysql_pconnect ("localhost", "interglo_admin") or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db ("interglo_Users"); echo mysql_error(); $res=mysql_query("SELECT * FROM cart$id"); //The shopping cart echo mysql_error(); $aff=mysql_affected_rows(); echo $id." ".$aff."<br>"; echo mysql_error(); if($aff==0){ ?> Aún no has agregado artículos a tu carro de compras.<br> <?php }else{ $dbh1=mysql_connect("localhost","interglo_admin"); mysql_select_db("interglo_productos"); //The products for($i=0;$i<$aff;$i++){ $fetch=mysql_fetch_row($res); echo $i." ".$fetch[0]." ".$fetch[1]."<br>"; $res1=mysql_query("SELECT * FROM ".$fetch[0]." WHERE id=".$fetch[1]); echo mysql_error(); $fetch1=mysql_fetch_row($res1); echo $fetch1[1]." ".$fetch[2]." ".$fetch[3]."<br>"; } }$id=session_id();[/code]I hope somebody can help meAlexis RR Link to comment https://forums.phpfreaks.com/topic/25914-temporary-table-generates-corrupt-data/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.