/    Sign up×
Community /Pin to ProfileBookmark

PHP / MYSQL connection

Hi,

Im very new at PHP/MYSQL and this are my first steps to send data on to my DB. I dont have a clue why when I send the data to MYSQL there is nothing on the database but I don’t get any errors so Im lost ?

I will atatch my code and post my code.

and here is the code for the insertion of the data:
[B]insert_procesador.php[/B]

[code=php]<?php
// Coneccion a MYSQL
$host = “localhost”;
$user = “root”;
$pwd = “root”;
$dbConn = mysql_connect($host,$user,$pwd);
// Conectandose a la base de datos
//nombre del abase de datos:

$database = “newland_tours”;
mysql_select_db($database);
$query_rs_insert_news = “INSERT INTO tbl_news ( Title, Country, City, Date, 1d, 2e, 3es, 4f, 5i, 6p, 7o, deutch, english, espanol, francaise, italiano, portugues, otro, Picture1, Picture2, Picture3, Picture4, Picture5, Picture6, Picture7) VALUES (‘”.$_POST[‘Title’].”‘, ‘”.$_POST[‘Country’].”‘, ‘”.$_POST[‘City’].”‘, ‘”.$_POST[‘Date’].”‘, ‘”.$_POST[‘1d’].”‘, ‘”.$_POST[‘2e’].”‘, ‘”.$_POST[‘3es’].”‘, ‘”.$_POST[‘4f’].”‘, ‘”.$_POST[‘6p’].”‘, ‘”.$_POST[‘7o’].”‘, ‘”.$_POST[‘deutch’].”‘, ‘”.$_POST[‘english’].”‘, ‘”.$_POST[‘espanol’].”‘, ‘”.$_POST[‘francaise’].”‘, ‘”.$_POST[‘italiano’].”‘, ‘”.$_POST[‘portugues’].”‘, ‘”.$_POST[‘otro’].”‘, ‘”.$_POST[‘Picture1’].”‘, ‘”.$_POST[‘Picture2’].”‘,
‘”.$_POST[‘Picture3’].”‘,
‘”.$_POST[‘Picture4’].”‘,
‘”.$_POST[‘Picture5’].”‘,
‘”.$_POST[‘Picture6’].”‘,
‘”.$_POST[‘Picture7’].”‘
);”;
//$rs_insert_news = mysql_query($query_rs_insert_news);
//header(“Location: admin_cp_master.php”);
?>[/code]

[B]index.php[/B]

[code=php]
<?php
// Set up connection to MySQL
$host = “localhost”;
$user = “root”;
$pwd = “root”;
$dbConn = mysql_connect($host,$user,$pwd);
// Connect to newland_tours database
$database = “newland_tours”;
mysql_select_db($database);
$query_rs_news = “SELECT * FROM tbl_news ORDER BY Date”;
$rs_news = mysql_query($query_rs_news);
$row_rs_news = mysql_fetch_assoc($rs_news);
?>

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″ />
<title>Untitled Document</title>
</head>

<body>
<form name=”form1″ id=”form1″ method=”post” action=”insert_procesador.php”>
<table width=”485″ border=”0″ cellspacing=”0″ cellpadding=”5″>
<tr>
<td width=”156″>Title:</td>
<td width=”309″><input name=”Title” type=”text” id=”Title” /></td>
</tr>
<tr>
<td>Country:</td>
<td><input name=”Country” type=”text” id=”Country” /></td>
</tr>
<tr>
<td>City:</td>
<td><input name=”City” type=”text” id=”City” /></td>
</tr>
<tr>
<td>Date YYYY-MM-DD:</td>
<td><input name=”Date” type=”text” id=”Date” /></td>
</tr>
<tr>
<td>Language:</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>1 deutsch :
<input name=”deutsch” type=”checkbox” id=”deutsch” value=”checkbox” /></td>
<td><textarea name=”1deutsch” cols=”50″ rows=”10″ id=”1deutsch”></textarea></td>
</tr>
<tr>
<td>2 english :
<input name=”english” type=”checkbox” id=”english” value=”checkbox” /></td>
<td><textarea name=”2 english” cols=”50″ rows=”10″ id=”2 english”></textarea></td>
</tr>
<tr>
<td>3 espa&ntilde;ol :
<input name=”espa&ntilde;ol” type=”checkbox” id=”espa&ntilde;ol” value=”checkbox” /></td>
<td><textarea name=”3 espanol” cols=”50″ rows=”10″ id=”3 espanol”></textarea></td>
</tr>
<tr>
<td>4 fran&ccedil;aise :
<input name=”fran&ccedil;aise” type=”checkbox” id=”fran&ccedil;aise” value=”checkbox” /></td>
<td><textarea name=”4 francaise” cols=”50″ rows=”10″ id=”4 francaise”></textarea></td>
</tr>
<tr>
<td>5 italiano:
<input name=”italiano” type=”checkbox” id=”italiano” value=”checkbox” /></td>
<td><textarea name=”5 italiano” cols=”50″ rows=”10″ id=”5 italiano”></textarea></td>
</tr>
<tr>
<td>6 portugu&ecirc;s :
<input name=”portugu&ecirc;s” type=”checkbox” id=”portugu&ecirc;s” value=”checkbox” /></td>
<td><textarea name=”6 portugues” cols=”50″ rows=”10″ id=”6 portugues”></textarea></td>
</tr>
<tr>
<td>7 other :
<input name=”other” type=”checkbox” id=”other” value=”checkbox” /></td>
<td><textarea name=”7 other” cols=”50″ rows=”10″ id=”7 other”></textarea></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>Pictures 1 </td>
<td><input name=”Pictures 1″ type=”text” id=”Pictures 1″ /></td>
</tr>
<tr>
<td>Pictures 2 </td>
<td><input name=”Pictures 2″ type=”text” id=”Pictures 2″ /></td>
</tr>
<tr>
<td>Pictures 3 </td>
<td><input name=”Pictures 3″ type=”text” id=”Pictures 3″ /></td>
</tr>
<tr>
<td>Pictures 4 </td>
<td><input name=”Pictures 4″ type=”text” id=”Pictures 4″ /></td>
</tr>
<tr>
<td>Pictures 5 </td>
<td><input name=”Pictures 5″ type=”text” id=”Pictures 5″ /></td>
</tr>
<tr>
<td>Pictures 6 </td>
<td><input name=”Pictures 6″ type=”text” id=”Pictures 6″ /></td>
</tr>
<tr>
<td>Pictures 7 </td>
<td><input name=”Pictures 7″ type=”text” id=”Pictures 7″ /></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type=”submit” name=”Submit” value=”Submit” /></td>
</tr>
</table>
</form>
</body>
</html>

[/code]

Thank you for any help
_Lobo_

ps: the page is on my LOCALHOST with WAMP server the server works just fine and also the DB

[upl-file uuid=4bca9a34-9dd6-490e-bbe9-33fae9dc5d00 size=2kB]admin.zip[/upl-file]

to post a comment
PHP

8 Comments(s)

Copy linkTweet thisAlerts:
@scragarMay 04.2005 — what's this say?[code=php]<?php
$host = "localhost";
$user = "root";
$pwd = "root";

$dbConn = mysql_connect($host,$user,$pwd);
$database = "newland_tours";
mysql_select_db($database, $dbConn);

$query_rs_insert_news = "INSERT INTO tbl_news (Title, Country, City, Date,
1d, 2e, 3es, 4f, 5i, 6p, 7o, deutch, english, espanol, francaise, italiano,
portugues, otro, Picture1, Picture2, Picture3, Picture4, Picture5, Picture6,
Picture7) VALUES ('".$_POST['Title']."', '".$_POST['Country']."',
'".$_POST['City']."', '".$_POST['Date']."', '".$_POST['1d']."',
'".$_POST['2e']."', '".$_POST['3es']."', '".$_POST['4f']."',
'".$_POST['6p']."', '".$_POST['7o']."', '".$_POST['deutch']."',
'".$_POST['english']."', '".$_POST['espanol']."',
'".$_POST['francaise']."', '".$_POST['italiano']."',
'".$_POST['portugues']."', '".$_POST['otro']."',
'".$_POST['Picture1']."', '".$_POST['Picture2']."',
'".$_POST['Picture3']."', '".$_POST['Picture4']."',
'".$_POST['Picture5']."', '".$_POST['Picture6']."',
'".$_POST['Picture7']."')";
$rs_insert_news = @mysql_query($query_rs_insert_news);
if($rs_insert_news){
header("Location: admin_cp_master.php");
}else{
echo mysql_error();
};
?>[/code]
Copy linkTweet thisAlerts:
@_LOBO_authorMay 04.2005 — this is the messenge

[B]Column count doesn't match value count at row 1 [/B]

ps:thank you for trying to help me ?
Copy linkTweet thisAlerts:
@scragarMay 04.2005 — your missing 5i.

in future remember to check it yourself by echoing the mysql error([color=red]echo mysql_error();[/color]), from that message it's obvious you've missed something in your query, a quick search reveals that you skiped streight past 5i.

$_POST['4f']."', [color=red]'".$_POST['5i']."', [/color]'".$_POST['6p']."
Copy linkTweet thisAlerts:
@_LOBO_authorMay 04.2005 — it works! this is great this is my first step on PHP/MYSQL hehehehe

thank you for the tip this is very new to me [COLOR=Red]echo mysql_error()[/COLOR]

thank you scragar
Copy linkTweet thisAlerts:
@_LOBO_authorMay 04.2005 — one more thing as you can see on my form I have a checkbox if I check those wich TYPE OF DATA I should choose on my DB to get somekind of true/false ? I don't know how to do this.
Copy linkTweet thisAlerts:
@scragarMay 04.2005 — I think the new version of mysql comes with the true/false datatype, but if you don't have that then your should use enum("N", "Y") and parse in "Y" if its checked, or "N" if it's not, you can check this again when you pull results out.
Copy linkTweet thisAlerts:
@_LOBO_authorMay 04.2005 — ok thank you again ?
Copy linkTweet thisAlerts:
@scragarMay 04.2005 — your welcome.
×

Success!

Help @_LOBO_ spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...