PHP - Php Simple Html Dom Parser Fails On A Simple Example - [driving Me Nuts]
Hi everyone,
I'm trying to select either a class or an id using PHP Simple HTML DOM Parser with absolutely no luck. My example is very simple and seems to comply to the examples given in the manual(http://simplehtmldom.sourceforge.net/manual.htm) but it just wont work, it's driving me up the wall. Here is my example: http://schulnetz.nibis.de/db/schulen/schule.php?schulnr=94468&lschb= I think the HTML is invalid: i cannot parse it. Well i need more examples - probly i have overseen something! If anybody has a working example of Simple-html-dom-parser...i would be happy. The examples on the developersite are not very helpful. your dilbertone Similar Tutorialsi have this code <?php require_once('dbconnect.php') $user = "test"; $pass = "test"; $result=mysql_query("SELECT * FROM accounts WHERE user = '$user' AND pass = '$pass' "); if(mysql_num_rows($result) == 0) { $login = "&err=Login Failed."; echo($login); } else { $row = mysql_fetch_array($result); $user = $row['user']; $pass = $row['pass']; $login = "&user=".$user."&pass=".$pass."&err=Login Successful."; echo($login); } ?> and im getting this Parse error: parse error in C:\wamp\www\flashstuff\WTF.php on line 4 line 4 is: $user = "test"; all the dbconnect stuff is fine help! im using simple_html_dom.php i want to extract the following html: and number the array key so i will know the location of each <td> and extract the value the this cell: <TD ALIGN=RIGHT NOWRAP class="ftableline1"> 3.7200 </TD> with this : Code: [Select] foreach($html->find('td[class=ftableline1]') as $e) echo $e->innertext . '<br>'; Code: [Select] <TR class="ftableline1"> <TD ALIGN=RIGHT NOWRAP class="ftableline1"> 3.7200 </TD> <TD ALIGN=RIGHT NOWRAP class="ftableline1"> 3.5400 </TD> <TD ALIGN=RIGHT NOWRAP class="ftableline1"> 3.6651 </TD> <TD ALIGN=RIGHT NOWRAP class="ftableline1"> 3.5982 </TD> <TD align="right" NOWRAP class="ftableline1"> <A HREF=_matbea=1><IMG SRC="images/tezuga_graphit.gif" WIDTH=15 HEIGHT=15 ALT="Show Graph" BORDER="0"></a><BR> </TD> <TD ALIGN=RIGHT NOWRAP>0.01%</TD> <TD ALIGN=right dir="rtl"> <IMG SRC="images/arrow_up.gif" WIDTH=10 HEIGHT=8 BORDER=0><BR> </TD> <TD align="right" NOWRAP dir="rtl" class="ftableline1"> 3.6316 </TD> <TD align="right" NOWRAP dir="rtl" class="ftableline1"> 1 </TD> <TD ALIGN=RIGHT NOWRAP dir="rtl" class="ftableline1"> <A HREF=_matbea=1> דולר ארה"ב</A><BR> </TD> <TD align="right" NOWRAP dir="rtl" class="ftableline1"> <A href="_matbea=1"><IMG SRC="../../meida/images/f1.gif" HEIGHT=15 WIDTH=21 border=0></A><BR> </TD> <TD ALIGN=center NOWRAP dir="rtl"><INPUT TYPE="Checkbox" VALUE="1" NAME="check" id="check" ></TD> </TR> Hi All, I am using the PHP Simple HTML DOM parser to connect to a financials website, parse out a companies financial information (Income statement in this case) and then insert the scrapped data into a mysql database that I can then later use to run automated calculations. Here is the code I have so far: Code: [Select] <?php include_once 'simple_html_dom.php'; //Connect to financial Website and Create DOM from URL $income_statement = file_get_html('http://www.WEBSITE.com/finance?etc..etc...etc...etc...'); //PULL FINANCIAL DATA foreach($income_statement->find('td[class]' ) as $lines=>$data) { echo $data->plaintext . "<br/>"; } // clean up memory $html->clear(); unset($html); ?> So far I am able to get output that looks like this: Code: [Select] Revenue 336.57 331.52 324.32 319.29 320.40 Other Revenue, Total - - - - - Total Revenue 336.57 331.52 324.32 319.29 320.40 etc............................. But being a newb I do not understand how I can break each $ value and each - into their own variables and then insert them to their corresponding mysql table fields. During the database insert I would like to ignore field headings from insertion (i.e Revenue, Total Revenue, etc.... Any help would be absolutely amazing, as I have been reading, scripting and searching for information like crazy, but just can't seem to figure it out. hello dear community, i am currently wroking on a approach to parse some sites that contain datas on Foundations in Switzerland with some details like goals, contact-E-Mail and the like,,, See http://www.foundationfinder.ch/ which has a dataset of 790 foundations. All the data are free to use - with no limitations copyrights on it. I have tried it with PHP Simple HTML DOM Parser - but , i have seen that it is difficult to get all necessary data -that is needed to get it up and running. Who is wanting to jump in and help in creating this scraper/parser. I love to hear from you. Please help me - to get up to speed with this approach? regards Dilbertone Hello dear Community, i have a document i need to parse it and spit out only this part of the table: see http://schulnetz.nibis.de/db/schulen/schule.php?schulnr=67003&lschb= how to i parse the stuff!? With perl or php? Note i have the xpaths (see below) Sad that i cannot apply them on Simple DOM Parser since this Dom Parser does not work with Xpaths but with CSS-Selectors: Well i want to get all the data with that are within the table that name is called class="fliess" How to dump all the results? BTW - thinking about the most elegant way, i think it is the most pretty way would be to do it with perl - So i can try it with HTML::TableExtract or.... Well what do you suggest - Which way to choose to do this [very] simple thing? Look forward to hear from you! see the xpaths: Schule: /html/body/center/table/tbody/tr[2]/td[1] Stasse: /html/body/center/table/tbody/tr[3]/td[1] Ort: /html/body/center/table/tbody/tr[4]/td[1] Tel: /html/body/center/table/tbody/tr[5]/td[1] Schulgliederungen: /html/body/center/table/tbody/tr[6]/td[1] Besonderheite: /html/body/center/table/tbody/tr[7]/td[1] E-Mail: /html/body/center/table/tbody/tr[8]/td[1] Schulnummer: /html/body/center/table/tbody/tr[9]/td[1] Hello dear friends, first of all : merry merry Xmas!!! i want to parse with the simple Simple HTML DOM Parser, well i am pretty new to php and to the Simple HTML DOM Parser. My example: http://schulen.bildung-rp.de/gehezu/startseite/einzelanzeige.html?tx_wfqbe_pi1[uid]=60119 I want to collect the data in the block: I have investigated the sourcecode - and found out that the attribute of interest should be this one: class="content"div class="content"><!-- TYPO3SEARCH_begin --> here the code is: - my trails. // inculde the Simple HTML DOM Parser include_once('simple_html_dom.php'); // get the file we want to parse right now,create a DOM $html = file_get_html(''); // simple_html_dom::find() creates a new // simple_html_dom-Objekt, that consists out of // corresponding childelements foreach($html->find('class: content ') as $h3) { // simple_html_dom::get the text in a tag // den Text innerhalb eines Tags if($h3->innertext == 'Text of a H3 Tag') { break; } } // simple_html_dom::next_sibling() gives the // next Element $table = $h3->next_sibling(); but believe me - it gives me not back what is aimed. what have id done wrong...? dbone I'm using PHP 5.2 Server and Simple HTML DOM 1.5. This script scrape or extract data from a football site, its fully working on PHP 5.9 Server but I need to know how I can fix it for PHP 5.2 server. Can someone give me a hint on how can I fix the error? Thanks in advance. My PHP 5.2 Server script output shows: ++++++++++++++++ Object id #599 Object id #604 Object id #609 Object id #614 Object id #619 Object id #627 Object id #632 Object id #637 Object id #642 Object id #647 Object id #655 Object id #660 Object id #665 Object id #670 Object id #675 Object id #683 Object id #688 Object id #693 Object id #698 Object id #703 Object id #711 Object id #716 Object id #721 Object id #726 Object id #731 ++++++++++++++++ while PHP 5.9 Server says ++++++++++++++++ Rk Player Team POS OPPONENT 1 Aaron Rodgers GB QB at CAR 2 Tom Brady NE QB vs. SD 3 Matt Schaub HOU QB at MIA 4 Michael Vick PHI QB at ATL ++++++++++++++++ I did applied the bug solution listed on https://sourceforge.net/tracker/index.php?func=detail&aid=3107230&group_id=218559&atid=1044037 but it is still not working. It says: ++++++++++++++++ Details: I get compiler errors in PHP 5.2 when using this as an object. The offending lines are 609 and 940, which both contain this construct: if ($this->size>0) $this->char = $this->doc[0]; This tries to get the first character of $this->doc, but PHP 5.2 sees it as trying to access it as an array. It's easily fixed by this: if ($this->size>0) $this->char = substr($this->doc, 0, 1); Or you could probably use chr(ord($this->doc)) as well. Either way solves the compile error without changing functionality. ++++++++++++++++ Here are my codes: Code: [Select] <?php # don't forget the library include('simple_html_dom.php'); # this is the global array we fill with article information $articles = array(); $source = 'http://www.athlonsports.com/columns/winning-game-plan/fantasy-football-qb-rankings'; # passing in the first page to parse, it will crawl to the end # on its own getArticles($source); function getArticles($page) { global $articles, $descriptions; $html = new simple_html_dom(); $html->load_file($page); //$items = $html->find('div[class=preview]'); $items = $html->find('tbody tr'); foreach($items as $post) { # remember comments count as nodes /*$articles[] = array($post->children(3)->outertext, $post->children(6)->first_child()->outertext);*/ $articles[] = array($post->children(0), $post->children(1), $post->children(2), $post->children(3), $post->children(4)); } # lets see if there's a next page if($next = $html->find('a[class=nextpostslink]', 0)) { $URL = $next->href; echo "going on to $URL <<<\n"; # memory leak clean up $html->clear(); unset($html); getArticles($URL); } } ?> <html> <head> </head> <body> <? echo "Source: " . $source; ?> <table cellpadding="5" cellspacing="0" border="0"> <?php foreach($articles as $item) { echo "<tr>"; echo "<td>" . $item[0] . "</td><td>" . $item[1] . "</td><td>" . $item[2] . "</td>"; echo "<td>" . $item[3] . "</td><td>" . $item[4] . "</td>"; echo "<tr>"; } ?> </table> </body> </html> good day dear community, this is a big issue. I have to decide: between native PHP DOM Extension or of simple DOM html parser well i want to parse the site he http://buergerstiftungen.de/cps/rde/xchg/SID-A7DCD0D1-702CE0FA/buergerstiftungen/hs.xsl/db.htm http://buergerstiftungen.de/cps/rde/xchg/SID-A7DCD0D1-702CE0FA/buergerstiftungen/hs.xsl/db.htm I will suggest to use the native PHP "DOM" Extension instead of "simple html parser", since it will be much faster and easier What do you think about this one here...: Code: [Select] $doc = new DOMDocument @$doc->loadHTMLFile('...URL....'); // Using the @ operator to hide parse errors $contents = $doc->getElementById('content')->nodeValue; // Text contents of #content look forward to hear from you best regards db1 require_once 'phpSimpleHtmlDomClass.php'; $html = '<div> <div class="man">Name: madac</div> <div class="man">Age: 18 <div class="man">Class: 12</div> </div>' $name=$html->find('div[class="man"]', 0)->innertext; $age=$html->find('div[class="man"]', 1)->innertext; $cls=$html->find('div[class="man"]', 2)->innertext; wanna get a text from each div class="man" but it didn't work because there is a missing closing div tag on 2nd line of html code. please help me to fix this. thanks in advance. I have been coding in circles and I can't take it anymore! This is my code: $sqlid = "select * from temp where Email='".$a[8]."'"; $idresult = mysql_query($sqlid); $res = mysql_fetch_assoc($idresult); if ($idresult > 0) { $tempid = $res['ID']; die('sql id:' . $tempid . 'or' . $res['ID']. 'or ' . $sqlid ); }elseif (!$idresult) { die('there is no sql id'); } I am trying to populate the variable $tempid with the ID from the temp table. I know i am not the best coder but I thought I was close. I keep getting different errors. Some errors simply print out the sql select statement to the screen Other errors give me a resource #10. Please help. I can't think straight anymore. Im sure it's something simple. This topic has been moved to CSS Help. http://www.phpfreaks.com/forums/index.php?topic=330182.0 Hi everyone. I'm completely new to PHP. I've been trying to teach myself to code with it and learn as much as I can for the past few days because it'll definitely come in handy. So far, everything I've learned is just from articles and videos.
Anyway, let's skip the boring stuff.
For literally the whole day today, I've been trying to figure out what the heck is wrong with a script I'm working with. I didn't code it myself. I'm pretty much just modifying it to fit my needs from the generic "template" it comes in.
So here's the issue:
The script is basically used to run a website with user generated content. Users can upload images and write about them. One file of the script deals with the page where the user writes and submits his/her content. Before, I had no issues. I could write a title, a few sentences, upload an image and submit it to the server. Now, seemingly out of nowhere, I'm getting problems everywhere.
Here are the issues:
1. After I fill out the form and hit submit, the page doesn't redirect to my content.
2. As soon as I hit the submit button, the page goes blank (white screen) and gets stuck on mydomain.com/submit (which is the same page where I filled out the form)
3. Along with the white screen, I'm getting the following error on top of it:
Notice: Undefined index: name in .../public_html/include/p-page-ask.php on line 126
I've spent the last 12 hours trying to fix this. For issue 3, I've read that you can use the "isset" function to fix it. But I have no idea how to code that into it. I tried different variations, but none worked to make it go away. For issue 2, I'm guessing this is a fatal php error? I have no idea what's causing it. If I view source, I just get a blank page. For issue 1, I'm guessing this has to do with issue 2 halting the page from redirecting? I'm pretty sure 2 and 3 are different errors because I've read that even if 3 occurs, the page still loads.
I've turned on all the error reporting and display functions in my php.ini file. I made sure that the server is using that particular file with phpinfo(). (Although I didn't restart my server. I have no idea how to. I'm on a shared environment). After making these changes, I still don't see any additional errors, just the notice on a blank page.
I've looked through the code for syntax errors, but couldn't find any.
I've even installed xampp and made a test environment. I read through the documentation and watched tutorials on YouTube to set it up. (I've had absolutely 0 experience with this kind of stuff). I downloaded all the exact files from my online server into my localhost environment. Funny enough, it works just fine on my machine. It doesn't even throw errors locally. However, it doesn't work online. What the heck is going on?
The only differences I can think of between the two environments are the php versions and sql database versions (xampp is newer)...but I don't know if that really makes a difference because the script USED to work on my server, so it must be compatible with the set versions.
I've been editing the files in the script for quite a while now. I know when I first started, the uploads would work just fine. Then I didn't upload for a while because I already tested it out and knew it worked, so I just continued working on the script. I may have modified something that's now causing the errors. But then wouldn't that cause the localhost environment to fail too? If the files are exactly the same, how could one fail to work? That makes no sense at all. I'm looking at this code lost and hopeless. I'm getting sad.
If ANYONE has any suggestions on fixing this, PLEASE let me know. I don't know what to do anymore.
If you need me to upload any of the other files, just ask.
Here are the error logs from the server:
PHP Notice: Undefined index: name in .../public_html/include/p-page-ask.php on line 126, referer:mydomain.com/submit
...public_html/submit: No such file or directory WARNING: .../public_html/submit: Can't access file Here's the code for the page with the notice: <?php if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser header('Location: ../'); exit; } require_once QA_INCLUDE_DIR.'p-app-format.php'; require_once QA_INCLUDE_DIR.'p-app-limits.php'; require_once QA_INCLUDE_DIR.'p-db-selects.php'; require_once QA_INCLUDE_DIR.'p-util-sort.php'; // Check whether this is a follow-on question and get some info we need from the database $in=array(); $followpostid=qa_get('follow'); $in['categoryid']=qa_get_category_field_value('category'); if (!isset($in['categoryid'])) $in['categoryid']=qa_get('cat'); $userid=qa_get_logged_in_userid(); list($categories, $followanswer, $completetags)=qa_db_select_with_pending( qa_db_category_nav_selectspec($in['categoryid'], true), isset($followpostid) ? qa_db_full_post_selectspec($userid, $followpostid) : null, qa_db_popular_tags_selectspec(0, QA_DB_RETRIEVE_COMPLETE_TAGS) ); if (!isset($categories[$in['categoryid']])) $in['categoryid']=null; if (@$followanswer['basetype']!='A') $followanswer=null; // Check for permission error $permiterror=qa_user_maximum_permit_error('permit_post_q', QA_LIMIT_QUESTIONS); if ($permiterror) { $qa_content=qa_content_prepare(); // The 'approve', 'login', 'confirm', 'limit', 'userblock', 'ipblock' permission errors are reported to the user here // The other option ('level') prevents the menu option being shown, in qa_content_prepare(...) switch ($permiterror) { case 'login': $qa_content['error']=qa_insert_login_links(qa_lang_html('question/ask_must_login'), qa_request(), isset($followpostid) ? array('follow' => $followpostid) : null); break; case 'confirm': $qa_content['error']=qa_insert_login_links(qa_lang_html('question/ask_must_confirm'), qa_request(), isset($followpostid) ? array('follow' => $followpostid) : null); break; case 'limit': $qa_content['error']=qa_lang_html('question/ask_limit'); break; case 'approve': $qa_content['error']=qa_lang_html('question/ask_must_be_approved'); break; default: $qa_content['error']=qa_lang_html('users/no_permission'); break; } return $qa_content; } // Process input $captchareason=qa_user_captcha_reason(); $in['title']=qa_post_text('title'); // allow title and tags to be posted by an external form $in['extra']=qa_opt('extra_field_active') ? qa_post_text('extra') : null; $in['tags']=qa_get_tags_field_value('tags'); if (qa_clicked('doask')) { require_once QA_INCLUDE_DIR.'p-app-post-create.php'; require_once QA_INCLUDE_DIR.'p-util-string.php'; $categoryids=array_keys(qa_category_path($categories, @$in['categoryid'])); $userlevel=qa_user_level_for_categories($categoryids); $in['notify']=qa_post_text('notify') ? true : false; $in['email']=qa_post_text('email'); $in['queued']=qa_user_moderation_reason($userlevel) ? true : false; qa_get_post_content('editor', 'content', $in['editor'], $in['content'], $in['format'], $in['text']); $errors=array(); if (!qa_check_form_security_code('ask', qa_post_text('code'))) $errors['page']=qa_lang_html('misc/form_security_again'); else { $filtermodules=qa_load_modules_with('filter', 'filter_question'); foreach ($filtermodules as $filtermodule) { $oldin=$in; $filtermodule->filter_question($in, $errors, null); qa_update_post_text($in, $oldin); } if (qa_using_categories() && count($categories) && (!qa_opt('allow_no_category')) && !isset($in['categoryid'])) $errors['categoryid']=qa_lang_html('question/category_required'); // check this here because we need to know count($categories) elseif (qa_user_permit_error('permit_post_q', null, $userlevel)) $errors['categoryid']=qa_lang_html('question/category_ask_not_allowed'); if ($captchareason) { require_once 'p-app-captcha.php'; qa_captcha_validate_post($errors); } if (empty($errors)) { $cookieid=isset($userid) ? qa_cookie_get() : qa_cookie_get_create(); // create a new cookie if necessary $questionid=qa_question_create($followanswer, $userid, qa_get_logged_in_handle(), $cookieid, $in['title'], $in['content'], $in['format'], $in['text'], qa_tags_to_tagstring($in['tags']), $in['notify'], $in['email'], $in['categoryid'], $in['extra'], $in['queued'], $in['name']); qa_redirect(qa_q_request($questionid, $in['title'])); // our work is done here } } } // Prepare content for theme $qa_content=qa_content_prepare(false, array_keys(qa_category_path($categories, @$in['categoryid']))); $qa_content['title']=qa_lang_html(isset($followanswer) ? 'question/ask_follow_title' : 'question/ask_title'); $qa_content['error']=@$errors['page']; $editorname=isset($in['editor']) ? $in['editor'] : qa_opt('editor_for_qs'); $editor=qa_load_editor(@$in['content'], @$in['format'], $editorname); $field=qa_editor_load_field($editor, $qa_content, @$in['content'], @$in['format'], 'content', 12, false); $field['label']=qa_lang_html('question/q_content_label'); $field['error']=qa_html(@$errors['content']); $custom=qa_opt('show_custom_ask') ? trim(qa_opt('custom_ask')) : ''; $qa_content['form']=array( 'tags' => 'name="ask" method="post" action="'.qa_self_html().'"', 'style' => 'tall', 'fields' => array( 'custom' => array( 'type' => 'custom', 'note' => $custom, ), 'title' => array( 'label' => qa_lang_html('question/q_title_label'), 'tags' => 'name="title" id="title" autocomplete="off"', 'value' => qa_html(@$in['title']), 'error' => qa_html(@$errors['title']), ), 'similar' => array( 'type' => 'custom', 'html' => '<span id="similar"></span>', ), 'content' => array( 'tags' => 'name="content" id="content" autocomplete="off" class="hide"', 'value' => qa_html(@$in['content']), 'error' => qa_html(@$errors['content']), ), 'imgupload' => array( 'type' => 'custom', 'html' => '<label class="imguploadbtn" for="checkbox-menu3">Upload image</label>', ), 'imgprev' => array( 'type' => 'custom', 'html' => '<div class="imgprev"><img id="imgprev" />or</div>', ), 'imgurl' => array( 'type' => 'custom', 'html' => '<input id="imgurl" placeholder="image url" type="text" autocomplete="off" ><input type="checkbox" name="check1" id="imgurlc" class="hide" onclick="copyTextValue();"/> <label class="imgurlb" for="imgurlc">Add</label><script>$("#imgurl").on({ keydown: function(e) { if (e.which === 32) return false; }, change: function() { this.value = this.value.replace(/\s/g, ""); } });</script>', ), ), 'buttons' => array( 'ask' => array( 'tags' => 'onclick="qa_show_waiting_after(this, false); '. (method_exists($editor, 'update_script') ? $editor->update_script('content') : '').'"', 'label' => qa_lang_html('question/ask_button'), ), ), 'hidden' => array( 'editor' => qa_html($editorname), 'code' => qa_get_form_security_code('ask'), 'doask' => '1', ), ); if (!strlen($custom)) unset($qa_content['form']['fields']['custom']); if (qa_opt('do_ask_check_qs') || qa_opt('do_example_tags')) { $qa_content['script_rel'][]='p-content/p-ask.js?'.QA_VERSION; $qa_content['form']['fields']['title']['tags'].=' onchange="qa_title_change(this.value);"'; if (strlen(@$in['title'])) $qa_content['script_onloads'][]='qa_title_change('.qa_js($in['title']).');'; } if (isset($followanswer)) { $viewer=qa_load_viewer($followanswer['content'], $followanswer['format']); $field=array( 'type' => 'static', 'label' => qa_lang_html('question/ask_follow_from_a'), 'value' => $viewer->get_html($followanswer['content'], $followanswer['format'], array('blockwordspreg' => qa_get_block_words_preg())), ); qa_array_insert($qa_content['form']['fields'], 'title', array('follows' => $field)); } if (qa_using_categories() && count($categories)) { $field=array( 'label' => qa_lang_html('question/q_category_label'), 'error' => qa_html(@$errors['categoryid']), ); qa_set_up_category_field($qa_content, $field, 'category', $categories, $in['categoryid'], true, qa_opt('allow_no_sub_category')); if (!qa_opt('allow_no_category')) // don't auto-select a category even though one is required $field['options']['']=''; qa_array_insert($qa_content['form']['fields'], 'content', array('category' => $field)); } $field=array( 'label' => qa_html(qa_opt('extra_field_prompt')), 'tags' => 'name="extra" placeholder="image url" id="extra" class="hide"', 'value' => qa_html(@$in['extra']), 'error' => qa_html(@$errors['extra']), ); qa_array_insert($qa_content['form']['fields'], null, array('extra' => $field)); if (qa_using_tags()) { $field=array( 'error' => qa_html(@$errors['tags']), ); qa_set_up_tag_field($qa_content, $field, 'tags', isset($in['tags']) ? $in['tags'] : array(), array(), qa_opt('do_complete_tags') ? array_keys($completetags) : array(), qa_opt('page_size_ask_tags')); qa_array_insert($qa_content['form']['fields'], null, array('tags' => $field)); } if (!isset($userid)) qa_set_up_name_field($qa_content, $qa_content['form']['fields'], @$in['name']); if ($captchareason) { require_once 'p-app-captcha.php'; qa_set_up_captcha_field($qa_content, $qa_content['form']['fields'], @$errors, qa_captcha_reason_note($captchareason)); } $qa_content['focusid']='title'; return $qa_content; /* Omit PHP closing tag to help avoid accidental output */ Hello, im very green to php and I am having trouble creating a simple log in script. Not sure why this is not working, maybe a mysql_query mistake? I am not receiving any errors but nothing gets updated in the members table and my error message to the user displays. any help is appreciated! here is my php: <?php session_start(); $errorMsg = ''; $email = ''; $pass = ''; if (isset($_POST['email'])) { $email = ($_POST['email']); $pass = ($_POST['password']); $email = stripslashes($email); $pass = stripslashes($pass); $email = strip_tags($email); $pass = strip_tags($pass); if ((!$email) || (!$pass)) { $errorMsg = '<font color="#FF0000">Please fill in both fields</font>'; }else { include 'scripts/connect_db.php'; $email = mysql_real_escape_string ($email); $pass = md5($pass); $sql = mysql_query("SELECT * FROM members WHERE email='$email' AND password='$pass'"); $log_check = mysql_num_rows($sql); if ($log_check > 0) { while($row = mysql_fetch_array($sql)) { $id = $row["id"]; $_SESSION['id']; $email = $row["email"]; $_SESSION['email']; $username = $row["username"]; $_session['username']; mysql_query("UPDATE members SET last_logged=now() WHERE id='$id' LIMIT 1"); }//Close while loop echo "You are logged in"; exit(); } else { $errorMsg = '<font color="#FF0000">Incorrect login data, please try again</font>'; } } } ?> and the form: <?php echo $errorMsg; ?> <form action="log_in.php" method="post"> Email:<br /> <input name="email" type="text" /><br /><br /> Password:<br /> <input name="password" type="password" /><br /><br /> <input name="myBtn" type="submit" value="Log In" /> </form> suppose a page has the following tags Code: [Select] <div class = "news"> <div class = "article"> <h2>title 1</h2> <div class = "content"> <p>content 1....</p> </div> </div> <div class = "article"> <h2>title 2</h2> <div class = "content"> <p>content 2....</p> </div> </div> </div> is it possible to check, using simple html dom library, whether the value of <h2> is title 1 and then if it is echo it, or store it in a variable? what i've been able to do up to now is: <?php include('simple_html_dom.php'); foreach($article->find('div[class=news]') as $news) { foreach ($news->find('div[class=article]') as $content) { foreach ($content->find('h2') as $heading) { echo $heading; } } } ?> this only echos all the h2 so say I want to make a url decoder and put it on my website [php] <?php $url = "url"; $urldecode = urldecode($url); [\php] I want there to be an entry box for somenoe to put the url in, a submit button so they put the url in and hit submit then a box to display the new decoded url any help with this? Thanks Hi can someone pls help, im tryin a tutorial but keep getting errors, this is the first one i get after registering. You Are Registered And Can Now Login Warning: Cannot modify header information - headers already sent by (output started at /home/aretheyh/public_html/nealeweb.com/regcheck.php:43) in /home/aretheyh/public_html/nealeweb.com/regcheck.php on line 46 Guys I m trying to make a crawler and the crawler works fine but the problem is that after some random amount of time the crawler crashes with the message "PHP Fatal error: Maximum function nesting level of '100' reached, aborting! in ....." . Please help me out . Is it my code or there is a problem with simple html dom ?? Hiya! I need to create a simple PDF script that will always create A4 documents. I need the content to be controlled using HTML and CSS. Where do you start in creating such a script? Any help is greatly received. |