Web Design Forums

PHP

Have questions about PHP? Ask them here and our experts will assist you before you know it! You can also find help in the documentation at PHP.net.

MySQL Problems With Insertinf PHP Code



Site of the Month Nominations
ENTER YOUR SITE NOW!

Reply
 
LinkBack Thread Tools
Old May 10 '07, 12:18 PM (#1)
leprechaun13 is offline
WDF Regular
 
leprechaun13's Avatar
 
Join Date: May 2005
Location: Northampton
Posts: 487
leprechaun13 will become famous soon enough
Send a message via AIM to leprechaun13 Send a message via MSN to leprechaun13
MySQL Problems With Insertinf PHP Code

Ive wrote a small articles script here To view the link you have to Register and would like to know how i can put php in the database so it gives the correct output.

Im trying with this PHP

PHP Code:
<?php
srand
(time());
$max=13// This is the number of photo you have in your directory (eg. numbered 1-50)
$arr = array();
while ( 
count($arr) < $max ) {
$x mt_rand(1,$max);
if ( !
in_array($x,$arr) ) { $arr[] = $x; }

$p1 "photo_".$arr[0].".jpg";
?>
<div style="text-align:center; padding-top:30px;">
<img src="/images/random/<?php echo $p1 ?>" />

<br /><br />


You Are Viewing Picture <?php echo $arr[0?><br />
How About Another? Just Hit F5

</div>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old May 10 '07, 03:23 PM (#2)
mlseim is offline
WDF Staff
 
mlseim's Avatar
 
Join Date: April 2004
Location: Cottage Grove, Minnesota
Posts: 3,405
mlseim has much to be proud ofmlseim has much to be proud ofmlseim has much to be proud ofmlseim has much to be proud ofmlseim has much to be proud ofmlseim has much to be proud ofmlseim has much to be proud ofmlseim has much to be proud ofmlseim has much to be proud ofmlseim has much to be proud of
I don't see the connection between the MySQL articles and
the random .jpeg image. Are you trying to do a random article?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old May 10 '07, 06:11 PM (#3)
filburt1 is offline
bored
 
filburt1's Avatar
 
Join Date: July 2002
Location: Maryland, US
Posts: 11,785
filburt1 is a name known to allfilburt1 is a name known to allfilburt1 is a name known to allfilburt1 is a name known to allfilburt1 is a name known to allfilburt1 is a name known to all
If you're doing what I think you're doing in that loop, this is much more efficient: To view the link you have to Register

Your code gets exponentially more inefficient the more elements there are because the probability of in_array() returning true increases.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old May 11 '07, 02:11 AM (#4)
leprechaun13 is offline
WDF Regular
 
leprechaun13's Avatar
 
Join Date: May 2005
Location: Northampton
Posts: 487
leprechaun13 will become famous soon enough
Send a message via AIM to leprechaun13 Send a message via MSN to leprechaun13
I just wanted to run my entire site from a simple artciles/cms script but cant get it to output the correct data when using a php script.. it doesnt matter what the script is it still cleans the data ad converts all of the data into its html entities.



filb i got the php script in the tutorials section so dont really know how it works i just know it works

Last edited by leprechaun13; May 11 '07 at 02:12 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old May 11 '07, 09:02 AM (#5)
mlseim is offline
WDF Staff
 
mlseim's Avatar
 
Join Date: April 2004
Location: Cottage Grove, Minnesota
Posts: 3,405
mlseim has much to be proud ofmlseim has much to be proud ofmlseim has much to be proud ofmlseim has much to be proud ofmlseim has much to be proud ofmlseim has much to be proud ofmlseim has much to be proud ofmlseim has much to be proud ofmlseim has much to be proud ofmlseim has much to be proud of
Phil ...

This is probably too late to mention now,
but I think Joomla is the answer for you.

Before you dig in deeper, you might want
to check it out.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old May 13 '07, 01:57 PM (#6)
leprechaun13 is offline
WDF Regular
 
leprechaun13's Avatar
 
Join Date: May 2005
Location: Northampton
Posts: 487
leprechaun13 will become famous soon enough
Send a message via AIM to leprechaun13 Send a message via MSN to leprechaun13
used joomla and mambo before, I found too many restrictions as far as templating and didnt like the fact that they werent semantic so I wrote my own solution.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

  Web Design Forums » Programming Help » PHP

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Top 21 PHP Programming mistakes thexchord PHP 19 June 18 '10 02:20 PM
PHP and MySQL issues: PHP not loading extensions!! darknailblue PHP 5 January 2 '07 09:02 PM
Help: expand/collapse menu with php and mysql ChiDao PHP 1 February 2 '06 01:54 PM
Prepared statements (PHP 5 / MySQL 4.1.x) rosland Coding Articles & Tutorials 0 February 25 '05 09:18 PM
need PHP and mySQL help jbagley PHP 4 November 4 '04 07:24 AM

 
User Infomation
Your Avatar

Site Of The Month

Ticket Cake
Ticket Cake

Ticket Cake is a drupal based event ticketing platform. It features that ability to browse events and share them.

Nominate Your Site Now!

Advertisement
WolfCMS.org

Latest Articles
- by RickM
- by bfsog

Advertisement

Partner Links



All times are GMT -4. The time now is 02:56 AM.


WebDesignForums.net is Copyright © 2010 RikeMedia.

SEO by vBSEO

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163