Here's the question, I need to connect to a remote MySQL database from my C# Application, problem is the MySQL instance will block all access to all IP's apart from localhost, this can not be changed as its too much of a security issue.
The question is, is it possible to connect via a tunnel instead to a php script hosted on the server, this would then act as the mysql connection.
Any ideas and suggestions?
My google fu is weak today, but I cannot find a good article to do so. I would like to extend the Zend Adapter to check n extra columns on my database table. What is the best way to fully extend the adapter, so I can use it in the future without needing to dig through documentation again.
I need an Access Report to use a CSV-File as a RecordSource.
I have searched and tried many things, yet, I've found no way to achieve this. A temporary table in some other database is not an option.
I've been trying to use a DAO RecordSet, but while I can read the RecordSet just fine I cannot set it as the report's RecordSet and I cannot use its Name as the RecordSource Property as both approaches lead to an error.
Please help me find a way!
Hi,
I am using cakephp for my site. I have stored multiple blocks in database and trying to access the code with following syntax.
foreach($blocks as $block){
if($block['Block']['position'] == 'left'){
$str = $block['Block']['value'];
eval("\"echo $str\";");
}
}
And i m getting this error;
: Undefined property: View::$requestAction [APP\views\layouts\home.ctp(60) : eval()'d code
Your Help will be highly appreciated.
Thanks,
First off, my question was a little vague or confusing since I'm not really sure how to phrase my question to be specific. I'm trying to query a database of stockists for a Knitting company (school project using PHP) but I'm looking to print the city as a heading instead of with each stockists information.
Here is what I have at the moment:
$sql = "SELECT * FROM mc16korustockists where locale = 'south'";
$result = pg_exec($sql);
$nrows = pg_numrows($result);
print $nrows;
$items = pg_fetch_all($result);
print_r($items);
for ($i=0; $i<$nrows2; $i++) {
print "<h2>";
print $items[$i]['city'];
print "</h2>";
print $items[$i]['name'];
print $items[$i]['address'];
print $items[$i]['city'];
print $items[$i]['phone'];
print "<br />";
print "<br />";
}
I'm querying the database for all of the data in it, the rows being ref, name, address, city and phone, and executing it. Querying the number of rows then using that to determine how many iterations for the loop to run is all fine but what I'd like to have is for the h2 heading to appear above the for ($i=0;) line.
Trying just breaks my page so that might be out of the question. I figure I'd have to count the number of entries in 'city' until it detects a change then change the heading to that name I think? That or make a heap of queries and set a variable for each name but at point, I might as well do it manually (and I highly doubt it would be best practice). Oh, and I'd welcome any critiques to my PHP since I'm just starting out.
Thanks and if you need any more information, just ask!
P.S. Our class is learning with PostgreSQL instead of MySQL as you can see in the tags.
I have a single MYSQL Question and need help ASAP.
Database:
Email | Name | Tag
[email protected] |Test Person | TagOne
[email protected] |Test Person | Tag Two
Need an SQL query that will return
Email | Name | Tag
[email protected] |Test Person | TagOne, Tag Two
Any help?
So I am making a small site using cakephp, and my ACL is set up so that every time a piece of content is created, an ACL rule is created to link the owner of the piece of content to the actual content. This allows each owner to edit/delete their own content. This method just seems so inefficient, because there is an equivalent amount of ACL rules as content in the database. I was curious, how do big sites, with millions of pieces of content, solve this problem?
Hello, I have a listview with a custom BaseAdapter. Each row of the listview has a TextView and a CheckBox.
The problem is when I click (or touch) any row, the textview foreground becomes gray, instead of the default behavior (background - green, textview foreground - white).
Here is the code:
row.xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/layout">
<TextView android:id="@+id/main_lv_item_textView"
style="@style/textViewBig"
android:layout_alignParentLeft="true"/>
<CheckBox android:id="@+id/main_lv_item_checkBox"
style="@style/checkBox"
android:layout_width="wrap_content"
android:layout_alignParentRight="true"/>
</RelativeLayout>
Custom Adapter:
public class CustomAdapter extends BaseAdapter {
private List<Profile> profiles;
private LayoutInflater inflater;
private TextView tvName;
private CheckBox cbEnabled;
public CustomAdapter(List<Profile> profiles) {
this.profiles = profiles;
inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
public int getCount() {
return profiles.size();
}
public Object getItem(int position) {
return profiles.get(position);
}
public long getItemId(int position) {
return position;
}
public View getView(final int position, View convertView, ViewGroup parent) {
View row = inflater.inflate(R.layout.main_lv_item, null);
final Profile profile = profiles.get(position);
tvName = (TextView) row.findViewById(R.id.main_lv_item_textView);
registerForContextMenu(tvName);
cbEnabled = (CheckBox) row.findViewById(R.id.main_lv_item_checkBox);
tvName.setText(profile.getName());
if (profile.isEnabled()) {
cbEnabled.setChecked(true);
}
tvName.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Bundle bundle = new Bundle();
bundle.putString(PROFILE_NAME_KEY, profile.getName());
Intent intent = new Intent(context, GuiProfile.class);
intent.putExtras(bundle);
startActivity(intent);
}
});
tvName.setOnLongClickListener(new OnLongClickListener() {
public boolean onLongClick(View v) {
selectedProfileName = ((TextView) v).getText().toString();
return false;
}
});
cbEnabled.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (!profile.isEnabled()) {
for (Profile profile : profiles) {
if (profile.isEnabled()) {
profile.setEnabled(false);
Database.getInstance().storeProfile(profile);
}
}
}
profile.setEnabled(isChecked);
Database.getInstance().storeProfile(profile);
updateListView();
}
});
return row;
}
}
Any help would be appreciated.
I'm working with an existing database where all dates are stored as integers in the following format: yyyy[3 digit day of year].
For example:
2010-01-01 == 2010001
2010-12-31 == 2010356
I'm using the following SQL to convert to a datetime:
DATEADD(d,
CAST(SUBSTRING(
CAST(NEW_BIZ_OBS_DATE AS VARCHAR), 5, LEN(NEW_BIZ_OBS_DATE) - 4
) AS INT) - 1,
CAST('1/1/' + SUBSTRING(CAST(NEW_BIZ_OBS_DATE AS VARCHAR),1,4) AS DATETIME))
Does anyone have a more concise way to do this?
I need help converting this SQL statement, into EF4:
Select Posts.PostID, Post, Comment
from Posts left join
Comments on posts.PostID = Comments.PostID
Where CommentID not in
(
Select PostID
from Votes
where VoteTypeID = 4 --4 = flagged comment type
)
In my database, the Votes table stores either the PostID of reported posts, or CommentID of reported comments in the column Votes.PostID
Thanks in advance!
We are using VB.NET and ASPx for our project. we would like to separate the aspx pages and put them on the IIS server (web server) on one m/c and the business logic and DAL layer on another IIS server (application server) on a different m/c .The database is on another m/c. Is such a configuration possible ? If so how can it be implemented?
I have a system that uses an mdb database with an xsd descriptor written in c#. Now I want to use one or more xml files with the same data instead. I have generated a couple of adapters for the mdb, but now I don't know what is needed for using xml instead. Anyone have some tips? I have managed to save the mdb as a few xml files.
Is there a way to know if all the properties in an object are empty. My object represents fields from database and I want to know if a particular record is present or not. NULL doesnt seem to work.
I am using my fluent nhibernate mappings to generate my MS SQL Server database.
I would like to be able to set a columns' description as part of this generation.
I am playing around with PHPFog and as a result I ended up with a MySql database. I am trying to figure out how to connect to it with a success message.
PHPFog says use this:
mysql_connect(
$server = getenv('MYSQL_DB_HOST'),
$username = getenv('MYSQL_USERNAME'),
$password = getenv('MYSQL_PASSWORD'));
mysql_select_db(getenv('MYSQL_DB_NAME'));
So I basically plug my variables into the above? Or Do I do something different?
Thanks,
Jim
I have a jQueryUI slider on my website that deals with price range.
I have a products table in mysql that has various entries.
I am using the slider to filter the results, but I need to set the minimum and maximum prices from the records in my database.
Should I just generate (with php) hidden fields in my html that contain the minimum and maximum and then use jQuery to obtain them? Or is there a better way of achieving this, maybe using AJAX?
Thanks
I have create a report in Microsoft Reporting Service that is presented in a browser. I would like to create button that opens a textbox where the user can fill in text. This text should be saved in column in the underlying database.
I have 3 files
1) show_createtable.html
2) do_showfielddef.php
3) do_showtble.php
1) First file is for creating a new table for a data base, it is a fom with 2 inputs, Table Name and Number of Fields. THIS WORKS FINE!
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<h1>Step 1: Name and Number</h1>
<form method="post" action="do_showfielddef.php" />
<p><strong>Table Name:</strong><br />
<input type="text" name="table_name" size="30" /></p>
<p><strong>Number of fields:</strong><br />
<input type="text" name="num_fields" size="30" /></p>
<p><input type="submit" name="submit" value="go to step2" /></p>
</form>
</body>
</html>
2) this script validates fields and createa another form to enter all the table rows.
This for also WORKS FINE!
<?php
//validate important input
if ((!$_POST[table_name]) || (!$_POST[num_fields])) {
header( "location: show_createtable.html");
exit;
}
//begin creating form for display
$form_block = "
<form action=\"do_createtable.php\" method=\"post\">
<input name=\"table_name\" type=\"hidden\" value=\"$_POST[table_name]\">
<table cellspacing=\"5\" cellpadding=\"5\">
<tr>
<th>Field Name</th><th>Field Type</th><th>Table Length</th>
</tr>";
//count from 0 until you reach the number fo fields
for ($i = 0; $i <$_POST[num_fields]; $i++) {
$form_block .="
<tr>
<td align=center><input type=\"texr\" name=\"field name[]\"
size=\"30\"></td>
<td align=center>
<select name=\"field_type[]\">
<option value=\"char\">char</option>
<option value=\"date\">date</option>
<option value=\"float\">float</option>
<option value=\"int\">int</option>
<option value=\"text\">text</option>
<option value=\"varchar\">varchar</option>
</select>
</td>
<td align=center><input type=\"text\" name=\"field_length[]\" size=\"5\">
</td>
</tr>";
}
//finish up the form
$form_block .= "
<tr>
<td align=center colspan=3><input type =\"submit\" value=\"create table\">
</td>
</tr>
</table>
</form>";
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Create a database table: Step 2</title>
</head>
<body>
<h1>defnie fields for <? echo "$_POST[table_name]"; ?>
</h1>
<? echo "$form_block"; ?>
</body>
</html>
Problem is here
3) this form creates the tables and enteres them into the database.
I am getting an error on line 37 "Parse error: syntax error, unexpected $end in /home/admin/domains/domaina.com.au/public_html/do_createtable.php on line 37"
<?
$db_name = "testDB";
$connection = @mysql_connect("localhost", "admin_user", "pass")
or die(mysql_error());
$db = @mysql_select_db($db_name, $connection)
or die(mysql_error());
$sql = "CREATE TABLE $_POST[table_name](";
for ($i = 0; $i < count($_POST[field_name]); $i++) {
$sql .= $_POST[field_name][$i]." ".$_POST[field_type][$i];
if ($_POST[field_length][$i] !="") {
$sql .=" (".$_POST[field_length][$i]."),";
} else {
$sql .=",";
}
$sql = substr($sql, 0, -1);
$sql .= ")";
$result = mysql_query($sql, $connection) or die(mysql_error());
if ($result) {
$msg = "<p>" .$_POST[table_name]." has been created!</p>";
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Create A Database Table: Step 3</title>
</head>
<body>
<h1>Adding table to <? echo "$db_name"; ?>...</h1>
<? echo "$msg"; ?>
</body>
</html>
Hi,
I am writing an Android app, part of which will be a survey involving multiple pages of checkbox question and answers. I have created an activity to display the question and options (from the DB) and what I want to do now is when i press the "Next" button it should just reload the current activity with the next question set from the database.
(the activity starts with survey.getNextQuestion() - so its just a case of refreshing the activity so it updates)
Im sure this is a simple thing to do -any ideas?
Thanks
Hi,
I am developing a static flex application which does not have a database connection, all the values are hardcoded(its just a prototype for the original app). Now when i click the save button, i need to get a message like saving in progress... please wait, I need to display this message for 3 seconds.
Please let me know how could this be done.
Thanks!
Cheers,
Deena
I am pulling a long timestamp from a database, but want to present it as a Date using Tags only, no embedded java in the JSP. I've created my own tag to do this because I was unable to get the parseDate and formatDate tags to work, but that's not to say they don't work.
Any advice?
Thanks.
I need to use a class callback method on an array inside another method (the callback function belongs to the class).
class Database {
public function escape_string_for_db($string){
return mysql_real_escape_string($string);
}
public function escape_all_array($array){
return array_filter($array,"$this->escape_string_for_db");
}
}
Is this the right way to go about that? (I mean, in terms of the second parameter passed to array_filter)