Jump to content

Fahid

Members
  • Posts

    30
  • Joined

  • Last visited

    Never

About Fahid

  • Birthday 02/25/1984

Contact Methods

  • Website URL
    http://dcpcskt.awardspace.com/

Profile Information

  • Gender
    Male
  • Location
    Pakistan

Fahid's Achievements

Member

Member (2/5)

0

Reputation

  1. I tried it myself, and it does delete the record from MS Access DB Thanks a lot again for help.
  2. Thanks a lot Mr. Mchl, I didn't found this thing in PHP documentation and was really troubled. Thanks a lot. 1 more little question please, can I delete a row/record from MS Access through PHP/ODBC ? I mean will this work DELETE FROM pNum WHERE `iRef`= '10' LIMIT 1
  3. Try changing the following portion better try copy/paste <?php $db = mysql_select_db("XXXXXXX_com_db", $con); $sql="INSERT INTO Enquiries (hear, name, email, contact, Schoolorcollege, date) VALUES (". $_POST['hear'] .",". $_POST['name'] .",". $_POST['email'] .",". $_POST['contact'] .",". $_POST['Schoolorcollege'] .",". $_POST['date'] .")"; //$_POST['SQL_query_result'] = 'Success'; if (!mysql_query($sql,$con)) { die("Database Error". mysql_error()); //$_POST['SQL_query_result'] = 'Database Error'; } ?>
  4. Hello All, I am trying to get some data from a MS Access database through ODBC, but don't know why I am failing no matter what I try. my code is given below I run this code and get the following error/output, which I have set to be displayed if no record is selected This means that my query is not affecting/selecting any data/row from the database. Please help WHY? <?php function get_given_number($num){ $conn = odbc_connect(settings('dsn'), settings('user'), settings('pass')) or die(odbc_error()."Cant conect"); $query = "SELECT * FROM pNum WHERE `iNum`='$num' ORDER BY `iSr` DESC"; //$query = "SELECT * FROM pNum"; $result = odbc_exec($conn, $query) or die(odbc_error($conn) . "get_given_number-query error"); $affected_rows = odbc_num_rows($result); //die($affected_rows); if($affected_rows < 1 ) die("get_given_number-no records found"); $output = ''; $entry_list = file_as_var('includes/pdel_entry_list.html'); while(odbc_fetch_row($result)){ $serial = odbc_result($result, 'iSr'); $reference = odbc_result($result, 'iRef'); $party_name = get_party_name($reference); $party_status = get_party_status($reference); if($party_status == 0) continue; $type = odbc_result($result,'iTyp2'); $amounta = odbc_result($result,'iAmnt'); $amountb = odbc_result($result,'iAmnt2'); $output .= format_entry($num, $serial, $party_name, $type, $amounta, $amountb); } $output = str_replace('__ENTRIES__',$output,$entry_list); $output = str_replace('__iNum__',$number,$output); odbc_close_all(); return $output; } echo get_given_number('7139'); ?>
  5. of course you can add whatever you want to add, you text/.txt could be a file with HTML code. or if you like, you can also use a .html file instead of .txt file. and use any of your favorite editor to create/edit this file. just be very careful at the replacement tokens i.e. __COUNTRY__ and replacement commands in PHP <?php $mail_body = str_replace('__COUNTRY__',$country,$mail_body); $mail_body = str_replace('__SCDATE__',$Scdate,$mail_body); $mail_body = str_replace('__COMMENT__',$country,$mail_body); ?> be very careful about these lines, use any number of replacement tokens you would like to, for example if I want to add a new variable into my HTML template file, I would add a line in my HTML code i.e. Your I.P. is __IP__ and add a new line ( at the end of code given below in my PHP code ) to replace __IP__ token with the user IP i.e. $mail_body = str_replace('__IP__',$_SERVER['REMOTE_ADDR'],$mail_body); End word is that: I can just give you the right direction, you have to make it to your destiny yourself
  6. Thanks God, I have got it done just a little addition to my php code, goes as under <?php function mysqlcon(){ $conn = mysql_connect('','root','pass') or die(mysql_error()); $db = mysql_select_db('wordpress') or die(mysql_error()); $unicode = mysql_query("SET NAMES utf8"); return $conn; } function get_wp_news (){ $conn = mysqlcon(); $output = ''; $query = "SELECT * FROM `wp_posts` WHERE `post_category`=0 ORDER BY `post_date` DESC LIMIT 0,1"; $result = mysql_query($query) or die(mysql_error()); $rows = mysql_affected_rows(); if($rows > 0){ while($db_output = mysql_fetch_array($result)){ $output = $db_output['post_content']; } } else $output = "No Records Were Found!"; return $output; } ?> notice the line# 5 in the script $unicode = mysql_query("SET NAMES utf8"); Thanks goes to lorenz pressler @ http://dev.mysql.com/doc/refman/5.1/en/charset-unicode.html
  7. Thanks God, I have got it done just a little addition to my php code, goes as under <?php function mysqlcon(){ $conn = mysql_connect('','root','pass') or die(mysql_error()); $db = mysql_select_db('wordpress') or die(mysql_error()); $unicode = mysql_query("SET NAMES utf8"); return $conn; } function get_wp_news (){ $conn = mysqlcon(); $output = ''; $query = "SELECT * FROM `wp_posts` WHERE `post_category`=0 ORDER BY `post_date` DESC LIMIT 0,1"; $result = mysql_query($query) or die(mysql_error()); $rows = mysql_affected_rows(); if($rows > 0){ while($db_output = mysql_fetch_array($result)){ $output = $db_output['post_content']; } } else $output = "No Records Were Found!"; return $output; } ?> notice the line# 5 in the script $unicode = mysql_query("SET NAMES utf8"); Thanks goes to lorenz pressler @ http://dev.mysql.com/doc/refman/5.1/en/charset-unicode.html
  8. Hello All, I am trying to obtain some uni-code ( uni-code urdu text ) text from MySQL database and show it on my page generated by using PHP. Original text ( that should be displayed or what I want to display ) may be seen here http://fahid.freehostia.com/text.html And this is the PHP code I am using to get the text from data base <?php function mysqlcon(){ $conn = mysql_connect('localhost','root','pass') or die(mysql_error()); $db = mysql_select_db('wordpress') or die(mysql_error()); return $conn; } function get_wp_news (){ $conn = mysqlcon(); $output = ''; $query = "SELECT * FROM `wp_posts` WHERE `post_category`=0 ORDER BY `post_date` DESC LIMIT 0,1"; $result = mysql_query($query) or die(mysql_error()); $rows = mysql_affected_rows(); if($rows > 0){ while($db_output = mysql_fetch_array($result)){ $output = $db_output['post_content']; } } else $output = "No Records Were Found!"; return $output; } ?> The text is stored in database correctly, it is originally stored into data base using Wordpress, a well know PHP blogging engine. Wordpress shows the text absolutely perfectly. but when I try to obtain the uni-code urdu text from MySQL and show it, it show something like ? ? ? ? ? ? ? ? ? ?? symbols instead of the uni-code urdu text. I hope I am using correct HTML encoding type in the html head, that is <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> A working version of my PHP script showing the messed up output is available here http://fahid.freehostia.com/ Please help me do it correctly, I can't understand what's going wrong
  9. How about this <?php function file_as_var ($file, $file_size_kilobytes = 100){ $file_size_bytes = $file_size_kilobytes * 1024; $fp = fopen($file,"r"); $output = fread($fp, $file_size_bytes); // LIMIT 100 KB fclose($fp); return $output; } $mail_body = function file_as_var ("./email_template.txt", 10); $mail_body = str_replace('__COUNTRY__',$country,$mail_body); $mail_body = str_replace('__SCDATE__',$Scdate,$mail_body); $mail_body = str_replace('__COMMENT__',$country,$mail_body); ?> while the email_template.txt should be some thing like this <p>Dear user<br>Your country is __COUNTRY__<br>Your Secure order date is __SCDATE__</p> <p>the comments are __COMMENTS__</p> You can add whatever you like in the text file, I hope this can give you the right idea at least.
  10. Hello All, I am trying to obtain some uni-code ( uni-code urdu text ) text from MySQL database and show it on my page generated by using PHP. Original text ( that should be displayed or what I want to display ) may be seen here http://fahid.freehostia.com/text.html And this is the PHP code I am using to get the text from data bse <?php function mysqlcon(){ $conn = mysql_connect('','root','pass') or die(mysql_error()); $db = mysql_select_db('wordpress') or die(mysql_error()); return $conn; } function get_wp_news (){ $conn = mysqlcon(); $output = ''; $query = "SELECT * FROM `wp_posts` WHERE `post_category`=0 ORDER BY `post_date` DESC LIMIT 0,1"; $result = mysql_query($query) or die(mysql_error()); $rows = mysql_affected_rows(); if($rows > 0){ while($db_output = mysql_fetch_array($result)){ $output = $db_output['post_content']; } } else $output = "No Records Were Found!"; return $output; } ?> The text is stored in database correctly, it is originally stored into data base using Wordpress, a well know PHP blogging engine. Wordpress shows the text absolutely perfectly. but when I try to obtain the uni-code urdu text from MySQL and show it, it show something like ???? ??????? ?? ? symbols instead of the uni-code urdu text. I am using correct encoding type in the html head, that is <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> A working version of my PHP script showing the messed up output is available here http://fahid.freehostia.com/ Please help do it correctly, I can't understand what's going wrong
  11. Sorry, Give it a try now <?php session_start(); $db_host = 'localhost'; //Hostname $db_user = 'root'; //Username $db_pass = ''; //Password $db_db = 'users'; //Database name if (isset($_POST['username'])) { // Mysql Connection $db_link = mysql_connect($db_host, $db_user, $db_pass) or die('MySQl Connection Error:'.mysql_error()); mysql_select_db($db_db) or die('MySQL Error: Cannot select table'); $username = mysql_real_escape_string($_POST['username']); $password = mysql_real_escape_string($_POST['password']); // MySQL Query $result = mysql_query("SELECT * FROM `users` WHERE `username` = '$username' AND `password` = '$password' ") or die ('Error Fetching Username & Pass'. mysql_error()); if(mysql_num_rows($result) > 0) { // Mysql fetch row results $row = mysql_fetch_assoc($result); $_SESSION['userid'] = $row['id']; $_SESSION['username'] = $username; $_SESSION['error'] = 'Login successful!'; } else { $_SESSION['error'] = '<span style="color: red">Login Failed</span>'; } mysql_close($db_link); } header('Location: ./') ?>
  12. I want to get the contents of the file/db_data into a variable, because it has both HTML and some PHP script. I want to save this data into variable so that I can print the data on a specific spot in my page. If I use your method, PHP Script will be executed, but HTML will be sent to browser right away, which I don't want. here are contents of PHP script I want to add through TEXT FILE or MYSQL DATABASE <div id="reporterrorform"> <form method="post" action="report-error.php"> <fieldset> <legend>Report Error...</legend> <table> <tr> <td colspan="2" align="center"><hr /></td> </tr> <tr> <th><label for="PageAddress">Page Address: </label></th> <td><input type="text" name="PageAddress" id="PageAddress" size="60" readonly="readonly" value="<?php isset($PageAddress) ? echo $PageAddress : echo $_SERVER['HTTP_REFERER']; ?>" /></td> </tr> <tr> <th valign="top"><label for="Description">Description of Error: </label></th> <td><textarea rows="6" cols="45" name="Description" id="Description"><?php echo $Description; ?></textarea></td> </tr> <tr> <td colspan="2"><p class="formhelp">Thank You for taking your time to Report the Error.</td> </tr> <tr> <th><label for="Name">Full Name: </label></th> <td><input type="text" name="Name" id="Name" size="60" maxlength="30" value="<?php echo $Name; ?>" /></td> </tr> <tr> <th><label for="Email">Email Address: </label></th> <td><input type="text" name="Email" id="Email" size="60" maxlength="60" maxlength="30" value="<?php echo $Email; ?>" /></td> </tr> <tr> <th><label for="Phone">Phone/FAX/Cell: </label></th> <td><input type="text" name="Phone" id="Phone" size="60" maxlength="60" maxlength="30" value="<?php echo $Phone; ?>" /></td> </tr> <tr> <td align="right"><input type="submit" value="Send" /></td> <td><input type="reset" value="Clear" /></td> </tr> </table> </fieldset> </form> </div>
  13. Try This <?php session_start(); $db_host = 'localhost'; //Hostname $db_user = 'root'; //Username $db_pass = ''; //Password $db_db = 'users'; //Database name if (isset($_POST['username'])) { // Mysql Connection $db_link = mysql_connect($db_host, $db_user, $db_pass) or die('MySQl Connection Error:'.mysql_error()); mysql_select_db($db_db) or die('MySQL Error: Cannot select table'); $username = mysql_real_escape_string($_POST['username']); $password = mysql_real_escape_string($_POST['password']); // MySQL Query $result = mysql_query("SELECT * FROM `users` WHERE `username` = '$username' AND `password` = '$password' ") or die ('Error Fetching Username & Pass', mysql_error()); if(mysql_num_rows($result) > 0) { // Mysql fetch row results $row = mysql_fetch_assoc($result); $_SESSION['userid'] = $row['id']; $_SESSION['username'] = $username; $_SESSION['error'] = 'Login successful!'; } else { $_SESSION['error'] = '<span style="color: red">Login Failed</span>'; } mysql_close($db_link); } header('Location: ./') ?>
  14. I think I have got the solution while visiting this forum, please confirm if you see it. Even if this function is the one I am looking for, still the question is: In which PHP Versions this function is supported? <?php $Name = mysql_real_escape_string($_POST['Name']); $Phone = mysql_real_escape_string($_POST['Phone ']); $query = "INSERT INTO `tablename` VALUES ('$Name', '$Phone' );"; $result = mysql_query($query) or die(mysql_error()); ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.