Jump to content

acctman

Members
  • Posts

    582
  • Joined

  • Last visited

Everything posted by acctman

  1. thanks for all the tips ... I'm going to find a tutorial on mysqli to bring myself up to speed
  2. can someone assistance me with converting this code over to mysqli. I know that mysqli requires 2 parameters instead of one... i tried $user = mysqli_real_escape_string($g_link, $en['user']); but no connection was passed. $user = mysql_real_escape_string($en['user']); $pass = mysql_real_escape_string($en['pass']); $sql = "SELECT m_id, m_user, m_pass, m_email, m_del FROM $membtable WHERE m_user='".$user."' AND m_pass='".$pass."' AND m_del!=1"; $result = mysql_query($sql); $line = mysql_fetch_assoc($result); Db Connection $g_link = false; function GetDbConn() { global $g_link; if( $g_link ) return $g_link; $g_link = mysqli_connect($db_server, $db_user, $db_pass) or die("Error " . mysqli_error($g_link)); mysqli_select_db($g_link, 'cialdb') or die('Could not select database.'); return $g_link; }
  3. after re-reading your response I found the problem. I did not have the database in $con... the error checked worked.
  4. but I have if (mysqli_num_rows($loadSession) == 0) { to had if it's 0 (false). Am I missing something?
  5. I'm trying to resolve these to mysqli update changes. I've rewritten the statements a few times but just keep receiving errors. Can some show me how to rewrite the mysqli_result() correctly. - thanks Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in $loadSession = mysqli_query($con, "SELECT smo.* FROM social_members_online AS smo LEFT JOIN social_members AS sm ON smo.o_id=sm.m_id WHERE smo.o_id='".session_id()."' ...); $result = mysqli_fetch_assoc($loadSession); // Check the Result if (mysqli_num_rows($loadSession) == 0) { // User has no session, create one mysqli_query($con, "INSERT INTO social_members_online (o_id,o_start,o_last,o_session_id,o_ip) VALUES (".(int)$_SESSION['userid'].", ".time().",".time().",'".session_id()."','$ }
  6. can someone help me change this to preg_replace_callback. i'm receiving the following error Warning: preg_replace_callback(): Requires argument 2, '@constant("\1")', to be a valid callback in //load current language foreach ($langs as $key => $value) if ($value['l_code'] == lang) break; $f = fopen('languages/'.$langs[$key]['l_file'],'r') or die('Cannot open language file '.$langs[$key]['l_file']); while (!feof($f)) { $s = chop(fgets($f,4096)); if ($s{0} == '#') continue; list($key,$value) = explode('=',$s,2); $value = preg_replace('/<%(.*)%>/sUe', '@constant("\\1")', $value); $def[$key] = $value; } fclose($f);
  7. I'm trying to use htmlspecialchars() to escape apostrophe foreach(htmlspecialchars($_POST) as $key=>$val) { but it's not escaping / working. Am I placing it in the wrong place? thanks in advance if(isset($_POST['save_your_application']) || isset($_POST['save_progress'])) { $errors = 0; $detailsArray = array(); $insertArray = array(); foreach($_POST as $key=>$val) { $stringDivide = explode("_", $key); // Break up key name $type = end($stringDivide); // Get the TYPE of field $fullKey = $key; //$key = substr($key, 0, -4); // Get the field name (deleting the TYPE from the end) // IF FIELD IS A NUMBER if(strcmp($type, "num") == 0) { $array = array(); $array['key'] = $key; $array['value'] = (int)$val; if($val == "") $array['value'] = NULL; $array['type'] = $type; $insertArray[] = $array; } // IF FIELD IS TEXT elseif(strcmp($type, "txt") == 0) { $array = array(); $array['key'] = $key; $array['value'] = $val; $array['type'] = $type; $insertArray[] = $array; } $detailsArray[$fullKey] = $val; } if(isset($_POST['save_progress']) && $_POST['save_progress'] == 1) { $status = 3; } else { $status = 2; } if(isset($_POST['other_user'])) { $userID = $_POST['other_user']; } elseif(isset($_GET['other_user'])) { $userID = $_GET['us']; } else { $userID = $_SESSION['ID']; } // THIS IS WHERE WE SEND STUFF TO DB applicationSubmit($userID,$insertArray,$status); if($userID == $_SESSION['ID'] && $status == 2) { send_email($_SESSION['ID'],"has completed their application."); } if(isset($_POST['save_your_application'])) $sent = 2; else $sent = 1; } else { if(isset($_GET['other_user'])) { $userID = $_GET['other_user']; } else { $userID = $_SESSION['ID']; } $application = getUserApplication($userID); $detailsArray = array(); if(is_array($application)) { foreach($application as $key=>$val) { if(is_numeric($key)) {} else { if(strcmp($key, "id") == 0 || strcmp($key, "fk_userid") == 0 || strcmp($key, "status") == 0 || strcmp($key, "submit_date") == 0 ) { $detailsArray[$key] = $val; } else { $detailsArray[$key] = decrypt_app($val,$GLOBALS['SITE_CONFIGURATION']['KEY_APP']); } } } } //$detailsArray['status'] = getApplicationStatus($_SESSION['ID']); //print_r($detailsArray); }
  8. I'm trying to check if there is and image after the <td> tag, and if there is grab the width value. the method i'm using below is not working $element = $html->find("td", 23); if ($element->innertext != null) { $element = $html->find("td img[src=http://pictures.domain.com/images/7.gif]"); echo $element->width . '<br />'; } else { echo "empty"; }
  9. Hi i'm using Simple HTML Dom to scrap a site page. I'm trying to grab the width value for each img src. Below is the html and php i've been using so far. <table> <tr> <th colspan="4"> <font size="3" color="#a74165">Interest Levels</font> </th> </tr> <tr> <td nowrap> <font size="2">MobileT</font> </td> <td><img src="http://pictures.domain.com/images/7.gif" alt="1 on a scale of 0-4" border="0" height="15" width="9"> </td> <td> </td> <td nowrap> <font size="2">MobileC</font> </td> <td> <img src="http://pictures.domain.com/images/7.gif" alt="3 on a scale of 0-4" border="0" height="15" width="27"> </td> </tr> <tr> <td nowrap> <font size="2">Moderate</font> </td> <td><img src="http://pictures.domain.com/images/7.gif" alt="3 on a scale of 0-4" border="0" height="15" width="27"> </td> <td> </td> <td nowrap> <font size="2">Males</font> </td> <td> </td> </tr> <tr> <td nowrap> <font size="2">Wild</font> </td> <td><img src="http://pictures.domain.com/images/7.gif" alt="3 on a scale of 0-4" border="0" height="15" width="27"> </td> <td> </td> <td nowrap> <font size="2">Females</font> </td> <td> <img src="http://pictures.domain.com/images/7.gif" alt="4 on a scale of 0-4" border="0" height="15" width="36"> </td> </tr> </table> include('simple_html_dom.php'); $html = new simple_html_dom(); $html = file_get_html('http://dev.domain.com/'); $element = $html->find("td font[size=3]", 0); echo $element-> plaintext . '<br>'; $element = $html->find("font", 7); echo $element-> plaintext . '<br>'; $element = $html->find("font[color=red]", 0); echo $element-> plaintext . '<br>'; $element = $html->find("font", 3); echo $element-> plaintext . '<br>'; # city state country $element = $html->find("font[size=2]", 3); echo $element-> plaintext . '<br>'; $element = $html->find("font[size=2]", 10); echo $element-> plaintext . '<br>'; $element = $html->find("font[size=2]", 11); echo $element-> plaintext . '<br>'; $element = $html->find("font[size=2]", 12); echo $element-> plaintext . '<br>'; $element = $html->find("font[size=-1]", 0); echo $element-> plaintext . '<br>'; $element = $html->find("font[size=-1]", 1); echo $element-> plaintext . '<br>'; $element = $html->find("font[size=-1]", 2); echo $element-> plaintext . '<br>'; $element = $html->find("font[size=-1]", 3); echo $element-> plaintext . '<br>'; $html->clear();
  10. Hi does anyone have an example of using a PHP code to access the .htpasswd file for a user / pass login.
  11. I almost have the data I want... this is a bit tricky. (pic at bottom) The query below returns all records with a status of Member-id5 but I need to filter that look up. if I did a simple query on ect. (exp_channel_titles) for author_id 323 I would get 5 results. Of those 5 results one has a status of 'Member-id5', another one has a status of 'complete' and title of %Member%. That's the deciding factor. If that row exist with status = complete and title = %Member% then its okay to grab the entry_id of row status = Member-id5 to use for looking up the data in ecd (exp_channel_data) with in it. SELECT ect.entry_id , ect.author_id , ect.title , ect.status , ecd.field_id_13 , ecd.field_id_14 , ecd.field_id_15 , ecd.field_id_25 , ecd.field_id_27 , ecd.field_id_28 , ecd.field_id_29 , ecd.field_id_30 , ecd.field_id_31 , ecd.field_id_32 , ecd.field_id_33 , ecd.field_id_34 , ecd.field_id_35 , exm.email FROM exp_channel_titles as ect LEFT JOIN exp_channel_data as ecd ON ecd.entry_id = ect.entry_id LEFT JOIN exp_members as exm ON exm.member_id = ect.author_id WHERE ect.status = 'Members-id5'
  12. do add it like this exm.email, ecd.field_id_14, ecd.field_id_15 ... and is there a better way to do it other than subqueries?
  13. here's what I got so far.... my out put is only should entry_id, author_id, title and status. What I need to show in the results is all the fields_* and email SELECT ect.entry_id, ect.author_id, ect.title, ect.status FROM exp_channel_titles as ect LEFT JOIN (SELECT entry_id, field_id_14, field_id_15, field_id_25, field_id_27, field_id_28, field_id_29, field_id_30, field_id_31, field_id_32, field_id_33, field_id_34, field_id_35 FROM exp_channel_data) as ecd ON ecd.entry_id = ect.entry_id LEFT JOIN (SELECT member_id, email FROM exp_members) as exm ON exm.member_id = ect.author_id WHERE ect.title LIKE '%Member%' AND ect.status = 'complete'
  14. I'm trying to create a query to where the code below will work... I typed out the general idea of what I'm trying to do SELECT entry_id, author_id, title, status FROM exp_channel_titles WHERE title LIKE %Member Package% AND status = 'complete' LEFT JOIN SELECT entry_id, field_id_14, field_id_15, field_id_25, field_id_27, field_id_28, field_id_29, field_id_30, field_id_31, field_id_32, field_id_33, field_id_34, field_id_35 FROM exp_channel_data WHERE entry_id = exp_channel_titles.entry_id LEFT JOIN SELECT member_id, email FROM exp_members WHERE member_id = exp_channel_titles.author_id I tried something like this but got an error. #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.field_id_14, d.field_id_15, d.field_id_25, d.field_id_27, d.field_id_28, d.fiel' at line 3 SELECT t.entry_id, t.author_id, t.title, t.status d.field_id_14, d.field_id_15, d.field_id_25, d.field_id_27, d.field_id_28, d.field_id_29, d.field_id_30, d.field_id_31, d.field_id_32, d.field_id_33, d.field_id_34, d.field_id_35, m.member_id, m.email FROM exp_channel_titles t LEFT JOIN exp_channel_data d on t.entry_id = d.entry_id LEFT JOIN exp_members m on t.author_id = m.author_id WHERE t.title LIKE %Member% AND t.status = 'complete'
  15. I'm not getting any errors but its also not INSERTing into the database. Without an error I can figure out whats wrong. $db_server = 'localhost'; $db_user = 'user_db'; $db_pass = 'password'; $dbc = mysql_connect ($db_server, $db_user, $db_pass); if (!$dbc) { die(mysql_error()); header ('Location: /form'); exit; } if (is_array($_POST)) { foreach ($_POST as $key => $value) { $_POST[$key] = mysql_real_escape_string(stripslashes($value)); } } $xRequestType = $_POST["xRequestType"]; $xConsumerBusiness = $_POST["xConsumerBusiness"]; $xGlobalLocation = $_POST["xGlobalLocation"]; $xFirstName = strtolower(str_replace("'","''",$_POST["xFirstName"])); $xFirstName = strtoupper(substr($xFirstName,0,1)).substr($xFirstName,1); $xLastName = strtolower(str_replace("'","''",$_POST["xLastName"])); $xLastName = strtoupper(substr($xLastName,0,1)).substr($xLastName,1); $xEmail = strtolower(str_replace("'","''",$_POST["xEmail"])); $xTitle = strtolower(str_replace("'","''",$_POST["xTitle"])); function dbSet($fields, $source = array()) { $set=''; if (!source) $source = &$_POST; foreach ($fields as $field) { if (isset($source[$field])) { $set.="`$field`='".mysql_real_escape_string($source[$field])."', "; } } return substr($set, 0, -2); } // INSERT INTO DATABASE mysql_select_db("new_contact",$dbc) or die("Could not select new_contact"); $fields = explode(" ", "xRequestType xConsumerBusiness xGlobalLocation xFirstName xLastName xEmail xTitle xCompany xAddress xCity xState xZip xPhone xFax xProductDesc xComment"); $query = "INSERT INTO new_contact SET ".dbSet($fields, $_POST); mysql_query($query);
  16. can someone visually just read through my code and let me know if this looks like it'll work? I'm not getting any errors in my IDE so now I want to double check the structure <?php require_once '/usr/local/cpanel/3rdparty/lib/php/Mail.php'; $db_server = 'localhost'; $db_user = '-----'; $db_pass = '-----'; $dbc = mysql_connect ($db_server, $db_user, $db_pass); if (!$dbc) { die(mysql_error()); header ('Location: /contact'); exit; } if ($_POST['contactsent'] != 'yes') { header ('Location: /contact'); exit; } else { if (is_array($_POST)) { foreach ($_POST as $key => $value) { $_POST[$key] = mysql_real_escape_string(stripslashes($value)); } } $RequestType = $_POST["RequestType"]; $ConsumerBusiness = $_POST["ConsumerBusiness"]; $GlobalLocation = $_POST["GlobalLocation"]; $FirstName = strtolower(str_replace("'","''",$_POST["FirstName"])); $FirstName = strtoupper(substr($FirstName,0,1)).substr($FirstName,1); $LastName = strtolower(str_replace("'","''",$_POST["LastName"])); $LastName = strtoupper(substr($LastName,0,1)).substr($LastName,1); $Email = strtolower(str_replace("'","''",$_POST["Email"])); $Title = strtolower(str_replace("'","''",$_POST["Title"])); $Title = strtoupper(substr($Title,0,1)).substr($Title,1); $Company = strtolower(str_replace("'","''",$_POST["Company"])); $Company = strtoupper(substr($Company,0,1)).substr($Company,1); $Address = strtolower(str_replace("'","''",$_POST["Address"])); $Address = strtoupper(substr($Address,0,1)).substr($Address,1); $City = strtolower(str_replace("'","''",$_POST["City"])); $City = strtoupper(substr($City,0,1)).substr($City,1); $State = $_POST["State"]; $Zip = $_POST["Zip"]; $Phone = $_POST["Phone"]; $F = $_POST["F"]; $ProductDesc = $_POST["ProductDesc"]; $Comment = $_POST["Comment"]; if ($GlobalLocation == "Canada"): $SendTo="canadainfo@------.com"; elseif ($GlobalLocation == "Central America"): $SendTo="customer.service@------.com.pa"; elseif ($GlobalLocation == "Europe"): $SendTo="marketing@-----.uk"; elseif ($GlobalLocation == "Mexico"): $SendTo="ventas@------.com.mx"; else: $SendTo="info@------.com"; endif; function dbSet($fields, $source = array()) { $set=''; if (!source) $source = &$_POST; foreach ($fields as $field) { if (isset($source[$field])) { $set.="`$field`='".mysql_real_escape_string($source[$field])."', "; } } return substr($set, 0, -2); } // INSERT INTO DATABASE mysql_select_db("new_contact",$dbc) or die("Could not select new_contact"); $fields = explode(" ", "RequestType ConsumerBusiness GlobalLocation FirstName LastName Email Title Company Address City State Zip Phone F ProductDesc Comment"); $query = "INSERT INTO new_contact SET ".dbSet($fields, $_POST); mysql_query($query); // SETUP EMAIL $Bodycopy = "This information was submitted via the ------.com website and sent to you because of the location identified by the user. <br>If this has reached you in error, please forward this email to info@------.com"; $Bodycopy. "<br>----------------------------------------------------------------------------------------------<br><br>"; if ($RequestType != "") $Bodycopy. "What kind of information do you need? : " .$RequestType. "<br>"; if ($ConsumerBusiness != "") $Bodycopy. "What type of customer or vendor are you? : " .$ConsumerBusiness. "<br>"; if ($GlobalLocation != "") $Bodycopy. "Global Location : " .$GlobalLocation. "<br>"; if ($Company != "") $Bodycopy. "Company : " .$Company. "<br>"; if ($FirstName != "") $Bodycopy. "First Name : " .$FirstName. "<br>"; if ($LastName != "") $Bodycopy. "Last Name : " .$LastName. "<br>"; if ($Title != "") $Bodycopy. "Title : " .$Title. "<br>"; if ($Email != "") $Bodycopy. "Email : " .$Email. "<br>"; if ($Address != "") $Bodycopy. "Address : " .$Address. "<br>"; if ($City != "") $Bodycopy. "City : " .$City. "<br>"; if ($State != "") $Bodycopy. "State : " .$State. "<br>"; if ($Zip != "") $Bodycopy. "Zip/Postal Code : " .$Zip. "<br>"; if ($Phone != "") $Bodycopy. "Phone : " .$Phone. "<br>"; if ($F != "") $Bodycopy. "F : " .$F. "<br>"; if ($ProductDesc != "") $Bodycopy. "UPC or product description : " .$ProductDesc. "<br>"; $Bodycopy. "<br>----------------------------------------------------------------------------------------------<br><br>"; if ($Comment != "") $Bodycopy. "Comments : <br>" .$Comment. "<br>"; $Bodycopy. "<br><br>"; $Bodycopy. $IP = $_SERVER["remote_addr"]; // PROCESS EMAIL // mail server info... $from = $SendTo; $to = "Do Not Reply <donotreply@------>"; $subject = "Website Contact : " . $GlobalLocation; $body = $Bodycopy; $host = "mail.------"; $port = "25"; $username = "donotreply@-------"; $password = "-------"; $headers = array ('From' => $from, 'To' => $to, 'Subject' => $subject); $smtp = Mail::factory('smtp', array ('host' => $host, 'auth' => true, 'port' => $port, 'username' => $username, 'password' => $password)); $mail = $smtp->send($to, $headers, $body); if (PEAR::isError($mail)) { echo("<p>" . $mail->getMessage() . "</p>"); } else { echo("<p>Message successfully sent!</p>"); } // MAKE SURE DB CONN IS CLOSED mysql_close($dbc); // REDIRECT TO THANK YOU PAGE header ('Location: /index.php?option'); exit(); } ?>
  17. this issue I'm having is that I have unlisted videos that do not show up on the feeds list. So I need to authenticate myself so I can grab the video ID's.
  18. Does anyone know of a json or php method of authenticating a youtube user without using zend? <?php $id = NULL; $username = 'myYouTubeAccount'; $url = 'http://gdata.youtube.com/feeds/api/users/%s/uploads?orderby=updated&max-results=8'; $xml = simplexml_load_file(sprintf($url, $username)); foreach ($xml->entry as $entry) : $kids = $entry->children('http://search.yahoo.com/mrss/'); $attributes = $kids->group->content[0]->attributes(); $flv = $attributes['url']; $attributes = $kids->group->player->attributes(); $link = $attributes['url']; $querystring = parse_url($link,PHP_URL_QUERY); parse_str($querystring, $id_temp); $id = $id_temp['v']; ?> <a href="<?=$link?>"> <img src="http://i4.ytimg.com/vi/<?=$id?>/default.jpg" /> </a> <?php endforeach; ?>
  19. The html file i'm scraping from has 11 boxevent div classes and I want to loop through them and grab the results and team name for each. Am I doing it the right way? Also how can I loop through all float-right result and team classes grabbing the data. <div class="boxevent"> <div class="row"> <span class="float-right result">4</span> <span class="team" title="Pittsburgh Power ">PIT</span> </div> <div class="row"> <span class="float-right result">12</span> <span class="team" title="Orlando Predators ">ORL</span> </div> </div> <div class="boxevent"> <div class="row"> <span class="float-right result">24</span> <span class="team" title="Atlanta ">ATL</span> </div> <div class="row"> <span class="float-right result">6</span> <span class="team" title="Miami ">MIA</span> </div> </div> **php** <?php include 'includes/simple_html_dom.php'; $html = new simple_html_dom(); $html = file_get_html('http://score...', false, $context); $score0 = $html->find('span[class=float-right result]', 0); $score1 = $html->find('span[class=float-right result]', 0); $team0 = $html->find('span[class=team]', 0); $team1 = $html->find('span[class=team]', 0); /* out */ echo '<pre>'; print_r($score0); print_r($score1); print_r($team0); print_r($team1); echo '</pre>'; $html->clear(); unset($html); ?>
  20. i figured it out... $i = 1; if (mysql_num_rows($bio) == 0) call404(); while ($line = mysql_fetch_assoc($bio)) { foreach ($line as $key => $value) { $en['b'.$key . $i] = str_replace("\n",'<br/>',stripslashes($value)); } $i++; }
  21. something like this i'm trying to do. I think my order is wrong for the increment if (mysql_num_rows($bio) == 0) call404(); $i=1; while ($line = mysql_fetch_assoc($bio)) { $line . $i; foreach ($line as $key => $value) { $en['b'.$key] = str_replace("\n",'<br/>',stripslashes($value)); } $i++; } echo $en['bm_pos1'];
  22. this is confusing me a bit, I have an idea... is there a way to add an increment number to $line for every complete loop? so then i'll have $en['bm_pos0'] and $en['bm_pos1'] this will allow me to use <%bm_pos0%> and <%bm_pos1%> in my template coding. So how can I add just a number after each complete loop (row of fields) while ($line = mysql_fetch_assoc($bio)) { foreach ($line as $key => $value) { $en['b'.$key] = str_replace("\n",'<br/>',stripslashes($value)); } }
  23. yes i tried that $line['m_id'] $line['m_pos'] etc... that works but it does not separate between rows. there is 1 -2 rows of data coming back from the table. so if i did $line['m_id'] i would get two of them and I won't be able to tell which is which.
  24. I'm having trouble trying to separate the output into variables that I can use/echo on my page. when I do a print I see the two rows of data all grouped together how can I separate each result base on field and row? maybe something like $line['m_id'][0], $line['m_name'][0], $line['m_id'][1], $line['m_name'][1], etc... $bio = mysql_query("SELECT * FROM soc_meminfo WHERE m_id = '".mysql_real_escape_string($en['mm_id'])."'"); if (mysql_num_rows($bio) == 0) call404(); while ($line = mysql_fetch_assoc($bio)) { foreach ($line as $key => $value) { $en['b'.$key] = str_replace("\n",'<br/>',stripslashes($value)); } echo '<pre>'; print_r($line); echo '</pre>'; }
  25. Which method is more efficient and optimized for storing and retrieving data on a potential large site this version would store all the info in the member table which means only accessing 1 table m_country = US m_state = NY m_city = NEW YORK m_postal = 10011 m_user = joe SELECT m_user, m_country, m_state, m_city, m_postal FROM s_MEMBERS WHERE $en_user = m_user this one has one entry in the member table, then goes to the search_us table to get the info. Just looking at the code this option would appear best. But, multiple at least two queries will be needed because I'll also have to reference the MEMBER table. I like to avoid LEFT JOINs so i'd probably use a second query or pull what I can from already stored session data. m_place = 103 SELECT us_id, us_zip, us_city, us_abv FROM search_US WHERE $en_place = us_id
×
×
  • 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.