Skip navigation links

MySQL Forums :: Spanish :: Necesito ayuda con un codigo mysql


Advanced Search

Necesito ayuda con un codigo mysql
Posted by: Axel Fantini ()
Date: June 08, 2013 04:37PM

Hola, como verán el titulo necesito ayuda con un codigo para insertar datos en mysql, lo que pasa es que, sí , se envian los datos, pero llegan los datos de texto en una row, y los datos de imagen llegan en otra row. Aver si me pueden ayudar...

<?php
/**************************************************************************************************
| F My Script
| http://www.fmyscript.com
| webmaster@fmyscript.com
|
|**************************************************************************************************
|
| By using this software you agree that you have read and acknowledged our End-User License
| Agreement available at http://www.fmyscript.com/eula.html and to be bound by it.
|
| Copyright (c) 2010 fmyscript.com. All rights reserved.
|**************************************************************************************************/

include("include/config.php");
include("include/functions/import.php");

function banned_words_chk($phrase)
{
global $conn, $config;
$query = "SELECT word from bans_words";
$executequery = $conn->Execute($query);
$bwords = $executequery->getarray();
$found = 0;
$words = explode(" ", $phrase);
foreach($words as $word)
{
foreach($bwords as $bword)
{
if(strtolower($word) == strtolower($bword[0]))
{
$found = 1;
}
}
}
if($found == "1")
{
return true;
}
else
{
return false;
}
}

if($_REQUEST[substory]!="")
{
$username = htmlentities(strip_tags($_REQUEST[uname]), ENT_COMPAT, "UTF-8");
$username = str_replace("(", "", $username);
$username = str_replace(")", "", $username);
$USERID = intval($_REQUEST[uid]);
$gender = stripslashes($_REQUEST[gender]);
$cat = stripslashes($_REQUEST[cat]);
$email = $_REQUEST; $clen = strlen($content); $captcha = stripslashes($_REQUEST['captcha']); if($_SESSION['USERID'] == &quot;&quot;) { if($username != &quot;&quot;) { if(!verify_email_username($username)) { $error=&quot;1&quot;; echo &quot;error1&quot;; exit; } } } if ($username == &quot;&quot;) { $username = &quot;Anonymous&quot;; } if ($gender == &quot;&quot; || !is_numeric($gender)) { $error=&quot;2&quot;; echo &quot;error2&quot;; } elseif ($cat == &quot;&quot; || !is_numeric($cat)) { $error=&quot;4&quot;; echo &quot;error4&quot;; } elseif($email != &quot;&quot; &amp;&amp; !verify_valid_email($email)) { $error = &quot;3&quot;; echo &quot;error3&quot;; } elseif($clen &lt; 0) { $error = &quot;5&quot;; echo &quot;error5&quot;; } elseif($captcha != $_SESSION['imagecode']) { $error = &quot;6&quot;; echo &quot;error6&quot;; } elseif(banned_words_chk($content)) { $error = &quot;7&quot;; echo &quot;error7&quot;; } if ($error == &quot;&quot;) { $approve_stories = $config['approve_stories']; if($approve_stories == &quot;1&quot;) { $active = &quot;0&quot;; } else { $active = &quot;1&quot;; } $query=&quot;INSERT INTO posts SET USERID='&quot;.mysql_real_escape_string($USERID).&quot;', username='&quot;.mysql_real_escape_string($username).&quot;', category='&quot;.mysql_real_escape_string($cat).&quot;', gender='&quot;.mysql_real_escape_string($gender).&quot;', email='&quot;.mysql_real_escape_string($email).&quot;', time_added='&quot;.time().&quot;', date_added='&quot;.date(&quot;Y-m-d&quot;).&quot;', active='$active', pip='&quot;.$_SERVER['REMOTE_ADDR'].&quot;'&quot;; $result=$conn-&gt;execute($query); $pid = mysql_insert_id(); echo &quot;ok&quot;; if ($active == &quot;1&quot; &amp;&amp; $email != &quot;&quot;) { $catname = get_cat($cat); $slink = $config['baseurl'].&quot;/view/&quot;.$catname.&quot;/&quot;.$pid; $sendto = $email; $sendername = $config['site_name']; $from = $config['site_email']; $subject = $lang['73']; $sendmailbody= $lang['74'].&quot;&lt;br&gt;&quot;.$slink.&quot;&lt;br&gt;&lt;br&gt;&quot;.$lang['75'].&quot;&lt;br&gt;&quot;.$sendername; mailme($sendto,$sendername,$from,$subject,$sendmailbody,$bcc=&quot;&quot;); } # Conectamos con la base de datos $link=mysql_connect(&quot;mysql11.000webhost.com&quot;,&quot;a2831153_axelf&quot;,&quot;deaxel123&quot;); mysql_select_db(&quot;a2831153_datos&quot;,$link); echo &quot;&lt;BR&gt;&quot;.$_FILES[&quot;userfile&quot;][&quot;name&quot;]; //nombre del archivo echo &quot;&lt;BR&gt;&quot;.$_FILES[&quot;userfile&quot;][&quot;type&quot;]; //tipo echo &quot;&lt;BR&gt;&quot;.$_FILES[&quot;userfile&quot;][&quot;tmp_name&quot;]; //nombre del archivo de la imagen temporal echo &quot;&lt;BR&gt;&quot;.$_FILES[&quot;userfile&quot;][&quot;size&quot;]; //tamaño # Comprovamos que se haya subido un fichero if (is_uploaded_file($_FILES[&quot;userfile&quot;][&quot;tmp_name&quot;])) { # Cogemos el formato de la imagen if ($_FILES[&quot;userfile&quot;][&quot;type&quot;]==&quot;image/jpeg&quot; || $_FILES[&quot;userfile&quot;][&quot;type&quot;]==&quot;image/pjpeg&quot; || $_FILES[&quot;userfile&quot;][&quot;type&quot;]==&quot;image/gif&quot; || $_FILES[&quot;userfile&quot;][&quot;type&quot;]==&quot;image/bmp&quot; || $_FILES[&quot;userfile&quot;][&quot;type&quot;]==&quot;image/png&quot;) { # Cogemos la anchura y altura de la imagen $info=getimagesize($_FILES[&quot;userfile&quot;][&quot;tmp_name&quot;]); echo &quot;&lt;BR&gt;&quot;.$info[0]; //anchura echo &quot;&lt;BR&gt;&quot;.$info[1]; //altura echo &quot;&lt;BR&gt;&quot;.$info[2]; //1-GIF, 2-JPG, 3-PNG echo &quot;&lt;BR&gt;&quot;.$info[3]; //cadena de texto para el tag &lt;img # Escapa caracteres especiales $imagenEscapes=mysql_real_escape_string(file_get_contents($_FILES[&quot;userfile&quot;][&quot;tmp_name&quot;])); # Agregamos la imagen a la base de datos $result=mysql_query(&quot;INSERT INTO `posts` (anchura,altura,tipo,imagen) VALUES (&quot;.$info[0].&quot;,&quot;.$info[1].&quot;,'&quot;.$_FILES[&quot;userfile&quot;][&quot;type&quot;].&quot;','&quot;.$imagenEscapes.&quot;')&quot;,$link); # Cogemos el identificador con que se ha guardado $id=mysql_insert_id(); }else{ $error=&quot;El formato de archivo tiene que ser JPG, GIF, BMP o PNG.&quot;; } }else{ $error=&quot;No ha seleccionado ninguna imagen...&quot;; } if ($error!=&quot;&quot;) { echo &quot;&lt;/center&gt;&lt;P&gt;&lt;font face='Arial' size=2 color='#ff0000'&gt; Error: &quot;.$error.&quot;&lt;/font&gt;&lt;br&gt;&quot;; } } } ?&gt; Desde ya muchas gracias Edited 1 time(s). Last edit at 06/08/2013 04:39PM by Axel Fantini.

Options: ReplyQuote


Subject Views Written By Posted
Necesito ayuda con un codigo mysql 655 Axel Fantini 06/08/2013 04:37PM
Re: Necesito ayuda con un codigo mysql 238 Jesús Uzcanga 06/11/2013 09:33AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.