I have a database table and I want to print the name. It isn't displayed correct, it's like this:
Abu Noooooora dddd#hotmail.com
���� ������� dddd#hotmail.com
almojaded dddd#islamway.net
WeldLibya dddd#hotmail.com
What can I do to print like:
Abu Noooooora dddd#hotmail.com
يوسف على dddd#hotmail.com
almojaded dddd#islamway.net
WeldLibya dddd#hotmail.com
My php code is:
<?
$dd = mysql_query("SELECT sname,semail FROM senders LIMIT 5");
while($ro = mysql_fetch_array($dd))
{
?>
<tr>
<td style="text-align:right;"><?php echo $ro["sname"]; ?></td>
<td style="text-align:right;"><?php echo $ro["semail"]; ?></td>
</tr>
<?
}
?>
Looks like you are using MySQL. Suggest you read this http://dev.mysql.com/doc/refman/5.6/en/charset.html.
Can you tell if MySQL is set up for unicode (international) character sets. You can use some of the MySQL admin tools to check this. YOu need to know the name of the character set you want to use, and check if it is loaded into your MySQL installation.
At the HTML level, you need to specify that you are using utf8 output by placing something like
in your header area
Related
I'm trying to replace some strings using regex in HTML, but there are Swedish characters that make my life difficult.
It starts off looking like this (I'm using dummy text instead of the real Swedish):
<td class="swedish">abc defgå hijk lmnopä</td>
<td><?php audioButton("../../audio/lessons/01/some_old_text","some_old_text"); ?></td>
<td><?php audioButton("../../audio/lessons/01/slow/some_old_text_slx","some_old_text_slx","1"); ?></td>
Step 1: I manage to place the string in the first tag inside the audiobutton, so it looks like this:
<td class="swedish">abc defgå hijk lmnopä</td>
<td><?php audioButton("../../audio/lessons/01/abc defgå hijk lmnopä","abc defgå hijk lmnopä"); ?></td>
<td><?php audioButton("../../audio/lessons/01/slow/abc defgå hijk lmnopä_slx","abc defgå hijk lmnopä_slx","1"); ?></td>
You don't have to read this, but I did it with the following:
Find
<td class="swedish">(.*)</td>\n.*<td><\?php audioButton\("(.*)/.*",".*"\); \?></td>\n.*<td><\?php audioButton\("(.*)/.*",".*","1"\); \?></td>
Replace
<td class="swedish">$1</td>
<td><?php audioButton("$2/$1","$1"); ?></td>
<td><?php audioButton("$3/$1_slx","$1_slx","1");?></td>
It's fairly straightforward, even for a noob like myself.
Step 2: Now this is where my problems begin. The Swedish characters ä, ö and å have special codes in HTML (ä - ö and å). I have to replace each instance of that code with ae, oe and aa respectively, and put an underscore between each word. This has to happen inside the audiobutton only.
The final result has to look like this:
<td class="swedish">abc defgå hijk lmnopä</td>
<td><?php audioButton("../../audio/lessons/01/abc_defgaa_hijk_lmnopae","abc_defgaa_hijk_lmnopae"); ?></td>
<td><?php audioButton("../../audio/lessons/01/slow/abc_defgaa_hijk_lmnopae_slx","abc_defgaa_hijk_lmnopae_slx","1"); ?></td>
This is where my regex literacy fails me. It's probably really simple, but I can't see it. I would really appreciate some help. It would be especially great if I can do the whole thing in one step instead of two.
Here's a bash loop that will replace the audioButton occurrences as you wish:
for line in $(egrep "audioButton" swedish.txt | sed -e 's?\ ?::ZZqC::?g') ; do
real_line=$(echo "${line}" | sed -e 's?::ZZqC::?\ ?g') ;
new_line=$(echo "${real_line}" | sed -e 's?ä?ae?g' -e 's?ö?oe?g' -e 's?å?aa?g' -e 's?\([a-z]\) ?\1_?g') ;
sed -i -e "s|${real_line}|${new_line}|g" swedish.txt ;
done
Hi i have one table in my database which has list of states and i want to fetch this data from the table but my query is not executing properly it gives me some error
<?php
require_once('../Config/database.php');
$result1=$this->Signup->query("SELECT * FROM states");
//echo $popular;
while($post = mysql_fetch_array($result1))
{ ?>
<table width="380">
<tr>
<td class="table_txt"><a class="thickbox tn" href="demo.php?state_name=<?php echo $post['state_name']?>&state_id=<?php echo $post['state_id']?>&height=430&height=430&width=700&inlineId=myOnPageContent"><?php echo $post['state_name']?></a></td>
</tr>
</table>
<?php }
?>
But it gives me error
Warning (512): Method SignupHelper::query does not exist [CORE\Cake\View\Helper.php, line 192
Warning (2): mysql_fetch_array() expects parameter 1 to be resource, null given
Please read the documentation first.
It seems you are trying to get the states, inside the View, with a query.
You need to separate the view from the model.
Create a State model.
Use something like this in your controller:
$this->loadModel('State');
$states = $this->State->find('list'); // this will create a key => value array with the IDs and names
$this->set('states', $states);
In your view, use
<table width="380">
<tr>
<?php foreach ($states as $stateId => $stateName) {
<td class="table_txt"><a class="thickbox tn" href="demo.php?state_name=<?php echo $stateName?>&state_id=<?php echo $stateId?>&height=430&height=430&width=700&inlineId=myOnPageContent"><?php echo $stateName ?>></a></td>
<?php } ?>
</tr>
You might still need some changes, but this is the main idea.
I would like to know how is it possible to block a list of given ips from a mysql database table of ips.
For example i have a registration form and if the user has a different ip than the one from the mysql dbs he should see the form else he should see a message on that page "You are not allowed to use VPN/Proxy ips on this website".
First how do i create the mysql table and column, what properties do i need to add, so i can import the ips from a csv file.
MYSQL
CREATE TABLE IF NOT EXISTS 'blocked_ips'.......
and don't know how exactly to continue. Tried adding a column in phpmyadmin with VARCHAR(15) and after tried importing the csv file of ips, but it doesn't work, it only imports 2 rows and has only 00 containing in the 2 rows
<?php
//check for user ip
$ip = $_SERVER['REMOTE_ADDR'];
compare the ip got from the user with the mysql table column with ips
if the $ip matches with one from the table echo a message on the same page, (no pop-up).
else {
will echo the form below
?>
<DOCTYPE html!>
<head>
<title> Registration</title>
meta
meta
</head>
<body>
<table class="colortext" width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="30%"> </td>
<td height="20" width="70%">{advertiser_msg:8921}</td>
</tr>
<tr>
<td>{advertiser_msg:1092} <span class="mandatory">*</span></td>
<td>{USERFIELD}<span id="fg" style="display: none;white-space: nowrap;"></td>
</tr>
</form>
</body>
</html>
I am a noob in this please help.
mysql_select_db("your database name") or die(mysql_error());
# Full Text Attempt
$query = mysql_query("SELECT `IP` FROM `your table` WHERE `IP` = '$ip'");
or
$query = mysql_query("SELECT `IP` FROM `database` WHERE `IP` LIKE '%$ip%'");
//chk for banned ip ipaddress
if (mysql_num_rows($query) > 0)
{
echo "<p> You are not allowed to register with proxy VPN </p>";
}
?>
I wish to do something like this:
apple
bag
cat
dog
the first column: generate auto number start with 1.
the second column: get data from database
<table>
<?php do { ?>
<tr>
<td><ol>
<li></td>
<td><?php echo $row["object"]; ?></td>
</li></ol>
</tr>
<?php } while ($row = mysql_fetch_assoc($recordset)); ?>
</table>
The coding above make like:
1 apple
1 bag
1 cat
1 dog
I do not know where am I wrong. Please correct me. Thank you.
You're creating a new ordered list with each record. You're also mixing your ordered list in tables, which doesn't make sense - do one or the other.
Maybe something like:
<ol>
<?php do { ?>
<li><?php echo $row["object"]; ?></li>
<?php } while ($row = mysql_fetch_assoc($recordset)); ?>
</ol>
I am having a problem, i can connect to my database but it wont save in database what i wrote in a text area. Every time i click update it saves as blank, if i write lalala in mysql directly and refresh the page where text area is i can see lalala in text area but if i replace the text lalala in text area for something else and click update, it deletes the previous text lalala and leaves the field blank. Heres my code:
----------------------------- File 1 ---------------------------------
<?
include("header.inc.php");
$result5 = mysql_query("SELECT faq FROM `demo_a_faq`");
$myrow5 = mysql_fetch_row($result5);
$faq = $myrow5[0];
?>
<?
include("../templates/admin-header.txt");
?>
<form method="post" action="faq2.php">
<TABLE bgcolor="#FFFFFF" bordercolor="#000008" border="0" width="95%" align="center">
<TR>
<TD width="50%"><center><font face="Verdana, Arial, Helvetica, sans-serif" size="2"> <b>Edit FAQ:</b><br><textarea name="faneu" type="text" cols="80" rows="25"><? echo "$faq"; ?></textarea></TD>
</TR>
</TABLE><br><br>
<center><input type="submit" value="Update"></form></center>
<?
include("../templates/admin-footer.txt");
?>
----------------------------- File 2 ---------------------------------
<?
include("header.inc.php");
$asl = "UPDATE `demo_a_faq` SET `faq` = '$faneu'";
$results = mysql_query($asl) or die(mysql_error());
?>
<?
include("../templates/admin-header.txt");
?>
<center><br><br><br><b>Updated!</b></center>
<?
include("../templates/admin-footer.txt");
?>
In header.inc.php i simply have the conection to database.
Can someone please tell me why it is not saving what i write in text area to database as it is driving me crazy.
Thanks in advance
Try this:
<?php
include("header.inc.php");
// Always escape variables used in SQL-queries to avoid SQL-injections.
$faneu = mysql_real_escape_string($_POST['faneu']);
$asl = "UPDATE `demo_a_faq` SET `faq` = '$faneu'";
$results = mysql_query($asl) or die(mysql_error());
?>
<?
include("../templates/admin-header.txt");
?>
<center><br><br><br><b>Updated!</b></center>
<?
include("../templates/admin-footer.txt");
?>
You don't POST your textarea value to "FILES 2".Be carefull.