PHP - Baffled For This... Why It Is Working?
Hello,
NOTE: I'm not asking for help to modify the code below, only looking for feedback regarding why it is working
I'm working over other's people code and I found this lines:
<div class="button-container" style="top:20px; left:0px"> <input type="submit" name="submit" value="Get Report" <a href="#" class="large-button" style="left: 0px" > <div class="button-glare"> </div> </a> </div>Clearly the input tag is wrong (W3C validator confirm it), however works fine and does what is supposed to do (apply some css styles over the submit button). IE11 Developer tools detect the errors, but FF nor Chrome does. this is what it looks like (attached image) and this is the related CSS /* CSS Document */ /* Button Containers */ .button-container { float: left; overflow: visible; position: relative; } .button-container .large-button { background: linear-gradient( to top, green, lightgray); border-radius: 6px; font-size: 14px; font-weight: bold; color: #FFFFFF; line-height: 14px; padding: 10px 20px 8px; text-shadow: -1px -1px 1.5px rgba(0, 0, 0, 0.5); position: relative; } .button-container .button-glare { border-radius: 4px; height: 50%; left: 1px; position: absolute; right: 1px; top: 1px; z-index: -1; }any idea why it does work? thanks Miko Similar TutorialsHey everyone, I'm getting an error on this code and I'm having a difficult time sorting it out. Most of this page is in html, but here is what little PHP I'm using as of now: Code: [Select] <select class="ddbox2" name="occasion"> <option value="select" selected>- Select -</option> <?php $resdate = "02/20/2012"; $result = mysql_query("SELECT `time` FROM delivery_times WHERE `index` > '0'"); while ($row = mysql_fetch_row($result)) { $posstime = $row[0]; $reserved = mysql_query("SELECT * FROM reservations WHERE `resdate` = '$resdate' AND `deltime` == '$posstime'"); $rowcheck = mysql_num_rows($reserved); // <-- THIS IS LINE 198 if ($rowcheck == 0) { echo "<option value='$posstime'>$posstime</option>"; } } ?> </select> What I'm doing is creating a dropdown menu for an html form depending on what is in my database, but here is the error that I'm getting: "Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\wamp\www\new_site\custform.php on line 198" When I change line 198 to read: $rowcheck = mysql_num_rows($result); I don't get the error, but I don't get the information that I need to complete my task. I was thinking that maybe this query isn't allowed in a while loop for some reason, but I don't think that would be the case. Any ideas on what I could be doing wrong? The alias form isn't being read for some reason, with having $alias = $_POST['alias']; i don't quiet understand why this isn't it isn't being picked up as a variable below, any clues? cheers Code: [Select] <?php include("header.php"); if(isset($_POST['formAlias']) && $_POST['formAlias'] == 'Yes') { $alias = $_POST['alias']; $alias = preg_replace("/[^a-zA-Z0-9_]/", "", $alias); $namelength = strlen($alias); if($namelength < 3){ $error1="Your alias must be at least 3 characters!</span></div>"; echo $error1; }else{ } $query = sprintf("SELECT COUNT(id) FROM players WHERE UPPER(alias) = UPPER('$alias')", mysql_real_escape_string($alias)); $result = mysql_query($query); list($count) = mysql_fetch_row($result); if($count >= 1) { $error1="$alias is already taken."; echo $error1; }else{ } $sql = "updatehereble"; mysql_query($sql) or die(mysql_error()); }else{ } ?> </p> <p> <input name="alias" type="text" id="alias"> </p> <form action="alias.php" method="post"> Do you wish to use an alias? <input type="checkbox" name="formAlias" value="Yes" /> <input type="submit" name="formSubmit" value="Submit" /> </form> Hi I'm trying to update a form to a mysql database- it's simply all text fields except for one integer which is the primar key (auto increment etc) http://www.arts.ulster.ac.uk/interviews/test.php http://www.arts.ulster.ac.uk/interviews/thanks3.php test.php holds the form and the recaptcha which all seems to be fine and it posts to thanks3.php which (when i switched to $_GET) is passing the variables to that page but those values are not being stored. I then input my query into the mySQL query browser: INSERT INTO UCASinterviews VALUES ('','$name','$address','$UCAS','$tel','$email','$mob','$subject','$interviewdate','$interviewtime','$parents'); which updated the values i put in but gave this error: Incorrect integer value: '' for column 'ID' at row 1 thanks3.php just won't transfer that info to the table no matter what I try. I used $_GET, I used PHP_SELF, I stripped the rest of the page away to make sure nothing was conflicting and now I'm totally stumped- please could someone look at this with fresh eyes? test.php: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Untitled Document</title> </head> <body> <form action="thanks3.php" method="post" id="form2" style="margin-left:15px; display:;"> <dl id="contform"> <dd><label>Name:</label><br /> <input class="padform" type="text" name="name" size="43" maxlength="20" tabindex="2"/></dd> <label>UCAS ID:</label><br /> <input class="padform" name="UCAS" type="text" id="UCAS" tabindex="3" size="43" maxlength="30"/></dd> <dd> <label>Email:</label><br /> <input class="padform" name="email" type="text" id="email" tabindex="3" size="43" maxlength="30"/></dd> <dd> <label>Mobile:</label><br /> <input class="padform" name="mob" type="text" id="mob" tabindex="3" size="43" maxlength="30"/></dd> <dd> <label>Landline:</label><br /> <input class="padform" name="tel" type="text" id="tel" tabindex="3" size="43" maxlength="30"/></dd> <dd> <label>Subject:</label><br /> <select name="subject" tabindex="1" class="padform"> <option value="English">English</option> <option value="European Studies">European Studies</option> <option selected value="Film Studies">Film Studies</option> <option value="French">French</option> <option value="German">German</option> <option value="History">History</option> <option value="Irish">Irish</option> <option value="Spanish">Spanish</option> <option value="Journalism">Journalism</option> <option value="Photo Imaging">Photo Imaging</option> <option value="Media Studies and Production">Media Studies & Production</option> <option value="Interactive Media Arts">Interactive Media Arts</option> </select></dd> <dd><label>Address:</label><br /> <textarea class="padform"name="address" cols="40" rows="15" id="address" tabindex="5"/> </textarea></dd> <dd> <label>Preferred Interview Date:</label> <select name="interviewdate" class="padform"> <option value="26/02/11">26 February 2011</option> <option selected value="12/03/11">12 March 2011</option> </select> </dd> <dd> <label>Preferred Interview Time:</label> <select name="interviewtime" class="padform"> <option value="AM">Morning (AM)</option> <option selected value="PM">Afternoon (PM)</option> </select> </dd> <dd> <label>Parents/Guardians:</label> <select name="parents" class="padform"> <option value="1">1</option> <option selected value="2">2</option> </select> </dd> <dd> <p> <?php require_once('recaptcha/recaptchalib.php'); $publickey = "6LdU2b4SAAAAAGsh6Z78HjunUL6Mt-ZqCXtIimOs"; // you got this from the signup page echo recaptcha_get_html($publickey); ?> </p> </dd> <dd style="background:none;"><input class="btn" type="submit" name="submit" value="Send" tabindex="6" id="submit" /></dd> </dl> </form> </div> </body> </html> thanks3.php <?php require_once('recaptcha/recaptchalib.php'); $privatekey = "6LdU2b4SAAAAAN_Z9rLyvle0vb4n4EbyAVyXDa6V"; $resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if (!$resp->is_valid) { // What happens when the CAPTCHA was entered incorrectly die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." . "(reCAPTCHA said: " . $resp->error . ")"); } else { // Your code here to handle a successful verification require_once("../includes/db_connect.php"); if($_POST['submit']=="true"){ $name=$_POST['name']; $address=$_POST['address']; $UCAS=$_POST['UCAS']; $mobile=$_POST['mob']; $email=$_POST['email']; $tel=$_POST['tel']; $subject=$_POST['subject']; $interviewdate=$_POST['interviewdate']; $interviewtime=$_POST['interviewtime']; $parents=$_POST['parents']; $addEntry="INSERT INTO UCASinterviews VALUES ('','$name','$address','$UCAS','$tel','$email','$mob','$subject','$interviewdate','$interviewtime','$parents');"; $addResult=mysql_query($addEntry,$db); } } ?> I have other forms working with this near enough the same structure/layout/code - i'm ready to have a coronary! Is it the database setup? It's same as it ever was myISAM, UTF unicode... PHP = 5.5.14
MySQL = 5.2.17
I've cloned a mysqli_connect() statement in a 'require' file placed in a non-public access location on the server. It's the same format (and location) currently working fine with another application, EXCEPT i changed the database name to what I need to use for this application, AND added the $con= part on the front end to substitute for the commented out $con= line in the example code I'm modifying to insert data into a new MySQL DB Table.
The dB Table is fine and I have Inserted data via myPHPAdmin with no problems. Only two form variables are in the simple PHP script thus far just to test if it will work before proceeding.
I've used pseudonames for the actual /home/.... location and filename, and am now Baffled about the Line 2 Error Message I'm getting (below the code).
<?php require '/home/myusername/domains/mydomain.com/myclonedrequire.php'; //$con=mysqli_connect("example","uid","pwd","my_db"); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } // escape variables for security $year = mysqli_real_escape_string($con, $_POST['year']); $callsign = mysqli_real_escape_string($con, $_POST['callsign']); $sql="INSERT INTO `lqplogs` (`year`, `callsign`) VALUES ('$year', '$callsign'); if (!mysqli_query($con,$sql)) { die('Error: ' . mysqli_error($con)); } echo "1 record added"; mysqli_close($con); ?>ERROR Message: Warning: Unexpected character in input: '\' (ASCII=92) state=1 in (above file & location) on line 2 There are NO '\' characters in any of my files. Here is the simple Form file code: <?php ?> <html: <head><title></title></head> <body> <form action="insert.php" method="post"> YEAR: <input type="text" name="year"> CALLSIGN: <input type="text" name="callsign"> <input type="submit"> </form> </body> </html> <?php ?>Thanks for any assistance! -FreakingOUT i dont understand what is wrong plz help me.
here is code
$name = "img/".rand(1,9999999).".png"; $myFile = $name; $fh = fopen($myFile, 'w') or die("can't open file"); $stringData = $html; fwrite($fh, $stringData); fclose($fh); $file=$name; $fst=file_get_contents($file); $im=imagecreatefromstring($fst); imagefilter($im, IMG_FILTER_GRAYSCALE); imagefilter($im, IMG_FILTER_NEGATE); //Convert to Grey Scale for($i=0;$i<123;$i++){ for($j=0;$j<50;$j++){ $px=imagecolorat($im,$i,$j); if($px<0x303030){ imagesetpixel($im,$i,$j,0); }else{ imagesetpixel($im,$i,$j,0xffffff); } } } $database = unserialize(@file_get_contents("db.txt")); if($database === false) $database = array(); // modify the database if needed if($_SERVER['REQUEST_METHOD'] == 'POST'){ if($_POST['submit'] == 'Add') $database[$_POST['ident']] = substr($_POST['letter'], 0, 1); if($_POST['submit'] == 'Del') unset($database[$_POST['ident']]); if($fh = @fopen('db111.txt', 'w+')){ fwrite($fh, serialize($database)); fclose($fh); } }else{ $newimage = true; } $width = 130; $height = 40; $captcha_gridstart =1; $captcha_gridspace =2; $letters = findletters($im, $width, $height, $captcha_gridstart, $captcha_gridspace); $count = count($letters); $cellw = ($count > 0) ? intval(100 / $count) : 0; //dispeckle the image and GET co-ordinates of the characters of captcha image and return them. function findletters($image, $width, $height, $gridstart, $gridspace){ $offsets = array(); $o = 0; $atstartx = true; for($x = 0; $x < $width; $x++){ $blankx = true; for($y = 0; $y < $height; $y++){ if(imagecolorat($image, $x, $y) == 0){ $blankx = false; break; } } if(!$blankx && $atstartx){ $offsets[$o]['startx'] = $x; $atstartx = !$atstartx; }else if($blankx && !$atstartx){ $offsets[$o]['endx'] = $x; $atstartx = !$atstartx; $o++; } } $count = $o; for($o = 0; $o < $count; $o++){ for($y = 0; $y < $height; $y++){ $blanky = true; for($x = $offsets[$o]['startx']; $x < $offsets[$o]['endx']; $x++){ if(imagecolorat($image, $x, $y) == 0){ $blanky = false; break; } } if(!$blanky){ $offsets[$o]['starty'] = $y; break; } } for($y = $height-1; $y > $offsets[$o]['starty']; $y--){ $blanky = true; for($x = $offsets[$o]['startx']; $x < $offsets[$o]['endx']; $x++){ if(imagecolorat($image, $x, $y) == 0){ $blanky = false; break; } } if(!$blanky){ $offsets[$o]['endy'] = $y; break; } } } for($o = 0; $o < $count; $o++){ $offsets[$o]['ident'] = ""; for($x = $offsets[$o]['startx'] + $gridstart; $x < $offsets[$o]['endx']; $x += $gridspace){ for($y = $offsets[$o]['starty'] + $gridstart; $y < $offsets[$o]['endy']; $y += $gridspace){ $offsets[$o]['ident'] .= ((imagecolorat($image, $x, $y) == 0) ? "0" : "1"); #echo $offsets[$o]['ident'].'<br>'; } } } return $offsets; } $a=""; foreach($letters as $letter){ $asciiletter = $database[$letter['ident']]; if(!empty($asciiletter)) { $a.=$asciiletter; } } http://paste.ee/p/OhiWv
The above is a link to a readable version of my code. The XMLHTTPREQUEST worked, and the array was pulled down. Was able to print out the undecoded/unparsed array. However, immediately afterwards, all code stops working.
<script> var xhr; if (window.XMLHttpRequest) { // Mozilla, Safari, ... xhr = new XMLHttpRequest(); } else if (window.ActiveXObject) { // IE 8 and older xhr = new ActiveXObject("Microsoft.XMLHTTP"); } xhr.open("POST", "PHPLibrary/selectMemberResults.php", true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.send(); xhr.onreadystatechange = display_data; var $phparray function display_data() { if (xhr.readyState == 4) { if (xhr.status == 200) { //alert(xhr.responseText); $phparray = xhr.responseText; document.getElementById("suggestion").innerHTML = $phparray; // // //......................................................? // The above line of code is the last thing to print or // to do anything that returns to the browser.... //.......................................................? // All lines below do nothing............................? // } else { //alert('There was a problem with the request.'); } } } document.write("Length of phparray Array :" + $phparray.length + "<"); var output = JSON.parse($phparray, function (key,val) { if ( typeof val === 'string' ) { // regular expression to remove extra white space if ( val.indexOf('\n') !== -1 ) { var re = /\s\s+/g; return val.replace(re, ' '); } else { return val; } } return val; } ); document.write("Length of Array :" + $output.length + "<"); for (var i=0; i < $output.length; i++) { document.getElementById("suggestion").innerHTML = $output[i].MEMBER_NAME; } </script> I need bit of help, so I am looking into a plugin created for newsletter where default is it shows ad but it has option to remove ads by checking the check box. Default is to send ads in newsletter but if you don't want to send ads through newsletter then check the box. The problem is, it seems like checkbox selected is not being picked up. Some help would be appreciated. The custom field in wp:
'label' => 'Hide newsletter ads', 'name' => 'hide_ads', 'type' => 'checkbox', 'instructions' => 'Checking the checkbox will remove ads', 'required' => 0, 'conditional_logic' => 0, 'wrapper' => array( 'width' => '', 'class' => '', 'id' => '', ), 'choices' => array( 'Hide newsletter ads' => 'Hide newsletter ads', ), 'allow_custom' => 0, 'default_value' => array( ), 'layout' => 'block', 'toggle' => 0, 'return_format' => 'value', 'save_custom' => 0, ),
This is the php code for it: <!doctype html> <html lang="en-GB"> <head> <meta name="viewport" content="width=device-width" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta name="x-apple-disable-message-reformatting"> <title><?php the_title(); ?></title> <style> <?php require ABSPATH . 'path/newsletter.css'; ?> </style> <!--[if mso]> <style type="text/css"> .outlook-fallback-font { font-family: 'Lucida Bright', 'Cambria', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif; } </style> <![endif]--> </head> <?php $hide_newsletter_ads = get_field('hide_ads'); echo $hide_newsletter_ads; ?> <body itemscope itemtype="http://schema.org/EmailMessage"> <div class="wrap"> <?php if (!$hide_newsletter_ads) { include ABSPATH . 'path/ad-banner.php'; } ?> <div class="header"> <a href="<?php bloginfo( 'url' ); ?>"> <img src="<?php echo get_home_url().'logo.png' ?>" alt="News" /> </a> </div> <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <?php if ( get_field( 'newsletter_summary' ) ) { ?> <div class="newsletter-summary"><?php the_field( 'newsletter_summary' ); ?></div> <?php } ?> <?php if ( have_rows( 'newsletter_content' ) ) : ?> <?php // Loop through the ACF blocks $count = 0; while ( have_rows( 'newsletter_content' ) ) : the_row(); if ( get_row_layout() === 'story' ) : ?> <?php if ( 0 === $count ) { ?> <span class="date outlook-fallback-font"><?php the_time( 'd M Y' ); ?></span> <?php } ?> <?php if ( get_sub_field( 'story_heading' ) ) : ?> <h1><?php the_sub_field( 'story_heading' ); ?></h1> <?php endif; ?> <div class="content"> <?php the_sub_field( 'story_content' ); ?> </div> <?php endif; if ( 'post_list' === get_row_layout() ) : ?> <?php $posts = get_sub_field( 'post_list' ); if ( $posts ) : ?> </div> <div class="story-list"> <h2><span class="wrap"><?php the_sub_field( 'post_list_heading' ); ?></span></h2> <div class="wrap-table"> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <?php // Output story cards foreach ( $posts as $i => $post ) { if ( 0 === $i % 2 ) { echo '<tr>'; } $class = ( 0 === $i % 2 ) ? 'odd' : 'even'; $image_src = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), array( 640, 345 ) ); $image_srcset = wp_get_attachment_image_srcset( get_post_thumbnail_id( $post->ID ) ); echo sprintf( '<td class="story-cell %4$s" valign="top"> <a href="%1$s" class="story-card outlook-fallback-font"> <img src="%3$s" alt="" height="120" style="height: 150px; object-fit: cover;" /> <span>%2$s</span> </a> </td>', esc_url( get_permalink( $post->ID ) . '?utm_source=newsletter&utm_medium=email&utm_campaign=newsletter' ), // permalink esc_html( get_the_title( $post->ID ) ), // title // esc_attr( $image_src[0] ), // image - src esc_attr( $image_src[0] ), // image - src esc_attr( $class ) // class ); if ( 0 !== $i % 2 || count( $posts ) === ( $i + 1 ) ) { echo '</tr>'; } } ?> </table> </div> </div> <div class="wrap"> <?php endif; endif; if (!$hide_newsletter_ads) { (0 === $count) { include ABSPATH . 'path/mpu-1.php'; } if (1 === $count) { include ABSPATH . 'path/mpu-2.php'; } } $count++; endwhile; endif; ?> <div class="footer"> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr> <td align="left"> © <?php echo esc_html( date( 'Y' ) ); ?> </td> <td class="footer-link"> <a href="<?php echo get_permalink( get_page_by_path( 'privacy-policy' ) ); ?>">Privacy Policy</a> · <a href="%unsubscribe_url%">Unsubscribe</a> </td> </tr> </table> </div> </div> <?php endwhile; endif; ?>
I'm trying to turn this while loop into a for loop and am unable to get my result set to display properly in the for loop. The while works fine I just want to be able to have more control over which information is shown in my table as I loop and was wanting to use a for loop that way I can take advantage of the counter variable while i"m displaying my information. Any help would be appreciated. while ($row = mysql_fetch_assoc($data_result_set)) { echo "<td>".$row["product_id"]."</td>"; echo "<td>".$row["city"]."</td>"; echo "<td>".$row["quantity"]."</td>"; } *** I'm wanting it to look like something like this but can't figure out how to properly work in which row to display with the $i variable. $count=mysql_num_rows($data_result_set); for($i = 0; $i <= $count; $i++){ echo "<td>".mysql_fetch_assoc[$i]["product_id"]."</td>"; echo "<td>".mysql_fetch_assoc[$i]["city"]."</td>"; echo "<td>".mysql_fetch_assoc[$i]["quantity"]."</td>"; } I know the syntax for the for loop is totally off with the method mysql_fetch_assoc just dropped in there like a jerk but I'm just kinda pseudoing it out. Any help would be appreciated. Thanks in advance. When I echo the POST, it echoes the correct value. The MySQL portion seems to just ignore it all together. I've tried changing the dropdown option to just a text field, same thing occurred. I have text fields right above this particular one that update just fine with the SAME exactly scripting. if POST, update query, done. Works. This one for some reason will not. MySQL portion: if ($_POST['bUpdate']){ mysql_query("UPDATE `Patients` SET `b` = '$_POST[bUpdate]' WHERE `id` = '".$_GET['id']."'"); } echo $_POST['bUpdate']; Form Portion: Code: [Select] <tr onmouseover="color(this, '#baecff');" onmouseout="uncolor(this);"> <td width="310" colspan="2" align="center"><span class="fontoptions">Postcard Status </span><br /> <? if ($data['b'] == 1){ echo '<select name="bUpdate"><option value="1" selected>Yes</option><option value="0">No</option></select>'; } else { echo '<select name="bUpdate"><option value="1">Yes</option><option value="0" selected>No</option></select>'; } ?> </td> </tr> Hi, I have the following file structure /.htaccess /index.php /displaypage.php All files are on root. I have following written in .htaccess file Options FollowSymLinks RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([a-z0-9-]+)$ displaypage.php?page=$1 [NC,L] I have following written in displaypage.php echo $_GET["page"]; Now when I run http://localhost/ then it shows index.php page which is correct. If I run http://localhost/something then it shows a blank page. Previously it used to display that "page" variable on screen. mod_rewrite is enabled and I am using Windows with XAMPP. What am I doing wrong? Thanks I just did a huge import from an app I have been working on. No issues except for this. I uploaded & imported all files & databases from my wampserver (localhost, local server) to my main online server. Before I continue with the problem, I have to give you info on how the files work. I am using a "controller" to view the files. Meaning, from index.php, I call all the files. For example, instead of mysite.com/register.php, its mysite.com/index.php?page=register. The index defines the doctype & html tags etc. The other files that are called through index.php are just pure php code, it does not contain the head & body tags etc. So, the issue is , when the surfer submits a form, i need to set a cookie. this cookie is VERY important. I cannot get it to work. I am getting the header warnings after submit Of course, this is to be expected. But I tried it on my local server, & it worked. I am not very familiar with cookies, this is a side of PHP i never really even touched. I know almost everything but that. So the php code is before the html code on the page, so I figured it was worth a shot. Im guessing the problem here is, since the code being outputted as index.php code + the form page code. So the cookie is being set after the html tags. How can I fix this? I need it to work thru the controller. I cannot just make it a single file, all files on the site needs to be thru this controller, otherwise it will mess everything up. Ino I could just add the code from index.php plus the form page code & just run the php code before all of the html tags, but like I said it has to be called thru index.php. I appreciate your replies, & I hope you guys dont think im an idiot & can understand my question, im terrible with words! Hello forom, I'm hoping there is help for a problem I'm facing. I need to know if I can write an addon in PHP for a script that is written in CGI. I know nothing about CGI scripts but I have a license for a brilliant search engine script that needs extra functionality, so ideally I'd like to build a mod in PHP because its the only language I half understand. The CGI script is called Poweseek SQL - Search end directory script Poweseek SQL presently takes care of all the reciprocals etc between it and the sites it links to. What I would like it to do is enable the link owners to negotiate links among themselves in an automated fashion. Is this a PHP possibilty or do I have to a) Learn CGI or b) Find a suitable PHP script and modify that. I really would like to keep Poweseek SQL if I can. It's money wasted all the time it isn't in production! Thanks for taking the time to read this, all advice welcomed $newsletter_settings_query = "SELECT * FROM newsletter_settings"; $newsletter_settings = mysql_query($newsletter_settings_query) or die("There was a problem with the SQL query: " . mysql_error()); $header_image = $newsletter_settings['sHeaderImage']; $header_name = $newsletter_settings['sHeaderName']; $header_text = $newsletter_settings['sHeaderText']; None of those variables are displaying data. I'm currently making a product tour. I am rewriting the url with javascript and sending the user to their profile pages. example: http://dev.mysite.com/u/jason?welcome I then use php to load my javascript via a get variable. Code: [Select] if (isset($_GET['welcome'])) { echo 'test'; ?> <script type="text/javascript"> $(function(){ focus.set('FOCUSTHIS', 0, 'absolute', 'Personal Information', function (body){ $('<div class="test">.</div><div class="center ptm pbs"><a id="next_4" class="button" href="javascript: void(0)">Continue</a></div>').appendTo(body); }); }); </script> <?php } Any reason why this wouldn't at least echo properly? I am rewriting the URLs with mod rewrite. Can someone help me get this working <?php include "sessionStore.php"; $userfinal = get_username($_SESSION['user_id']); if ($userfinal[username]) { //checks user is logged in switch ($_GET[friends]) { //allows multiple pages default: $get = mysql_query( "SELECT * FROM `friend_requests` WHERE `username` = '$userfinal' "); //gets requests while ($reqs = mysql_fetch_array($get)) { echo ( "Friend Requests $reqs[by] wants to be friends with you. <a href='newfriends.php?friends=accept&user=$reqs[by]'>Accept</a><br/> <a href='newfriends.php?friends=delete&user=$reqs[by]'>Delete</a>" ); //displays requests and shows accept delete links } break; case 'accept': //accept page if ($_GET[user]) { //get username $add = mysql_query( "INSERT INTO `friends` (`friendname` , `username`, `added`) VALUES ('$_GET[user]' , '$userfinal' , '1') "); // add to your friends list $delete = mysql_query( "DELETE FROM `friend_requests` WHERE `by` = '$_GET[user]' "); // deletes friend request echo ( "$_GET[user] has been added as a friend and the request has been deleted" ); // echos the completion } break; //ends accept page case 'delete': // delete page if ($_GET[user]) { //gets username $delete = mysql_query( "DELETE FROM `friend_requests` WHERE `by` = '$_GET[user]' "); // deletes friend request echo ( "$_GET[user]'s request has been deleted" ); // echos completion } break; //ends delete page } // ends switch } else { echo ( "You need to be logged in" ); // not logged in } ?> http://www.phpfreaks.com/forums/index.php?topic=354469.0;prev_next=prev#new ok this is my new post, i think im gona hang around here more oftern. sorry for waking the destertuts but i feel like i need to explain that this post SEE ABOVE is now resoved. If i have made my self look like a noob then fine, im older now and i love PHP its cool. DELETE THIS IF THIS IS UNSESSARY but i just needed to get my point accoross that i have SOLEVED the post and not them admins thanks and gnetuk love it............................................... ....................... I can't remember a time where I got \n to work since I started PHP a month ago. I'm reading the book PHP and MySQL Web Development, and I'm following a tutorial where the author uses the new line break, I'm doing it just like him, for him it works for me it doesn't. This one for example doesn't work for me: <?php echo "test test test \n Test test test"; ?> And on this one, which is from the book tutorial, the \t WORKS, but the \n doesn't: $outputstring = $date."\t".$tiregty." tires \t".$oilgty." oil\t" .$sparkgty." spark plugs\t\$".$totalamount ."\t". $address."\n"; Did something happen with a PHP update, or is it because of my php.ini file settings? I'm using XAMPP with default settings. And I have PHP version 5.3.1 and the book I'm reading is written for PHP 5.3. right this is from my database Database: inbox right i did this code: <?php $totalmess2 = mysql_num_rows(mysql_query("SELECT read='0' FROM inbox")); ?> then <?php echo "$totalmess2"; ?> ive got read in my inbox which just shows whether some one as read the message or not 1=read 0=unread i want to know the total unread message there is in my inbox database whats going wrong this wont display there name Code: [Select] $sql = mysql_query("SELECT firstname,lastname FROM myMembers WHERE id='$logOptions_id' LIMIT 1"); while($row = mysql_fetch_array($sql)){ $fn = $row["firstname"]; $ln = $row["lastname"]; $name=("$fn,$ln"); } |