•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the MySQL section within the Web Development category of DaniWeb, a massive community of 403,212 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,773 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MySQL advertiser: Programming Forums
Views: 447 | Replies: 1 | Solved
![]() |
| |
I am able to connect to the database and located the table. I am unable to populate the db. Attached is a in image of the phpmyadmin trucks table structure. Please help. I am excited to be so close to getting it right.
The stuff preceding the above....
echo '<blockquote><blockquote><blockquote>';
echo '<form method="post" action="/inventory/">';
echo '<input type="submit" name="validated_confirmed_update" value="• • • Update Inventory • • •"></form>';
echo '</blockquote></blockquote></blockquote>';
$db_connection = @mysql_connect("----------------------.net", "--------------", "----------------");
if (!$db_connection) {
echo( "<P>Unable to connect to the database server at this time.</P>" );
exit();
}
$db = @mysql_select_db("---------", $db_connection);
if(!$db) {
echo( "<P>Unable to locate the database at this time.</P>" );
exit();
}
if ("submit" == $validated_confirmed_update) {
$sql = "INSERT INTO trucks SET " .
"relpath-box1='$data[0]', " .
"relpath-box2='$data[1]' ," .
"relpath-box3='$data[2]' ," .
"relpath-box4='$data[3]' ," .
"relpath-primary='$data[4]' ," .
"relpath-gallery1='$data[5]' ," .
"relpath-gallery2='$data[6]' ," .
"relpath-gallery3='$data[7]' ," .
"year='$year' ," .
"make='$make' ," .
"model='$model' ," .
"miles='$miles' ," .
"comment='$comment' ," .
"option1='$option1' ," .
"option2='$option1' ," .
"option3='$option1' ," .
"option4='$option1' ," .
"option5='$option1' ," .
"option6='$option1' ," .
"option7='$option1' ," .
"option8='$option1' " ;
mysql_query($sql);
}The stuff preceding the above....
<?php session_start(); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns='http://www.w3.org/1999/xhtml' xmlns:b='http://www.google.com/2005/gml/b' xmlns:data='http://www.google.com/2005/gml/data' xmlns:expr='http://www.google.com/2005/gml/expr' xml:lang="en">
<body>
<div id="whole_page">
<div id="header">
</div>
<div style="opacity: 0.7; filter: alpha(opacity: 70);" id="nav">
</div>
<div style="clear: both;"></div>
<div style="opacity: 0.95;" class="content">
<div style="background-color: #fffff0;" id="log">
<?php
$data = $_SESSION['data'];
$year = $_POST['year'];
$make = $_POST['make'];
$model = $_POST['model'];
$miles = $_POST['miles'];
$comment = $_POST['comment'];
$option1 = $_POST['option1'];
$option2 = $_POST['option2'];
$option3 = $_POST['option3'];
$option4 = $_POST['option4'];
$option5 = $_POST['option5'];
$option6 = $_POST['option6'];
$option7 = $_POST['option7'];
$option8 = $_POST['option8'];
$update = array(0 => $data[0], $data[1], $data[2], $data[3], $data[4], $data[5], $data[6], $data[7], $year, $make, $model, $miles, $comment, $option1, $option2, $option3, $option4, $option5, $option6, $option7, $option8);
echo '<table class="pictured photo_data">';
echo ' ';
echo ' <tr> ';
echo ' <td width="320"> ';
echo ' <a href="/inventory/trucks/'.$data[0].'" title="" class="smoothbox" rel="inventory/trucks"><img src="../inventory/trucks/'.$data[4].'" alt="1" /></a></td> ';
echo ' <td width="320">'.$year.' '.$make.' '.$model.'<br/><br/>'.$miles.'<br/>'.$comment.'<br/><br/> ';
echo ' <a href="../inventory/trucks/'.$data[1].'" title="" class="smoothbox" rel="inventory/trucks"><img style="float:left" src="../inventory/trucks/'.$data[5].'" alt="2" /></a> ';
echo ' <a href="../inventory/trucks/'.$data[2].'" title="" class="smoothbox" rel="inventory/trucks"><img style="float:left" src="../inventory/trucks/'.$data[6].'" alt="3" /></a> ';
echo ' <a href="../inventory/trucks/'.$data[3].'" title="" class="smoothbox" rel="inventory/trucks"><img style="float:left" src="../inventory/trucks/'.$data[7].'" alt="4" /></a> ';
echo ' </td> ';
echo ' <td>'.$option1.'<br/>'.$option2.'<br/>'.$option3.'<br/><br/>';
if($option4 != "")
echo $option4.'<br/>';
if($option5 != null)
echo $option5.'<br/>';
if($option6 != null)
echo $option6.'<br/>';
if($option7 != null)
echo $option7.'<br/>';
if($option8 != null)
echo $option8;
echo '</td> ';
echo ' </tr> ';
echo '</table>';
echo '<br/><br/><br/>';•
•
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation:
Rep Power: 8
Solved Threads: 239
Have you got it right already ? While inserting a record to a table, you follow this syntax.
Its while updating, you use this syntax.
php Syntax (Toggle Plain Text)
$sql = "insert into table (column1,column2) values ('$value1','$value2')";
php Syntax (Toggle Plain Text)
$sql = "update table set column1='$value1', column2='$value2' where id='$id'";
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
*PM asking for help will be ignored*
*PM asking for help will be ignored*
![]() |
•
•
•
•
•
•
•
•
DaniWeb MySQL Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
age amd avatar backup blue gene breach business chips daniweb data data protection database development dos economy energy enterprise europe government hacker hardware hp ibm ibm. news intel ibm it linux medicine memory microsoft news open source openoffice pc ps3 recession red hat russia security server sql sun supercomputer supercomputing survey technology trends ubuntu working x86
- Previous Thread: Having issues on MYSQL from one Domain to another
- Next Thread: Please help



Hybrid Mode