|
Hi,
I have an email through my web hosting service which has told me my database details.
they go
MySQL Hostname: 99.99.999.999
MySQL Username: xxx xxx
MySQL Passwor: aaaaahh
MySQL Server: MySQL 1
I was able to connect to a differnet database which did not have mysql server on it by using the following code
$hostname = "99.99.999.999"; <br />
$password = "aaaaahh"; <br />
$username = "xxx xxx"; <br />
Now i thought that this was simply going to be adding a $server variable on underneath so the complete code would look like this
$hostname = "99.99.999.999"; <br />
$password = "aaaaahh"; <br />
$username = "xxx xxx"; <br />
$server = "MySQL 1"; <br />
<br />
$connection = mysql_pconnect($hostname, $server, $username, $password);<br />
<br />
if (!$connection)<br />
{<br />
die('Could not connect: ' . mysql_error());<br />
}<br />
<br />
echo 'Connected successfully';<br />
mysql_close($connection)<br />
<br />
?><br />
However this doesn't seem to do anything?
Any help would be great
Many Thanks
Dan
|
|
|
|
|
Server and hostname usually mean the same thing - the address of the server. In any case, you have the arguments to mysql_pconnect[^] wrong, it should be:
$connection = mysql_pconnect($hostname, $username, $password);
This is assuming the server name is in the $hostname variable.
I suspect $server is actually the database name, so you should select this after connection using mysql_select_db[^].
if(!mysql_select_db($server, $connection)) { ...
|
|
|
|
|
Hi,
You are doing it wrong. The correct syntax of mysql_pconnect is:
$connection = mysql_pconnect($server, $username, $password, $client_flags);
So, if you have the hostname, you must use it instead of using ServerName. So, all you have to do is use this piece of code:
$hostname = "99.99.999.999";
$password = "aaaaahh";
$username = "xxx xxx";
$server = "MySQL 1";
$connection = mysql_pconnect($hostname, $username, $password);
if (!$connection)
{
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($connection);
See, I have not used $server anywhere. Not needed. Give it a try.
Enjoy.
|
|
|
|
|
Server isnt a accepted value in the connection string.
|
|
|
|
|
Hi all,
In the MySQL database i have stored the image as BLOB datatype.Now i want to display that image on the HTML page using the PHP coding.How can i do ?
Thanks in advance.
|
|
|
|
|
Let's say we store image in our mysql db with auto generated id. Then in following code
we are using image id to retrieve image and display it on html.
error_reporting(E_ALL);
if(isset($_GET['image_id']) && is_numeric($_GET['image_id'])) {
$link = mysql_connect("localhost", "username", "password") or die("Could not connect: " . mysql_error());
mysql_select_db("testblob") or die(mysql_error());
$sql = "SELECT image FROM testblob WHERE image_id=0";
$result = mysql_query("$sql") or die("Invalid query: " . mysql_error());
header("Content-type: image/jpeg");
echo mysql_result($result, 0);
mysql_close($link);
}
else {
echo 'Please use a real id number';
}
Find more information click this[^] link.
HTH
Jinal Desai - LIVE
Experience is mother of sage....
|
|
|
|
|
Simply use the select query to get the image field in the variable then use
print($variablename);
it will print the image
use the block within the HTML page to view the image as it cann't work in HTML tags.
|
|
|
|
|
Hi all,
Can any one tell me how can i convert a file from pdf to doc using PHP code.
Thanks in advance.
|
|
|
|
|
When a mail is bounced it has a standard subject.
Is it possible to change with a custom subject or the subject which we gave or with a dynamic subject?
I am building a simple system in php to count all send and not sent mails with the help of bounced mails.
So i need to parse the body of the bounced mail to find the email address to which the mail was not sent.
If there could be any other less overhead option then that could be nice. We can reduce the processing time to parse.
Today's Beautiful Moments are
Tomorrow's Beautiful Memories
|
|
|
|
|
Hi there
During the last 6 months I've put some time into learn and building simple web based apps using the cakephp framework. At this moment, a friend is asking me to build a website with shopping cart support. I was thinking to use a magento or oscommerce, but after some digs I've find some cakephp plugins for that:
infinitas[^] and kaching-php[^].
It is a hard choose for me, because I'll like to be a long term choose. Do you have any idea, which of those cakephp based apps has a better written code?
|
|
|
|
|
Hi all,
how can i embedded an image in to the doc file using php ?
Thanks in advance.
|
|
|
|
|
<?php
$wordApp = new COM("Word.Application");
$wordApp->visible = true;
$wordApp->Documents->Add();
$wordApp->Selection->TypeText("Code Project - PHP Office Automation Example - enhzflep: \n");
$wordApp->Selection->InlineShapes->AddPicture("http://s.codeproject.com/App_Themes/Std/Img/logo225x90.gif");
$wordApp->ActiveDocument->SaveAs("CP - php example");
$wordApp->Quit();
unset($wordApp);
?>
Hint: Try recording a macro in word and then checking out the generated vba code.
modified on Sunday, July 25, 2010 3:23 AM
|
|
|
|
|
ya my friend i have tried this code.
But the problem is the function TypeText allows only Text data,but in the doc file i have to print data from database + from a .html file + an image.
How can i do it ? Is there any solution ?
Thanks in advance.
|
|
|
|
|
I would argue that the code functions perfectly well & answers the question.
The problem it seems, is that the question doesn't match desired outcome.
I've answered the question and you still don't have what you want. Perhaps you could consider making the question actually relate to your query?
|
|
|
|
|
hi all,
Can any one tell me how can i export data to MS-Word i.e., to a .doc file or .docx file using php ?
Thanks in advance.
|
|
|
|
|
Have a look at using word ml (word xml) format, then just push out all your data as xml text which can be read in word. (Just push it to the http stream with application/msword content type).
Hope this helps, not done this in PHP but the concept remains the same
|
|
|
|
|
hi
I am working on a website & i am new to php i want to extract the entire details from a row in the database on to different text boxes. Is it possible to do so.
Any help would be great for me.
Thanks in advance.
|
|
|
|
|
I guess you mean you will extract a row of data with each column being placed into a text field?
if so it would kinf of look like this
$fld1 = '';
$fld2 = '';
$fld3 = '';
$sql = "select * from aTable";
$rst = mysql_query($sql);
if(mysql_num_rows($rst)>0)
{
$fld1 = $row['col1'];
$fld2 = $row['col2'];
$fld3 = $row['col3'];
}
echo "<input type='text' value='".$fld1."'>";
echo "<input type='text' value='".$fld2."'>";
echo "<input type='text' value='".$fld3."'>";
Hope that helps =)
|
|
|
|
|
That helped thanks cjoki
|
|
|
|
|
Hi all,
I am having once problem that is i have exported all the date to the doc in php but i am not able to export the image to doc.
Can any one tell me how can i export images and data to a doc ?????
Thanks in advance.
|
|
|
|
|
A colleague of mine came up with phpLiveDocx[^], a Zend Framework component and can read and write DOC and DOCX files in PHP on Linux, Windows and Mac.
But I haven't worked with it, might be helpful to you.
HTH
Jinal Desai - LIVE
Experience is mother of sage....
|
|
|
|
|
its something about mail merge...
|
|
|
|
|
Oov. . That could be nice.
So those people has played with the docx file format and has developed a script to generate a word document.
Hmm... like html2pdf conversions.
If people need to use in all platforms then why not convert it to a PDF.
There are lots of open sources written in simple php to convert so including images.
for all the users FYI. DOMPDF.com.
Today's Beautiful Moments are
Tomorrow's Beautiful Memories
|
|
|
|
|
Hi guys., am having with duplicate entry on the DB when the Page is refreshed..
any solution please,. what am trying to do is when the data is added, the portion of the page loads, not the whole page, am using AJAX to load potion of the page..
help guys, thanks..
|
|
|
|
|
You need to check for duplication of data before
inserting it into database for all values you are
inserting.
HTH
Jinal Desai - LIVE
Experience is mother of sage....
|
|
|
|