Jump to content
php.lv forumi

Problēma ievadīt datus


ziedinjsh

Recommended Posts

Sveiki!

šādi pieslēdzot datubāzei:

<?php
mysql_connect("localhost", "root", "") or die(mysql_error()); 
mysql_select_db("sell") or die(mysql_error()); 
?>

 

un šādie ievadu datus{

<?php

if (isset($_GET['add_d7'])) {

$d7_name = $_POST['d7_name'];
$d7_size = $_POST['d7_size'];
$d7_demo = $_POST['d7_demo'];
$d7_link = $_POST['d7_link'];
$d7_buy = $_POST['d7_buy'];

$add = mysql_query("INSERT INTO `d7` (d7_name, d7_size, d7_demo, d7_link, d7_buy) VALUES ('$d7_name', '$d7_size', '$d7_demo', '$d7_link', '$d7_buy') ");
$result = mysql_query($sql);

if($result){
echo "All done!";
}else {
echo "ERROR";
}

}

echo "<form method='post' action='index.php?id=add_d7'>";
echo "<div id='add-d7'>";
echo "<div class='title'>File name</div><div class='input'><input type='text' name='d7_name' size='35'></div>";
echo "<div class='title'>File size</div><div class='input'><input type='text' name='d7_size' size='2'></div>";
echo "<div class='title'>Demo link</div><div class='input'><input type='text' name='d7_demo' size='60' ></div>";
echo "<div class='title'>Download link</div><div class='input'><input type='text' name='d7_link' size='60' ></div>";
echo "<div class='title'>Buy id</div><div class='input'><input type='text' name='d7_buy' size='2'></div>";
echo "<div class='fix'></div>";
echo "<center><input type='submit' name='add_d7' value='ADD' class='button'></center>";
echo "</div>";
echo "</form>";

?>

 

piespiežot pogu lapa vienkāršī refrešojas un viss.. informāciju iekš datubāzes neievada.. Kas par vainu??

Link to comment
Share on other sites

$sql = "?";

Tas $sql jau neko nedara.

Es kļūdu ķertu šitā, lai kods pats stāsta kas un kapēc nenotiek:

$connection=mysql_connect("localhost", "root", "") or die(mysql_error()); 
mysql_select_db("sell",$connection) or die(mysql_error()); 

if (isset($_GET['add_d7'])) {

echo "<br>GET nostrādāja<br><br>";

$d7_name = $_POST['d7_name'];
$d7_size = $_POST['d7_size'];
$d7_demo = $_POST['d7_demo'];
$d7_link = $_POST['d7_link'];
$d7_buy = $_POST['d7_buy'];

$q="INSERT INTO `d7` (d7_name, d7_size, d7_demo, d7_link, d7_buy) VALUES ('$d7_name', '$d7_size', '$d7_demo', '$d7_link', '$d7_buy')";
$add = mysql_query($q,$connection);

echo "<br>Query: ",$q,"<br><br>";
echo "<br>Error: ",mysql_error($connection),"<br><br>";

}

Edited by Rincewind
Link to comment
Share on other sites

<?php

if (isset($_GET['add_d7'])) {

$d7_name = $_POST['d7_name'];
$d7_size = $_POST['d7_size'];
$d7_demo = $_POST['d7_demo'];
$d7_link = $_POST['d7_link'];
$d7_buy = $_POST['d7_buy'];

$add = mysql_query("INSERT INTO `d7` (d7_name, d7_size, d7_demo, d7_link, d7_buy) VALUES ('$d7_name', '$d7_size', '$d7_demo', '$d7_link', '$d7_buy') ");
$result = mysql_query($sql);

if($result){
echo "All done!";
}else {
echo "ERROR";
}

}

echo "<form method='post' action='index.php?id=add_d7'>";
echo "<div id='add-d7'>";
echo "<div class='title'>File name</div><div class='input'><input type='text' name='d7_name' size='35'></div>";
echo "<div class='title'>File size</div><div class='input'><input type='text' name='d7_size' size='2'></div>";
echo "<div class='title'>Demo link</div><div class='input'><input type='text' name='d7_demo' size='60' ></div>";
echo "<div class='title'>Download link</div><div class='input'><input type='text' name='d7_link' size='60' ></div>";
echo "<div class='title'>Buy id</div><div class='input'><input type='text' name='d7_buy' size='2'></div>";
echo "<div class='fix'></div>";
echo "<center><input type='submit' name='add_d7' value='ADD' class='button'></center>";
echo "</div>";
echo "</form>";

?>

 

$result = mysql_query($sql);

if($result){
echo "All done!";
}else {
echo "ERROR";
}

 

Un ko tad dara šitas?

 

Un ko tu gribi ieraudzīt, kad informāciju ievieto?

Un viņu tev ievieto, vispār?

Edited by labaiss
Link to comment
Share on other sites

nu lab, tagad ievade ir šāda

<?php

if (isset($_GET['add_d7'])) {

echo "<br>GET nostrādāja<br><br>";

$d7_name = $_POST['d7_name'];
$d7_size = $_POST['d7_size'];
$d7_demo = $_POST['d7_demo'];
$d7_link = $_POST['d7_link'];
$d7_buy = $_POST['d7_buy'];

$q="INSERT INTO `d7` (d7_name, d7_size, d7_demo, d7_link, d7_buy) VALUES ('$d7_name', '$d7_size', '$d7_demo', '$d7_link', '$d7_buy')";
$add = mysql_query($q,$connection);

echo "<br>Query: ",$q,"<br><br>";
echo "<br>Error: ",mysql_error($connection),"<br><br>";

}

echo "<form method='post' action='index.php?id=add_d7'>";
echo "<div id='add-d7'>";
echo "<div class='title'>File name</div><div class='input'><input type='text' name='d7_name' size='35'></div>";
echo "<div class='title'>File size</div><div class='input'><input type='text' name='d7_size' size='2'></div>";
echo "<div class='title'>Demo link</div><div class='input'><input type='text' name='d7_demo' size='60' ></div>";
echo "<div class='title'>Download link</div><div class='input'><input type='text' name='d7_link' size='60' ></div>";
echo "<div class='title'>Buy id</div><div class='input'><input type='text' name='d7_buy' size='2'></div>";
echo "<div class='fix'></div>";
echo "<center><input type='submit' name='add_d7' value='ADD' class='button'></center>";
echo "</div>";
echo "</form>";

?>

 

bet informāciju datubāzē neievadās :?

Edited by ziedinjsh
Link to comment
Share on other sites

Atrodi 10 atšķirības starp (isset($_GET['id']) AND $_GET['id']=='add_d7') un (isset($_GET['add_d7']))

Tak liec kaut vai pēc katras koda rindiņas kādu teksa izvadīšanu, lai pats saprastu, kas nostrādā un kas nē...

Link to comment
Share on other sites

šo pārveido

$add = mysql_query("INSERT INTO `d7` (d7_name, d7_size, d7_demo, d7_link, d7_buy) VALUES ('$d7_name', '$d7_size', '$d7_demo', '$d7_link', '$d7_buy') ");
$result = mysql_query($sql);

 

šādi:

$sql="INSERT INTO `d7` (d7_name, d7_size, d7_demo, d7_link, d7_buy) VALUES ('$d7_name', '$d7_size', '$d7_demo', '$d7_link', '$d7_buy')";
$result=mysql_query($sql);

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...