/    Sign up×
Community /Pin to ProfileBookmark

Just can’t win trying to Alter a field in a table

my code:

[code=php]
<?php
//connect to database
$connection = mysql_connect (“localhost”, “markbad_drpl1”, “funny”)
or die (‘I cannot connect to the database because: ‘ . mysql_error());
mysql_select_db (“markbad_markbadsql”);

// start the query
$sql = “ALTER TABLE archive DROP barthumb”;
$result = mysql_query(“$sql,$connection”)
or die (“Query failed”);
?>
[/code]

The worst part is this is how my book says to do it and it just plain out says query error to me. All I really want to do is change it from one name to another but All I can find to help me is DROP and ADD! don’t know hot to set a definition. MAN I WISH THIS WAS A TAD EASIER!

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@chazzyJan 17.2006 — try use or die ("Query failed: ".mysql_error()); instead of just or die ("Query failed");
Copy linkTweet thisAlerts:
@ScleppelJan 17.2006 — [code=php]// it should probably be
$result = mysql_query($sql,$connection)
//instead of
$result = mysql_query("$sql,$connection")[/code]


You have quotes the variables so they had become one. There's no point in quoting variables at all, unless they're actually in a string.

Edit: Remove you mysql username and password from you first post!
Copy linkTweet thisAlerts:
@Markbad311authorJan 17.2006 — I just ordered a PHP5 and MySql for dummies. Aparently I am one.
Copy linkTweet thisAlerts:
@chazzyJan 17.2006 — I just ordered a PHP5 and MySql for dummies. Aparently I am one.[/QUOTE]

The dummies books never work. I would recommend O'Reilly if you're trying to get your feet wet.
×

Success!

Help @Markbad311 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 5.11,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...