Jump to content

jason360

Members
  • Posts

    77
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

jason360's Achievements

Member

Member (2/5)

0

Reputation

  1. Okay...thanks for the info. Looks like I got a big job ahead of me switching to mysqli.
  2. Hello, I am trying to insert this string into my data base but it is failing and I am getting my die message. Anyone see why this is not working? I am connected to my database too. $string="Toyota, Volkswagen, Samsung, Ford, HewlettPackard"; $string=explode(',',$string); foreach($string as $val) { $val=strtolower($val); mysql_query('INSERT INTO companies (brands) VALUES ("'.$val[0].'")') or die ('fail insert'); }
  3. Hey guys, I am stumped on this htaccess write rule. I currently have this rule functioning: RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /item\.php\?pid=([a-z0-9]+)\ HTTP/ [NC] RewriteRule ^item\.php$ http://www.mysite.com/%1? [R=301,L] RewriteRule ^([-a-z0-9]+)$ /item.php?pid=$1 [NC,L] Original url: http://www.mysite.com/item.php?pid=2015-hyundai-genesis-coupe enabling this url: http://www.mysite.com/2015-hyundai-genesis-coupe What I require is a url like this: http://www.mysite.com/item/2015-hyundai-genesis-coupe I tried a bunch of things with no success. Anyone familiar with this? Thanks!
  4. Hey guys, I am not sure how to phrase this WHERE statement. I currently have this: WHERE approved = "1" AND item_gender="1" OR item_gender="3" It seems to be omitting the 'approved' part. What I require is that approved=1 must be adhered to regardless, but item_gender can be equal to 1 or 3. Any ideas what I am doing wrong? Thanks!
  5. Thanks for the prompt reply Psycho. I used your wildcard clean up and also found my problem. When being posted I was getting \" instead of just \. Used stripslashes function. Working like a charm now. I couldn't figure it out...I felt like i was on crazy pills...haha Thanks again! JK
  6. UPDATE: I realize it was this term triggering my preg_match: 42" AJ Slick How can I get it to accept " ' and + This is what I am using now: if(preg_match('/[^a-z0-9\-\_\,\!\?\+\"\'\ \.]+/i',$_POST['title'])) { $err[]='<p class="error" style="color: #ed1c24;">Your Name contains invalid characters!</p>'; }
  7. Anyone know why my preg_match is being triggered by this term: 3D Hobby Shop To me it should allow letters and numbers etc. My php: if(preg_match('/[^a-z0-9\-\_\,\!\?\+\ \.]+/i',$_POST['title'])) { $err[]='<p class="error" style="color: #ed1c24;">Your Title contains invalid characters!</p>'; }
  8. Hey guys, I am not sure how to do a proper range in my if statement. I need a range where count is between 1 and 10. I am using this statement below, but it is just considering the $count<=10 and 0 is included in this statement. I require a different function for $count = 0. Thanks in advance! if ($count <= 10 && $count >= 1)
  9. Thanks QuickOldCar...that was simple.
  10. Hey guys, I am stuck on this piece of code. Within the function I am using I need to include an mysql query. I am not sure how to insert it within the echo. Currently the query works but the code stops once close the '' and </ul> and </section> are cut out. Please note that there is alot more code within the echo, not just the section and ul. Just simplified it for my question. Any help would be appreciated. Thanks <?php $query = mysql_query('SELECT id FROM videos WHERE user="'.$id.'"'); list ($video_id) = mysql_fetch_array($query); if ($video_id != '') { echo '<section> <ul >'; $query = mysql_query('SELECT video FROM videos WHERE id="'.$id.'" ORDER BY RAND()'); $i = 0; class myCounter implements Countable { public function count() { static $count = 0; return ++$count; } } $counter = new myCounter; while ($row = mysql_fetch_array($query)) { if($i % 5 === 0) { } echo "<li data-path='feeds/api/videos/".$row['video']."' ></li>"; $i++; } '</ul> </section>'; ?>
  11. Thanks @mac_gyver I was able to make a large pool of results using the UNION function in my query. Here is a link if anyone else comes across this situation in the future: http://www.w3schools.com/sql/sql_union.asp
  12. I have started a function with various if statements and a counter. The individual queries are quite complicated. I have been using individual queries with a counter and if statements, however when a category has 4 or more results it just takes over the whole function and the other categories are not included. I figured explaining it this way would be simpler.
  13. Hey guys I am stuck on how to best create a php function to do the following. I need to echo out 4 restaurants. I have a database of numerous restaurant categories: breakfast, lunch, dinner, and coffee. In this database some categories have more results than others. Basically I want to randomly choose results from each category query, Breakfast, Lunch, and dinner to create 4 echoed results. (I understand that one category will have an extra result as there are 3 categories and 4 echoed results.) I do not want one category of restaurant to bump out another category because it has more results. Also, if there are not enough or no results from one category, I want extra results from the other queries to make up for it so that there are always 4 echoed items. Finally, if there are not enough results from breakfast, lunch, dinner to make 4 echoed items, I would like Coffee to fill the 4 required results. Randomly echo 4 results from the below primary queries: Primary Query: Breakfast Restraunts Query Primary Query: Lunch Restraunts Query Primary Query: Dinner Restraunts Query Get results from secondary query if Primary queries can’t echo 4 results: Secondary Query: Coffee Shops Query I hope this makes sense. I understand how to do the mysql queries, I just don't know how to do the php function to echo the results as required. Any help would be appreciated!
  14. Thanks Ch0cu3r! That was simple. I didn't know you could use > and < in the query.
×
×
  • 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.