Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

language feature not compatible... error

Posted on 2011-10-21
6
Medium Priority
?
192 Views
Last Modified: 2013-12-12
Hi,

I have this line which works in php 5.3, but not below. Is there a way to rewrite it for php 5.2?

 
sql("SELECT * FROM idx_cities WHERE city_name REGEXP '^$city_name' LIMIT 0, 10;", function($data){
    echo "<li><span id='{$data['idxID']}'>{$data['city_name']}</span></li>";
  },"");

Open in new window


total PHP/MySQL newbie here... I have (almost) no idea what I'm doing..

Thanks,
Koza
0
Comment
Question by:Kyle Hamilton
  • 4
  • 2
6 Comments
 
LVL 11

Accepted Solution

by:
maeltar earned 2000 total points
ID: 37008155
try something like :

$sql = "SELECT * FROM idx_cities WHERE city_name REGEXP '^$city_name' LIMIT 0, 10;"
$result = mysql_query($sql);
if (!$result)
{
echo "Error ... : " . mysql_error();
exit();
}else{
while ($data = mysql_fetch_assoc($result)
{
echo "<li><span id='{$data['idxID']}'>{$data['city_name']}</span></li>";
}

Open in new window

0
 
LVL 11

Expert Comment

by:maeltar
ID: 37008160
oops line 8 should read

while ($data = mysql_fetch_assoc($result))

Open in new window

0
 
LVL 11

Expert Comment

by:maeltar
ID: 37008168
Sorry, am tired !

Line 1 , remove the semi-colon...
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 25

Author Closing Comment

by:Kyle Hamilton
ID: 37008211
That worked a treat. Thank you.

As a matter of interest, what's the incompatibility, the placement of the function?
0
 
LVL 11

Expert Comment

by:maeltar
ID: 37008231
Not sure to be honest, I just know what works :)
0
 
LVL 25

Author Comment

by:Kyle Hamilton
ID: 37008252
cheers, thanks.
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Containers like Docker and Rocket are getting more popular every day. In my conversations with customers, they consistently ask what containers are and how they can use them in their environment. If you’re as curious as most people, read on. . .
This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question