-
Posts
3,404 -
Joined
-
Last visited
-
Days Won
55
Everything posted by Ch0cu3r
-
How to show static image when there is no dynamic image
Ch0cu3r replied to parlanchina's topic in PHP Coding Help
Your code should be <?php if(is_file($data['thumbnailUrl'])){ ?> <img src="<?php echo $data['thumbnailUrl'];?>" alt="" border="0" width="122" height="92"> <?php }else{ ?> <img src="noimage.jpg" width="168" height="128" alt="" /> <?php } ?> -
Loop through the array checking each value as you go. http://jsfiddle.net/nGPu2/
-
Remove the quotes, from around CustomerID in your query. So it is $theselectedrow = "SELECT * from CustomerTable WHERE CustomerID = 13";
-
Ok, check to make sure your query is returning an error. $theselectedrow = "SELECT * from CustomerTable WHERE 'CustomerID' = '13'"; $theselectedrowresults = mysql_query($theselectedrow); if(!$theselectedrowresults) { echo '<p><b>Database error:</b> ' . mysql_error() . '</p>'; } else { if(mysql_num_rows($theselectedrowresults)) { $row = mysql_fetch_assoc($theselectedrowresults); var_dump($row); } else { echo 'No results returned from query'; } }
-
So your code is this $theselectedrow = "SELECT * from CustomerTable WHERE 'CustomerID' = '13'"; var_dump($row);die(); Then, it will always be null. Because a) you have not executed the query and b) you haven't define $row.
-
Where have place that? Before or after you defined $row?
-
Here you have not got the results from the query. You have only queried the database $theselectedrow = "SELECT * from CustomerTable WHERE 'CustomerID' = '$CustomerIDforedit'"; $theselectedrowresults = mysql_query($theselectedrow); $count = mysql_num_rows($theselectedrowresults); You need to get the results from the query using one of the mysql_fetch_* functions. Eg $row = mysql_fetch_assoc($theselectedrowresults); // echo the form for editing record If your query returns multiple results, then you'll need to use a while loop while($row = mysql_fetch_assoc($theselectedrowresults)) { // echo form for editing record }
-
Change your code to $db=JFactory::getDBO(); $q = "select * from #__jbjobs_employer where user_id=".$job->employer_id; $db->setQuery($q); $employer_record = $db->loadObject(); $u = JFactory::getUser($job->employer_id); echo '<table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td>'.($employer_record->show_addr == 'y') ? $employer_record->street_addr : JText::_('JBJOBS_NOT_DISPLAYED')).'</tr> <tr> <td>'.(($employer_record->show_location == 'y')? $employer_record->city.', '.$employer_record->state : JText::_('JBJOBS_NOT_DISPLAYED')).'</td> </tr> <tr> <td>'.(($employer_record->show_phone == 'y')? $employer_record->primary_phone : JText::_('JBJOBS_NOT_DISPLAYED')).'</td> </tr> <tr> <td>'.(($employer_record->show_fax == 'y')? $employer_record->fax_number : JText::_('JBJOBS_NOT_DISPLAYED')).'</td> </tr> <tr> <td>'.(($employer_record->show_email == 'y')? $u->email : JText::_('JBJOBS_NOT_DISPLAYED')).'</td> </tr> </table>';
-
My code does not use that store array for displaying the store name. This code only displays the store, if the current item has a store array defined, hence the if statement // the store logo and name echo '<p><b>Buy From: </b>'; if(isset($item[$key]['store'])) { echo '<img src="'.$item[$key]['store']['logo']['sourceURL'].'" /> ' .$item[$key]['store']['name'] .'</p>'; }
-
Yes, you can update the lastname in a separate query. But it is more effeicent to update the firstname, and lastname within one query, using //update firstname and lastname fields $update = $dbh->prepare('UPDATE contacts SET first=:firstname, last=:lastname WHERE id=:id '); /* the update query */ $update->bindParam(':firstname', $_POST['first']); /* the firstname field */ $update->bindParam(':lastname', $_POST['last']); /* the lastname field */ $update->bindParam(':id', $_POST['id'], PDO::PARAM_INT); $update->execute();
-
Yes, change $queryString .= "t{$i}=$mp3file&"; to $queryString .= "t{$i}=" . substr($mp3file, 0, strlen($mp3file)-4) . '&';
-
the index.html needs to be saved as index.php Also I forgot to mention, you will need to change include 'billy.php'; to include 'music/billy.php'; Also change $mp3folder = '/mp3files/'; to $mp3folder = '/music/';
-
So you're using a Joomla Module to display news but you dont like how images are displayed on the page? I dont think you need regex is the answer. You just need to edit the template for that module to change how images are displayed.
-
because that is the version that works with apache. windows.php.net/download clearly states which is Thread Safe and Non Thread Safe. The non thread safe version (the one you have downloaded/installed) is for IIS, this could be why you keep getting the error message. And why the PHP src? That is only needed if you want to compile your own version, or extensions Uninstall PHP and do not use the installer it is not needed at all. ?? PHP4 is outdated. You should be using atleast PHP5.3 minimum. It doesn't matter if you use \\ or / in your file paths. I always use / in my file paths. Right lets start from the beginning. Uninstall Apache/PHP completely and delete any fils/folders leftover files from this process. Download a version of PHP5.x from windows.php.net/, making sure to chose the package that is labelled Thread Safe and is in zip format (stay clear of the installer). Take a mental note of the compile version you have downloaded (whether its VC9 or VC11) Once downloaded extract its contents to C:/php. Next head over to Apachelounge.com/download/. On the left, click of the VC version of PHP you just downloaded, now download the .zip file for Apache2.4.7. Once downloaded extract its contents to C:/apache Now open a command prompt with Administrative Privileges and run the following command C:/apache/bin/httdpd.exe -k install Now open windows exploder and navigate to C:/apache/bin/ApacheMonitor.exe and run it. (You might want to create a shortcut to the desktop for this as it a useful tool for controlling Apache). And click the Start button. This should load Apache with its default config state and should be running when you goto http://localhost. Now to configure it with PHP. Open the httpd.conf and add the following at the bottom of the file PHPIniDir "C:/PHP/" LoadModsule php5_module "C:/PHP/php5apache2_4.dll" AddType application/x-httpd-php .php Save the http.conf. Now using ApacheMonitor, click Restart and hopefully apache should now of loaded with PHP. You should be able to confirm this by creating a info.php file in C:/apache/htdocs, and then add the following code to it <?php phpinof(); ?> and then running http://localhost/info.php. You should see a page generated about PHP's configuration state and operating environment. A step I recommend you to take would be to add PHP to the Windows PATH Environment Variable. You do this by going to Start -> All Apps -> Control panel -> System -> Advanced System Settings -> Advanced -> Environment variables. On the window that pops up, select the Path from the System Variables list. Click Edit followed by pressing the End key on your keyboard. Now type C:\php; Click Ok to all windows, and then restart windows. Next rename C:/php/php.ini-recommended to C:/php/php.ini, and configure it use whatever extensions you require. Restart Apache after you have made any changes.
-
form to post multiple inputs into post_content table
Ch0cu3r replied to KJThaDon's topic in PHP Coding Help
Change <p class="question"><label>Description</label><input name="description[]" type="text"></p> <p class="question"><label>Your First Name</label><input name="description[]" type="text"></p> <p class="question"><label>Your Last Name</label><input name="description[]" type="text"></p> to <p class="question"><label>Description</label><input name="description" type="text"></p <p class="question"><label>Your First Name</label><input name="firstName" type="text"></p> <p class="question"><label>Your Last Name</label><input name="lastName" type="text"></p> Now get the description with $_POST['description'], the first name with $_POST['firstName'] and the last name with $_POST['lastName'] You'll then define 'post_content' using $post_content = '<p>Description: ' . $_POST['description'] . '</p>'. '<p>First Name: ' . $_POST['firstName'] . '</p>'. '<p>Last Name: ' . $_POST['lastName'] . '</p>'; ... $new_post = array( 'post_title' => $title, 'post_content' => $post_content, ... ); -
So what code is setting the $setts['default_theme'] variable? This variable is either not defined at the time the code you posted is being executed, or it is in fact set to a empty value. What is the output of printf('<pre>%s</pre>', print_r($setts, true)); This will print the array structure to $setts. What does it show for the default_theme key?
-
What file is this code in? <div id='tumblings-player'> <center><div id='playericon'><a href="http://tumblings.net...r-music-player"><img alt="Tumblr Music Player" src="http://i122.photobuc.../minigif01.gif"/></a></div></center> <div><?php include 'billy.php'; /* generates webplayer html, or displays an error */ ?> <div style="color:#000; background-color:#fff; padding:100px; font-size:10px;"><a href="http://tumblings.net...r-music-player">Tumblr Music Player</a></div> </div> </div> Does the file end in a .php extensions? If it does not then you'll need to rename the file so it does ends in a .php extension. Otherwise the php include will not be executed, and subsequently the music player wont load.
-
You may find the following pages from the manual useful http://php.net/manual/en/language.basic-syntax.phptags.php http://www.php.net/manual/en/language.basic-syntax.phpmode.php
-
it is mentioned, billy.php echo's the <embed> tag to the page. The code that does this is echo '<embed src="'.$baseurl.'/billy.swf?'.$queryString.'" quality="high" wmode="transparent" width="200" height="10" name="billy" align="middle" type="application/x-shockwave-flash" />'; The alternative would be to delete that line of code from billy.php. Now add the following line code <embed src="<?php echo $baseurl; ?>/billy.swf?<?php echo $queryString; ?>" quality="high" wmode="transparent" width="200" height="10" name="billy" align="middle" type="application/x-shockwave-flash" />'; After <?php include 'billy.php'; /* generates webplayer html, or displays an error */ ?>. And you'll get the same result.
-
You have now changed how the playlist is being sent to your swf, you have changed from this, where you are building a querystring of all files in the directory <embed src="billy.swf?autoplay=1&f0=file1.mp3&t0=song-title1&f1=file2.mp3&t0=sone-title2&etc.. ." ... /> To <embed src="http://www.isthisabstract.com/music/billy.swf?autoplay=true&phpurl=http://www.isthisabstract.com/music/billy.php" So how is your swf file reading the phpurl querystring parameter? I do not know how flash/actionscript handles this. As it stands, the code I provided for billy.php will only add .mp3 files to the playlist (it will ignore any other files). It'll then build the querystring (as your original code was trying to do) into the format posted above. It'll then return the embed html tag comlete with the formatted querystring. So if you had file1.mp3 and file2.mp3 in your folder my script will return this html <embed src="http://site.com/billy.swf?autoplay=1&f0=http://site.com/file1.mp3&t0=file1.mp3&f1=http://site.com/file2.mp3&t0=file2.mp3" quality="high" wmode="transparent" width="200" height="10" name="billy" align="middle" type="application/x-shockwave-flash" /> I have tested my code with the swf file provided by your site when clicking the advanced link.
-
You cant get that value in PHP, as whatever is after the # in the url it is not passed in the request to the server. What is happening in craftland is they are using jquery to get the hash, and then deciding what page load. Then the page is loaded using ajax.
-
Your class deals with $_SESSION and $_COOKIE variables. These variables usually associative arrays, whereby the data you are storing in that variable is assigned a key. This key is then used to retrieve that data associated to it. You cannot presume the keys will always exist. For example when someone logs in to your site you login you may store their username in the session using $_SESSION['username'] = $username; and you'd echo their username with echo $_SESSION['username']; the username key will only exist, when the user has logged in. It will not exist if they are not logged in. So you need to check that the username key exists first before using it. if(isset($_SESSION['username'])) echo 'Welcome, ' . $_SESSION['username']; // great the logged in user else echo 'Please login in'; // username key does not exist, so user must not be logged in ------------- So, jairathnem is correct that you need to use isset. About four of those notices are referencing line 39 return $_SESSION[SESSION_PREFIX.$variable]; Here you are presuming the key produced by SESSION_PREFIX.$variable exists in the $_SESSION array. A simple fix is to us isset return isset($_SESSION[SESSION_PREFIX.$variable]) ? $_SESSION[SESSION_PREFIX.$variable] : null; The above code will return the value, if the key exists. If it doesn't it'll return null. Simlarly their is a notice produced for line 71 $cookie_value = $_COOKIE[SESSION_PREFIX.$variable]; Again you're presuming the key produced by SESSION_PREFIX.$variable exists in $_COOKIE. A fix would be to check that it exists if(isset($_COOKIE[SESSION_PREFIX.$variable])) { // do something with cookie value } You should now be left with 4 notices, 3 of which are being reported from main_cron.php on line 315, 324 and 341. Again where you are using keys which you presume exists. The fix would be to check that they exist before using them. This will leave you with, one actual error being Check what are passing to that function is correct, The data you want decoded should be passed as the first argument. The second argument is for setting the flags, see php.net/html_entity_decode for possible options.