/    Sign up×
Community /Pin to ProfileBookmark

Java and database help!!!

Hi i tried on this code and found out there is error for that.

<?php require_once(‘../Connections/mConn.php’); ?>
<?php
mysql_select_db($database_mConn, $mConn);
$query_rs2 = “SELECT * FROM example1”;
$rs2 = mysql_query($query_rs2, $mConn) or die(mysql_error());
$row_rs2 = mysql_fetch_assoc($rs2);
$totalRows_rs2 = mysql_num_rows($rs2);
?>
<script type=”text/javascript”>
var menu3=new Array()
menu3[0]='<a href=”user_shopping.php”>e-Shopping</a>’
menu3[1]='<a href=”user_tv.php”>e-TV</a>’
menu3[2]=’$row_rs2[‘name’]’
</script>

Whereby in table example1, the column ‘name’ has the value of
<a href=”user_facilities.php”>e-Facilities</a>

For the javascript, it suppose to have drop down menu when my mouse over it but after i use the menu3[2]=’$row_rs2[‘name’]’the drop down list becomes disabled. The problem should be from the code menu3[2]=’$row_rs2[‘name’]’. Does anyone know how to code it correctly?Thanks.
I do not straight enter menu3[2]='<a href=”user_facilities.php”>e-Facilities</a>’ because i want it to retrieve the data which i inserted from the database.Hope anyone can help me out.Thanks.

to post a comment
PHP

8 Comments(s)

Copy linkTweet thisAlerts:
@so_is_thisNov 27.2006 — You could use [B]htmlentities()[/B] to prepare that text for insertion as the option value.
Copy linkTweet thisAlerts:
@PezmcNov 27.2006 — where is the code from?
Copy linkTweet thisAlerts:
@so_is_thisNov 27.2006 — Does anyone know how to code it correctly?[/QUOTE]
This:

menu3[2]='$row_rs2['name']'

is more correctly formatted as follows:

menu3[2]='<?=$row_rs2['name']?>'

But can also be formatted as follows:

menu3[2]='<?php echo $row_rs2['name'];?>'

Lastly, depending upon what you're doing with it, it should be coded as follows:

menu3[2]='<?=[B]htmlentities([/B]$row_rs2['name'][B])[/B]?>'
Copy linkTweet thisAlerts:
@teongkiaauthorNov 28.2006 — Oh thanks i made it.1 more question.May i know how to delete the specific row of data and write a new one in MySQL database using php code?Thanks a lot..i really appreaciate it.
Copy linkTweet thisAlerts:
@so_is_thisNov 28.2006 — [code=php]<?php
$sql = "Delete from Orders Where ord_numb = {$ordno} Limit 1;";
if (!$result = mysql_query($sql)):
echo '<p>Error: ' .mysql_errno(). '; ' .mysql_error(). "<br />n".
"sql = "{$sql}"</p>n";
else:

...etc...

endif;
?>[/code]

[code=php]<?php
$sql = "Insert into Orders Values(0,'" .$id. "','Open',0,0,0,0,NOW(),NOW());";
if (!$result = mysql_query($sql)):
echo '<p>Error: ' .mysql_errno(). '; ' .mysql_error(). "<br />n".
"sql = "{$sql}"</p>n";
else:

...etc...

endif;
?>[/code]
Copy linkTweet thisAlerts:
@teongkiaauthorNov 28.2006 — Hi thanks, can you let me know why my code doesn't work?

<?php

mysql_connect("localhost","root","")or die(mysql_error());

mysql_select_db("pnecnew")or die(mysql_error());

$result = mysql_query("UPDATE example1 SET name='<a href="a1.php">a1</a>' WHERE id='1'")

or die(mysql_error());


$result = mysql_query("SELECT * FROM example1 WHERE age='22'")

or die(mysql_error());

// get the first (and hopefully only) entry from the result

$row = mysql_fetch_array( $result );

echo $row['name']." - ".$row['age']. "<br />";

?>

Error in line 5.Thanks.

I just want to change the overwrite the name which holds id=1.
Copy linkTweet thisAlerts:
@so_is_thisNov 28.2006 — Well, what's the error message say?
Copy linkTweet thisAlerts:
@teongkiaauthorNov 28.2006 — Hi solved it by changing <a href="a1.php">a1</a> to <a href="a1.php">a1</a>

Thanks a lot.
×

Success!

Help @teongkia 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.19,
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,
)...