-
Posts
3,404 -
Joined
-
Last visited
-
Days Won
55
Everything posted by Ch0cu3r
-
Where is this 'u":"PB4CwyDzE6FnnqDrnEoEPWIuC9_uWV"}] snippet of code from? You need to make it valid json syntax in order to decode it with json_decode You can do $json = '[{"u":"PB4CwyDzE6FnnqDrnEoEPWIuC9_uWV"}]'; $data = json_decode($json, true); echo $data[0]['u'];
-
I have modified your code so it will output an error if the query returned no results or an error <?php //GET PRIMARY PORTFOLIO ID IF NONE CAPTURED if (!$c_page) { // Query #1 $query = "SELECT id FROM gallery_rooms ORDER BY sort ASC LIMIT 1"; if($result = mysql_query($query)) { if(mysql_num_rows($result)) { $row = mysql_fetch_assoc($result); $c_page = $row['id']; } else { echo 'Query #1 returned no results!'; } } else { echo 'Database query #1 has failed - ' . mysql_error(); } } //---------------------------------------------------- //---------------------------------------------------- //FORMAT PORTFOLIO SIDE NAV $port_nav = ''; // Query #2 $query = "SELECT id, title FROM gallery_rooms ORDER BY sort ASC"; if($result = mysql_query($query)) { if(mysql_num_rows($result)) { while($row = mysql_fetch_array($result)) { $id = $row['id']; $title = trim(stripslashes($row['title'])); if ($c_page == $id) { $active = ' class="active_port"'; } else { $active = ''; } $port_nav .= '<li'.$active.'><a href="portfolio.php?p='.$id.'">'.$title.'</a></li>'; } } else { echo 'Query #2 returned no results!'; } } else { echo 'Database query #2 has failed - ' . mysql_error(); } //---------------------------------------------------- //---------------------------------------------------- //GET PORTFOLIO HEADER image $query = "SELECT * FROM photos WHERE category = '$c_page'"; // Query #3 if($result = mysql_query($query)) { if(mysql_num_rows($result)) { while($row = mysql_fetch_array($result)) { $imageID = $row['id']; $alt = trim(stripslashes($row['alt'])); $img_title = trim(stripslashes($row['title'])); $filename = $row['filename']; list($width, $height, $type, $attr) = getimagesize('photos/'.$filename); } } else { echo 'Query #3 returned no results!'; } } else { echo 'Database query #3 has failed - ' . mysql_error(); } if (!$filename) { $filename = 'not_available.jpg'; } $header_img = '<img src="photos/'.$filename.'" alt="'.$alt.'" title="'.$img_title.'" '.$attr.' />';
-
is this just another repeat of this http://forums.phpfreaks.com/topic/283160-problem-pulling-data-from-database/ and http://forums.phpfreaks.com/topic/282635-cannot-view-the-fields-unless-i-state-select-all-but-it-still-does-not-work/ You got this from phpacademy.org right? Ask them for support
-
Looks like they were trying to hack your site.
-
You're outputting new table rows for each value for host, server, current player, max player and boat class. Instead output these as table columns, not as rows. Output the table headings before the loop, then just echo the values as columns within a row. echo '<tr><th>Host</th>'; echo '<th>Server</th>'; echo '<th width=150px>Current Players</th>'; echo '<th width=150px>Maximum Players</th>'; echo '<th width=150px>Boat Class</th></tr>'; foreach($xml as $server) { if ($server->login!='') { echo '<tr><td>' .$server->login. '</td>'; echo '<td>' .$server->servername. '</td>'; echo '<td>' .$server->playercount. '</td>'; echo '<td>' .$server->maxplayercount. '</td>'; echo '<td>' .$server->currentvehiclename. '</td></tr>'; echo '<tr><td colspan=5>_______________________________________________________________________________</td></tr>'; } }
-
For the following rules to work RewriteRule ^([^/]*)\.html$ /trip.php?url=$1 [L] RewriteRule ^(.*)\.html$ $1.php [nc] You need some form of unique identifier in your url For example if domain.com/las-vagas.html should request trips.php?url=las-vagas and domain.com/trips.html should request trips.php how is the server going to know what url matches which rule? Both will match any url that contains .html and the first rewrite rule will always be used. For viewing trips to las-vagas I'd have urls like domain.com/trips/las-vagas.html To see trips.php I'd have I'd have urls like domain.com/trips/. The the following rules will match these urls and make the nessecary request #Matches domain.com/trips/las-vegas.html RewriteRule ^trips/([^/]).html trips.php?url=$1 [L] #Matches domain.com/trips/ RewriteRule ^([^/])/? $1.php [L]
-
PHP - AJAX select with onchange event doesn't work
Ch0cu3r replied to hitman47's topic in Javascript Help
Because the output of the ajax request (ajax_city.php) is used to add the city options to the page for the selected country. Yes. You just need to make sure when your php script receives the ajax request it only outputs the city options and not your whole webpage. For you to understand this more you'll want to research more about what is ajax and how it works. -
PHP - AJAX select with onchange event doesn't work
Ch0cu3r replied to hitman47's topic in Javascript Help
Have a look at the following example to get an idea of how to do this http://www.9lessons.info/2010/08/dynamic-dependent-select-box-using.html http://www.satya-weblog.com/2007/04/dynamically-populate-select-list-by.html -
So this is solved now? or you still have a problem?
-
Dynamically changing a link in php to have it point to a external page
Ch0cu3r replied to scuttzz's topic in PHP Coding Help
You don't store the whole webpage in the database. Each product you add to the database should contain just the raw information about it. Such as product id image(s) name description price (if applicable) etc Then in product.php you grab all the information about that product. Once you have got all data about that product you use PHP to generate the page. Using the database to just store the product image and then coding static webpages for each product is not very efficient. -
Most likely cause of a blank page is an error. Either turn error reporting on or view your servers error log to see what the error is.
-
Dynamically changing a link in php to have it point to a external page
Ch0cu3r replied to scuttzz's topic in PHP Coding Help
This line <a id="inventoryImage" href="product.php?id =' . $id .'"><img src="uploaded_images/' . $id . '.jpg"></a> Outputs the products image and the link to display the products information. Are you saying some products information are not stored in the database. Those that are not stored in the database have static html pages defined for them? -
Post tags for what exactly?
-
PHP - AJAX select with onchange event doesn't work
Ch0cu3r replied to hitman47's topic in Javascript Help
I would help if you explained what you're trying to do. -
if you need to do something with the data in each line of the file then you'd grab the contents of the file using file() and then use some form of loop to loop through lines in the array $filedata = file('filename'); foreach($filedata as $line => $data) { // do something // $line - contains the line number (n-1) (eg first line is 0, second line is 1 etc) // $data - contents of current line }
-
Are you wanting to update multiple records at the same time? You need to setup you form like this echo '<form action="edit_page.php" method="post"> <table> <tr> <th>Status</th> <th>Notes</th> </tr>'; while ($data = mysql_fetch_array($mitigation_query)) { $row_id = $data['id']; echo " <tr> <td width='56' height='20px'> <span id='MitigationOnTrack'><input type='text' name='mitigation[$row_id][status]' value=". $data['status'] ."></span> </td> <td width='758'> <input type=text name='mitigation[$row_id][id]' value=". $data['id'] ."> <textarea rows=5 cols=100 name='mitigation[$row_id][notes]'>" . $data['notes'] ."</textarea> </td> </tr>"; } echo ' <tr> <td colspan="2"><input type="submit" name="update" value="Update" /></td> <!-- one update field --> </tr> </table> </form>'; Then to update the records you'd use if(isset($_POST['update'])) { // loop through the form entries foreach($_POST['mitigation'] as $row_id => $mitigation) { $status = mysql_real_escape_string($mitigation['status']); $notes = mysql_real_escape_string($mitigation['notes']); $row_id = (int) $row_id; // update the row mysql_query("UPDATE mitigations SET `status`='$status', `notes`='$notes' WHERE id='$row_id'"); } }
-
php create mysql table with constraints help please
Ch0cu3r replied to webdevdea's topic in PHP Coding Help
host gator as in hostgator.com They provide phpmyadmin through cPanel -
php create mysql table with constraints help please
Ch0cu3r replied to webdevdea's topic in PHP Coding Help
Please don't say that is your actual mysql hostname, username and password in the code you posted above. If it is I strongly recommend you to change the password to your mysql server NOW! Never post your sensitive data such as usernames/password etc on the internet It can be configured to use your remote mysql database too, not just localhost. However surely the web site you're working on also has a tool available for importing MySQL dump files. Pretty sure every webhost that provides MySQL databases will also provide phpmyadmin access in some form. Who is your webhost? -
Wow! PHP3 was released in 1998 and end of life towards the end of the year 2000! Yes, PHP and MySQL can run on Windows Server 2008. The only version available is PHP5 and onwards. If you'e completely new to PHP you're better of getting your company to hire someone to do this conversion/upgrade for you.
-
php create mysql table with constraints help please
Ch0cu3r replied to webdevdea's topic in PHP Coding Help
Cant you just download phpmyadmin, and configure it with your MySQL hostname, username and password and you should be good to go then. if you cant get phpmyadmin then try this $hostname = 'localhost'; $username = 'YOUR_MYSQL_USERNAME'; $password = 'YOUR_MYSQL_PASSWORD'; $database = 'YOUR_MYSQL_DATABASE'; $sqlfile = 'path/to/the/sql-your-file'; $command="mysql -h $hostname -u $username -p $password $database < $sqlfile"; exec($command); -
Look at your table schema have you spelled the columns correctly when setting up the table? are they spelled the same as the columns in your query?
-
The session data is stored on the server. The session_id needs to be given to both the client and the server on each page request. The server will then fetch the session data that belongs to that session id. If you don't pass the session id from the client to the server then you wont be able to identify the user!
- 10 replies
-
You need to echo mysql_error(); for the error to be outputted.