Jump to content

gary_rip

Members
  • Posts

    17
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

gary_rip's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Brill... showed me the correct way and explained it so i fully understand why. I really do appreciate your help! All working now as i desired!
  2. Using your example i have done this... // Execute query mysql_query($sql,$con); for ($i=0; $i<=199; $i=$i+1) { mysql_query("INSERT INTO tophotdeals (title, deal_link, mobile_deal_link, submit_time, hot_time, temperature) VALUES ('%s','%s','%s','%s','%s','%s')"; $query = sprintf($sql, mysql_real_escape_string('{$title[1][$i]}'), mysql_real_escape_string('{$deal_link[1][$i]}'), mysql_real_escape_string('{$mobile_deal_link[1][$i]}'), mysql_real_escape_string('{$submit_time[1][$i]}'), mysql_real_escape_string('{$hot_time[1][$i]}'), mysql_real_escape_string('{$temperature[1][$i]}')); } mysql_close($con); But it is showing error... Parse error: syntax error, unexpected ';' in /home/nawaj/public_html/hukd/top/top.php on line 82 Where am i going wroong? If i remove the : then i get a T_String error on 84?
  3. Having a look the ones that are missing contain ' So it would seem that i do need to add mysql_real_escape_string Im having trouble working out where i would need to place this as all of the examples seem to be using this with form data. Could anyone point me in the right direction? Thanks for all your help!
  4. I have tried the set_time_limit(120); and this has not worked. Although there is 200 rows with 5 columns there isn't much data and it takes only about 2 seconds to complete.
  5. This is what i have... $con = mysql_connect("localhost","xxxxx","xxxxx"); if (!$con) { die('Could not connect: ' . mysql_error()); } // Create table mysql_select_db("xxxxx_12345", $con); $sqldelete = "DROP TABLE table1"; mysql_query($sqldelete,$con); $sql = "CREATE TABLE table1 ( hotID int NOT NULL AUTO_INCREMENT, PRIMARY KEY(hotID), title text(10000), deal_link text(10000), mobile_deal_link text(10000), submit_time text(10000), hot_time text(10000), temperature text(10000) )"; // Execute query mysql_query($sql,$con); for ($i=0; $i<=199; $i=$i+1) { mysql_query("INSERT INTO tophotdeals (title, deal_link, mobile_deal_link, submit_time, hot_time, temperature) VALUES ('{$title[1][$i]}', '{$deal_link[1][$i]}', '{$mobile_deal_link[1][$i]}', '{$submit_time[1][$i]}', '{$hot_time[1][$i]}', '{$temperature[1][$i]}')"); } mysql_close($con); As you can see... very basic. I have changed it to text (10000) as i was just trying to get it to work. I will try the suggestions above.
  6. Hello, I have completed a limited search but i am unsure of the search term so look for a quick pointer. I have 200 rows of data. When i INSERT this into mysql database using PHP only 184 rows are inserted. I have a feeling that this is because there are "illegal" characters in what i am asking it to insert. Is there some code that i can put into my PHP or mysql so that it can ignore any illegal data? It might not even be illegal data? In which case could it be Null data? As you can see i am really unsure of my terminology! I welcome any help! Thanks Gary
  7. So simple! Thanks - you have made me very happy!
  8. Hello All, Long time since my last question... Each multidimensional array has 100 values. I wish to put each array into its own column and each value in to 100 different rows in the that column. At the moment i am getting "Array[1]" etc... put into the mysql database. My code is... for ($i=0; $i<=99; $i=$i+1) { mysql_query("INSERT INTO tophotdeals (title, deal_link, mobile_deal_link, deal_image, description, submit_time, hot_time, poster_name, temperature) VALUES ('$title[0][$]', '$deal_link[0][$i]', '$mobile_deal_link[0][$i]', '$deal_image[0][$i]', '$description[0][$i]', '$submit_time[0][$i]', '$hot_time[0][$i]', '$poster_name[0][$i]', '$temperature[0][$i')"); } In reading about, i don't think i want to use serialize, it looks like i want to use implode, but i cant find an example with many arrays and its all getting a bit confusing. I welcome any help! Thanks Gary
  9. Hey All... a little help needed if you will? This is the code that i am scraping from a site. <li>1455° <a style="position:relative; display:inline;" <li>795° <a style="position:relative; display:inline;" <li>59° <a style="position:relative; display:inline;" <li>49° <a style="position:relative; display:inline;" <li>4° <a style="position:relative; display:inline;" I would like to take just the number. Ive been using this code... <?php $regex = '/<li>(.+?)$/i'; preg_match_all($regex,$data,$match4); ?> Which i have tested on http://www.rubular.com/ and it seems it should work, but in practice it does not. Any suggestions? EDIT: Here is a perma link to Rubular with info filled in... http://www.rubular.com/regexes/6315
  10. Sorry for being vague, but you gave me all the answers that i needed to get my origional question resolved! Its just that as you correctly stated it was a problem with my array was populated... i was using preg_match and not preg_match_all RESOLVED!
  11. changed it to $match1 and its now outputting the first row of the table but its not looping to create the next 4 rows...
  12. Is this bit correct then? as i cant see where $match comes from... <?php $cnt = count($match); ?>
  13. Thanks for your help... but... When i use the code that you have posted nothing is echo'ed from thr array. Its like the inserted code does not run - looking at the source its not even creating the table tags. Any ideas?
  14. I'm not even sure i have the right title for this thread but... Here is my code <?php echo '<table border="1">'; echo '<tr>'; echo '<td>'.$match4[1].'</td>'; echo '<td><a href="http://www.awebsite.com/'.$match3[1].'" target="_blank">'.$match2[1].'</a></td>'; ?> I'm making a table from the data in the arrays, but i want to loop it so that every $match[X] jumps up a number and creates another row on the table. Sorry for the rubbish explanation... it doesn't help when i don't know the correct terminology!
×
×
  • 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.