|
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....
|
|
|
|
|
A refresh will resubmit $_POST variables, that if you are using them in your page logic, means the logic will repeat. These values are stored on the users browser so using unset to clear the post variable will do you no good, you need to do 2 things the first is as the other poster says, make certain the information does not already exist. The second is when the data is processed send the user to a specific URL. This will keep the user from refreshing the page and having post vars repeated.
On a side note if you are echoing any information before you redirect the user, they will get a error message (headers already sent or some such). You can fix this with eith redirect by using javascript or you can redign your code to put all the echo'd information into a variable and echo that just after you redirection code.
|
|
|
|
|
I assume you are using an ajax framework which uses iframe to submit your form. In that case you are doing a normal refresh like you press F5. Or if you say that you are using javascript to reload the page like window.location.reload() then you will face that problem whether you are using F5 or reload using javascript. whatever. use window.location.href = window.location.href. this is like assigning a string to as the new url instead of meaning to the browser as reload. so the browser will load the page as a new request instead of page refresh. so we are reassigning a new(same) url (requesting the browser to load that page) instead of requesting the browser to reload the page. so the only difference here is loading a page and reloading a page.
To load a page use window.location.href = window.location.href (new request)
To reload a page use window.location.reload(). (refresh the same)
I suppose that your problem lies within this.
If you are not using ajax then use the redirect option in php to the same controller(page) to change the last loaded url. for example if you are posting your form data to a page called post.php in that after processing the database operation redirect to again the same post.php. by doing so you are changing the last request as a get request. and after that when you refresh the browser will issue a get request and not the previous post request because it will do a reload only with the last request.
DO YOU NEED A SAMPLE CODE?
IF THIS DID NOT SOLVE YOUR PROBLEM THEN USE
INSERT IGNORE INTO table (field1,field2) VALUES(1,2);
Better i should blog this answer with more possible combination.
Today's Beautiful Moments are
Tomorrow's Beautiful Memories
|
|
|
|